Compare commits

...

4167 Commits

Author SHA1 Message Date
Wayne Stambaugh 50608c19ff Tag beginning of 5.0.0-rc2 developemnt. 2018-02-24 19:51:04 -05:00
Wayne Stambaugh 42e07736a5 Set kicad version to 5.0.0-rc1 for v5 branch. 2018-02-24 16:14:48 -05:00
Jeff Young 9453a7e186 Fix segfault when not all libraries loaded.
Fixes: lp:1751464
* https://bugs.launchpad.net/kicad/+bug/1751464
2018-02-24 15:49:09 -05:00
Jon Evans baea3080ad Ensure m_Layers is null before it is created 2018-02-24 15:48:36 -05:00
Jeff Young 821a411ac0 Fix regression in user grid size.
Frame, dialog and config file couldn't agree on whether to use
internal units or not.

Frame now stores internal units, and they're now mapped on the
way in/out of the config file.  Dialog was already assuming they
were stored in internal units (though they were previuosly not).

Fixes: lp:1751435
* https://bugs.launchpad.net/kicad/+bug/1751435
2018-02-24 09:21:28 -05:00
Wayne Stambaugh 3a73e775de Revert "Separate copper and graphical zone tools"
This reverts commit fea71c9f8f.
2018-02-24 08:31:25 -05:00
Seth Hillbrand 948396024b Setting Eeschema white foreground for BW printing
Keep any Eeschema color except background a fraction off of true white
to ensure that BW printing shows the lines as black.  Only the
background is allowed to be white in an Eeschema printout.

Fixes: lp:1662859
* https://bugs.launchpad.net/kicad/+bug/1662859
2018-02-23 15:41:41 -05:00
Jeff Young 2473cf6d45 Make plot dialog modeless.
Fixes: lp:1496617
* https://bugs.launchpad.net/kicad/+bug/1496617
2018-02-23 15:03:22 -05:00
Jeff Young 7bd2f14342 Go back to checking individual file timestamps.
Too many external applications fail to touch the parent directory.

Also removes FP_CACHE_ITEM lastMod times and dirty flags as we've
always loaded libraries atomically anyway.

Claws back some of the performance lost by being more efficient
with cache management for sequential calls to Enumerate and then
Load.

Fixes: lp:1750936
* https://bugs.launchpad.net/kicad/+bug/1750936
2018-02-23 10:56:12 -05:00
Jon Evans a83669ab19 Merge PCB_LAYER_WIDGET::SyncRenderStates into ReFillRender 2018-02-23 16:25:58 +01:00
Jeff Young bbad8dc9af Conditionally compile Mac-specific bug fix.
It apparently hangs some other window managers.

Fixes: lp:1748793
* https://bugs.launchpad.net/kicad/+bug/1748793
2018-02-23 10:01:45 -05:00
Jon Evans 8c1847f7ab Don't allow ZONE_FILLER::Fill to run more than once at a time 2018-02-23 09:43:23 -05:00
Jeff Young d043ef5bb6 Address inc/decAlpha bug fix code review comments.
Change menu names to reference Opacity instead of Brighness.
Implement a bottom-stop at 20%.
2018-02-23 14:14:56 +01:00
Jeff Young 63e113740b Fix copy/paste compile error on Mac. 2018-02-23 14:10:06 +01:00
Jon Evans 2991c0d258 Only show microvia and blind/buried via settings if they are enabled 2018-02-23 06:57:27 -05:00
Jon Evans 9a3ea1d53c Rename "Render" to "Items" and a few other wording changes 2018-02-23 06:57:27 -05:00
Jon Evans 1ed7d5f816 Clear out old layer data when loading on top of an existing image
Fixes: lp:1747443
* https://bugs.launchpad.net/kicad/+bug/1747443
2018-02-23 11:59:40 +01:00
jean-pierre charras 1597f31d4b Fix a crash due to uninitialized variable. 2018-02-23 11:50:38 +01:00
jean-pierre charras 9a462d9414 dialog_bom: modify the way a command line is created (python scripts on windows only) to call python scripts
For some reason, when calling python and giving a full filename script, the last separator in the filename
must be '/', not '\'.
Otherwise the import command inside the script does not find files to import in the same folder as the script.

We cannot replace blindly '\' to '/' in command line because it does not work for file on a server (name starting by \\server_name\).
So the fix is just replacing one '\' in python script full filename.
This is not perfect, but at least it works for newly created plugin commands.
2018-02-23 09:50:15 +01:00
Michael afd4710045 Eeschema: New menubar structure
Update menubar to new structure and use common hotkeys.
2018-02-22 20:43:21 -05:00
Michael 1e7275c712 Kicad: Minor menubar changes 2018-02-22 20:43:10 -05:00
Simon Richter d5f5f5e719 Remove duplicate source file from list 2018-02-22 18:40:55 -05:00
Jeff Young e552c2fbff Remove confusing active library interactions with save.
Add a library selector to the save dialog.  Initialize it to the
footprint's library.  This way a straigh-up save will do what's
expected.

However, the user can still select the active library (or any
other library) if they really did want to move the footprint.

Fixes: lp:1750918
* https://bugs.launchpad.net/kicad/+bug/1750918
2018-02-22 18:19:02 -05:00
Jon Evans b67b4b9ea9 Rearrange Render panel of PcbNew layer widget; add spacers 2018-02-22 18:09:26 -05:00
jean-pierre charras 43cb1b7bc7 Fix a compil issue with too old compilers 2018-02-22 21:06:48 +01:00
Jeff Young 80f36ce264 Scale up number of segments per polygon for larger features.
Also fixes a typo in the plot dialog.
2018-02-22 13:17:25 -05:00
Jeff Young 4dda8a39fe Add inc/dec current layer alpha to menus.
Also adds indicators in layers palette for feedback.
Also generates sized images for all indicators instead of using
scaled bitmaps (which didn't look great).
Also fixes a completely unrelated typo in a UI string.
2018-02-22 17:48:14 +01:00
Andrzej Wolski 2e42d5c006 Do not allow selecting tracks if they are hidden
This is a complementary patch to dbafdd39.
2018-02-22 17:31:18 +01:00
Maciej Suminski 2dfc35a9d6 Fix a typo in KI_DIALOG::Title() 2018-02-22 17:26:35 +01:00
Maciej Suminski 918ac567e5 Fix constant naming conflict in KI_DIALOG 2018-02-22 17:15:22 +01:00
Maciej Suminski 8a8b062d8e Fix a copy-paste error in WX_HTML_REPORT_PANEL badges creator 2018-02-22 17:05:06 +01:00
Maciej Suminski fea71c9f8f Separate copper and graphical zone tools
Previously zone drawing tool was used to draw copper and graphical
polygons, but now there is a dedicated tool for that.
2018-02-22 16:28:09 +01:00
Maciej Suminski dd97718a50 Point Editor: prevent creation of self-intersecting polygons 2018-02-22 16:28:09 +01:00
Maciej Suminski fe0e44ba3d PNS: display a message in case of keep-out zone triangulation failure 2018-02-22 16:28:09 +01:00
Maciej Suminski 01aca9d783 KI_DIALOG: flexible way of creating dialogs, including "do not show again" 2018-02-22 16:24:08 +01:00
Maciej Suminski 4da47f2c01 Forbid drawing self-intersecting polygons. 2018-02-22 16:24:08 +01:00
Maciej Suminski 7129dcef91 Added STATUS_TEXT_POPUP for simple popup text display 2018-02-22 15:18:52 +01:00
Maciej Suminski 9673ac4ecd WX_STATUS_POPUP refactor
- Rename WX_STATUS_POPUP -> STATUS_POPUP
- Added Expire() to show a popup temporarily
- Code formatting
2018-02-22 15:18:52 +01:00
Maciej Suminski 7775f59eec Converted zone drawing tools to store points in a SHAPE_LINE_CHAIN
Simplifies the code a bit, removes redundant conversions to/from
std::vector.
2018-02-22 15:18:52 +01:00
jean-pierre charras 997d4dee4f Minor fixes (fix a compil warning, and a incorrectly sized dialog) 2018-02-22 14:29:33 +01:00
Jon Evans dfb0dc4dd5 Change algorithm for GetBoundingPoly() to something that works better 2018-02-22 07:58:47 -05:00
Jeff Young c69db55c1f Fix regression in auto-selection-disambiguation.
Fixes: lp:1646339
* https://bugs.launchpad.net/kicad/+bug/1646339
2018-02-22 11:31:11 +01:00
Jeff Young cb77babe52 Only load all the libraries for a keyword or wildcard search. 2018-02-22 09:35:01 +01:00
Jeff Young 60a9befe7c Print solder and paste masks if user asks for them.
Fixes: lp:1613057
* https://bugs.launchpad.net/kicad/+bug/1613057
2018-02-22 09:04:33 +01:00
Jon Evans f7d0c3997d Don't recache items unnecessarily when toggling D-code display 2018-02-22 08:52:43 +01:00
Jeff Young f60c251c12 Fix regression in plotting %R and %V text. 2018-02-21 18:02:06 -05:00
Andrzej Wolski dbafdd39b9 Add tracks display control to Render tab 2018-02-21 14:29:05 -05:00
Andrzej Wolski 370232f70d Do not draw pads on hidden copper layers. 2018-02-21 14:18:51 -05:00
Andrzej Wolski 4c19606eb7 Fix pads and footprints rendering switches behavior
Pads and footprints rendering switches in Render tab were working incorrectly, as described in bug report:
https://bugs.launchpad.net/kicad/+bug/1743890

This patch fixes it and makes GAL behave as the legacy canvas.

Fixes: lp:1743890
2018-02-21 13:44:52 -05:00
Bernhard Stegmaier b300e8cce5 Update macOS compiling instructions to use KiCad wxWidgets fork. 2018-02-21 13:37:54 -05:00
Jon Evans 0c9d11c180 Add progress reporting for GerbView file loading 2018-02-21 13:17:02 -05:00
Maciej Suminski fad0452c0e Fix builds with scripting disabled
Fixes: lp:1750853
* https://bugs.launchpad.net/kicad/+bug/1750853
2018-02-21 17:46:57 +01:00
Maciej Suminski dd04bcbcbf Make the wxWidgets toolkit test Linux specific
Other platforms (Windows, macOS) have only one base toolkit,
so there is no mismatch risk.
2018-02-21 11:44:32 +01:00
jean-pierre charras 644190301f Minor fixes in strings. 2018-02-21 09:36:27 +01:00
Jeff Young c47821a689 Stop nagging me about annotating.
Adds a checkbox to turn off confirmation dialogs.
2018-02-20 19:12:59 -05:00
Jeff Young 5159fc5952 Stop nagging me about unconnected zones.
Moves the nag dialog to a highly-visible warning immediately above
the OK button.
2018-02-20 19:06:33 -05:00
Jeff Young 900bd9da68 Added error and warning badges to HTML report panel.
Fixes: lp:1669020
* https://bugs.launchpad.net/kicad/+bug/1669020
2018-02-20 18:51:58 -05:00
Wayne Stambaugh df2819e5bc Eeschema: fix sheet schematic file naming bug.
Fixes lp:1750468

https://bugs.launchpad.net/kicad/+bug/1750468
2018-02-20 16:01:52 -05:00
Wayne Stambaugh 961ddd107d Update AUTHORS.txt and contributors list in about dialog. 2018-02-20 15:47:43 -05:00
Maciej Suminski 1013f81608 Fix wxWidgets toolkit detection for msys2 builds 2018-02-20 20:33:02 +01:00
Maciej Suminski 792e9015ac CMakeLists: compare wxWidgets and wxPython toolkits
Having wxWidgets and wxPython build using different toolkits leads
to an unusable build. KiCad executables are linked against wxWidgets
shared libraries, which will be in conflict with wxPython ones that
are loaded at runtime. We cannot easily solve it, so at least warn
the users about expected problems.

More information:
https://forum.kicad.info/t/9493
https://bugs.launchpad.net/kicad/+bug/1746753
2018-02-20 17:51:50 +01:00
Jeff Young cd81254262 Respect 45-degree mode when set from zone dialog.
Fixes: lp:1655073
* https://bugs.launchpad.net/kicad/+bug/1655073
2018-02-20 17:38:20 +01:00
Jeff Young 4d5e1489fb New menu structure for ModEdit.
Includes some dialog changes to go with the menu update.
Includes promoting the Pcbnew graphics mode back to main menu.
Includes renaming Graphics modes to Toolsets.
2018-02-20 10:49:41 -05:00
Jon Evans 01ab8b0584 Use polygonal hit testing for module selection 2018-02-20 10:43:43 -05:00
jean-pierre charras c8458bc8ed Custom pad shape: primitive duplication dialog: better position/rotation of duplicate (new) primitives. 2018-02-20 16:25:58 +01:00
jean-pierre charras bc6763e14d bitmap2cmp_gui: fix incorrect initialization of m_Negative when starting bitmap2cmp. 2018-02-20 14:08:25 +01:00
Michael ed8ca6ec60 Pcbnew menubar tweaks 2018-02-20 13:54:16 +01:00
Jeff Young 702eb48ca0 Fix issues with Bitmap2Component positive/negative radio buttons.
Cleaned up the UI a bit and removed the radio buttons (Negative
is now a checkbox).

Fixes: lp:1744043
* https://bugs.launchpad.net/kicad/+bug/1744043
2018-02-20 13:26:10 +01:00
Maciej Suminski ee6ac1af1d Fix crash on custom shape pad primitive duplication
Fixes: lp:1750463
* https://bugs.launchpad.net/kicad/+bug/1750463
2018-02-20 13:00:57 +01:00
Maciej Suminski be871c0f8c Removed unused variables 2018-02-20 13:00:57 +01:00
Maciej Suminski 602acf1b7c Fixed an assert 2018-02-20 13:00:57 +01:00
jean-pierre charras 3626129631 Very minor fix (remove trailing space in message) 2018-02-20 11:24:31 +01:00
jean-pierre charras 79dac591c8 Custom pad shape primitive not always visible
Fixes: lp:1750458
https://bugs.launchpad.net/kicad/+bug/1750458
2018-02-20 10:52:37 +01:00
Maciej Suminski a752f376a1 Fix autopanning issues when selecting a segment
Fixes: lp:1750302
* https://bugs.launchpad.net/kicad/+bug/1750302
2018-02-20 09:48:48 +01:00
Maciej Suminski 6c1a05a7d5 Coverity fixes
Uninitialized variables: CID #163188 and #174187
Unused variable: CID #168698
2018-02-20 09:14:51 +01:00
Jeff Young 7e0ff6fe8d Fix current directory issue loading Gerbers.
Fixes: lp:1750361
* https://bugs.launchpad.net/kicad/+bug/1750361
2018-02-19 15:09:54 -05:00
Jeff Young 4b01c9e04e Fix undo of pin edit.
Undo stashing must happen before modifications.

Fixes: lp:1750401
* https://bugs.launchpad.net/kicad/+bug/1750401
2018-02-19 15:03:23 -05:00
jean-pierre charras 0e493a3f91 Disallow '/' in labels, Step 2: disallow not allowed chars in all labels (local, global, hierarchical, and sheet pin)
Currently, if a old label already containing a '/' (or a space) is edited, it is accepted,
but no new not allowed char can be added to the label.
(Previously, a sheet pin label was not filtered)
2018-02-19 18:15:53 +01:00
Jeff Young 04d1d503ee Disallow '/' in labels.
Fixes: lp:1749232
* https://bugs.launchpad.net/kicad/+bug/1749232
2018-02-19 18:08:09 +01:00
Jeff Young 5c6b19c55d Don't allow DIALOG_SHIM to reduce size below min.
This should fix a bunch of bugs with run-time generated sizes
that can grow larger than their minimums in other configurations.

Also fixes a related bug in the WX_HTML_REPORT_PANEL where the
min size was set in the wrong place.

Fixes: lp:1692442
* https://bugs.launchpad.net/kicad/+bug/1692442
2018-02-19 10:53:02 -05:00
Jeff Young c27ee1ece3 Fix disappearing origin lines in modedit (and modview).
Fixes: lp:1745701
* https://bugs.launchpad.net/kicad/+bug/1745701
2018-02-19 10:01:30 -05:00
Jeff Young 447fd1bf02 Add a start number to annotate.
This also makes the dialog modeless so that one switch between
sheets while annotating to choose the base numbers for each
sheet (assuming they don't like the base number we pick because
of the order of the sheets).

Fixes: lp:1154131
* https://bugs.launchpad.net/kicad/+bug/1154131
2018-02-19 09:32:54 -05:00
Andrzej Wolski 9241a399a7 Add EDA_RECT hit test for S_POLYGON
Fixes lp:1749989
2018-02-19 10:59:02 +01:00
Maciej Suminski ab8e2419c2 PNS: Handle no-tracks setting in keep out zones
Fixes: lp:1748832
* https://bugs.launchpad.net/kicad/+bug/1748832
2018-02-19 10:25:05 +01:00
Maciej Suminski 2f4ec0c0c4 Code formatting 2018-02-19 10:18:01 +01:00
Jon Evans 0504a6db52 Don't sync zone if polygon triangulation fails 2018-02-19 08:49:34 +01:00
Maciej Suminski 463e944113 Fixed an assert when assigning a bitmap to radio menu item 2018-02-19 08:44:09 +01:00
Jeff Young d67ceea568 Set current sheet number when only annotating a single sheet.
Fixes: lp:1750096
* https://bugs.launchpad.net/kicad/+bug/1750096
2018-02-18 21:12:07 -05:00
Jeff Young 12247db467 Enable Bmp2Component Export button when loaded from argv
Fixes: lp:1608813
* https://bugs.launchpad.net/kicad/+bug/1608813
2018-02-18 17:47:26 -05:00
Jeff Young 3d77ed9e9d Replace Cancel button with Close in Generate Pos dialog
Fixes: lp:1548123
* https://bugs.launchpad.net/kicad/+bug/1548123
2018-02-18 17:07:09 -05:00
Jeff Young e9e3134dab Grid dialog changes to go along with menu changes.
Removes the units from the grid dialog.  They're now set via
the view menu.
2018-02-18 17:03:26 -05:00
Jeff Young 8b4e8fcd26 Dialog changes to go with new menu structure.
Move sketch mode stuff from Display Settings to View menu.
Move Icons in Menus from View menu to General Preferences.
Move Icon Scaling from Display Settings to General Preferences.
Regroup some items in both dialogs for better comprehension.
2018-02-18 17:03:26 -05:00
jean-pierre charras af1281433b fix minor compil warning 2018-02-18 21:22:16 +01:00
jean-pierre charras 6ab76a0373 rename file 2018-02-18 21:11:52 +01:00
Jeff Young b3884669cf Proper error reporting for Annotate dialog.
Also fixes:
- forcing the annotation scope to "full schematic" when run
  as a prerequisite to Generate Netlist.

- a long-standing bug where displaying extra items in a dialog
  would mess up the height of the HTML_REPORT_PANEL (becasue
  we were setting the html window's height rather than its
  parent flexgrid.

- initializing the annotation radio buttons to safe values
  (full schematic and keep existing)

Fixes: lp:1750062
* https://bugs.launchpad.net/kicad/+bug/1750062
2018-02-18 15:08:24 -05:00
jean-pierre charras cf5d93857f PnS router: add support for circles in board outline 2018-02-18 21:00:28 +01:00
Michael 3b085f0d03 Pcbnew new menubar structure 2018-02-18 11:27:52 -05:00
Michael 28705d7c6d Fix up file menu and hotkeys 2018-02-18 11:22:16 -05:00
Wayne Stambaugh 322ce84fb3 Pcbnew: fix minor layout issues with track and via properties dialog.
Fixes lp:1750196

https://bugs.launchpad.net/kicad/+bug/1750196
2018-02-17 19:53:19 -05:00
Wayne Stambaugh 4a3839b48c Pcbnew: use radio buttons instead of check boxes in STEP export dialog.
Fixes lp:1749447

https://bugs.launchpad.net/kicad/+bug/1749447
2018-02-17 19:02:45 -05:00
Maciej Suminski 7a57606af3 Mute shadow warnings in pcbnew{,PYTHON}_wrap.cxx 2018-02-17 23:27:10 +01:00
Maciej Suminski c3197a5906 CMakeLists: detect gtk3 using wx-config 2018-02-17 21:00:16 +01:00
Tomasz Włostowski dfb98ce70b router: use more kicad-ish arc representation 2018-02-17 18:25:20 +01:00
Tomasz Włostowski 50c1ff67eb router: treat negative net indices as always colliding 2018-02-17 18:25:20 +01:00
Tomasz Włostowski b05f95e7af RTREE: avoid uninitialized variables 2018-02-17 18:25:20 +01:00
Tomasz Włostowski 5fef750b49 SHAPE_ARC: use more Kicad-ish arc representation. Fixes board outline collisions issues in the P&S 2018-02-17 18:25:20 +01:00
Robbert Lagerweij ed0e226aab pcbnew: add and use new icons for align left, right, top & bottom
NEW: add new align icons based on the existing align_items.svg icon, just flipped and rotated
CHANGED: change the context menu to use the new align icons
2018-02-17 11:58:36 -05:00
Maciej Suminski 28f1209ce9 Fixed invalid dynamic_cast in Align Tool
Fixes: lp:1750107
* https://bugs.launchpad.net/kicad/+bug/1750107
2018-02-17 11:36:51 +01:00
Maciej Suminski 24fcdb00cc Eagle importer: convert special characters in net names
Convert '!' to '~' to reflect overbar toggling and change '~' to '~~'.
Now it matches the net names in schematics import plugin.
2018-02-17 00:03:28 +01:00
Maciej Suminski b1f456fade Eagle importer: use only global net labels
Local net labels are preceded with sheetpath (even for single sheet
schematics it is '/') causing net name conflicts between schematics and
layout. It can be easily avoided by using exclusively global net
labels, at the cost having uglier schematics.
2018-02-17 00:03:28 +01:00
jean-pierre charras de72ef8518 Fix code after renaming files 2018-02-16 20:27:57 +01:00
jean-pierre charras a889cd7cde rename files 2018-02-16 20:27:55 +01:00
jean-pierre charras a5a6c4a012 Fix code after renaming files 2018-02-16 20:27:16 +01:00
jean-pierre charras 35a7f7a7b4 rename files: replace module by footprint in dialog filenames 2018-02-16 20:27:14 +01:00
Maciej Suminski 9e80eff90a Eagle importer: two stage netlist update
After Eagle project import, schematic and board netlists are inconsistent:
footprints do not have sheetpaths assigned, schematics are unannotated.

One can update netlist either by references or timestamps, but timestamps
are empty in pcbnew, and updating by reference must by preceded by
annotation which may lead to broken links between board and schematics
(Eagle does not require references to end with a number, so KiCad annotater
will add numbers in such cases).

To fix the problem, there is a two step netlist update:
- update by reference without the annotation step, to assign
correct sheetpaths to footprints
- update by timestamp, after symbols are annotated, in order to
update references in the board

Fixes: lp:1748502
* https://bugs.launchpad.net/kicad/+bug/1748502
2018-02-16 19:37:23 +01:00
Maciej Suminski 43523a6179 Options for board update KiWay request (MAIL_SCH_UPDATE[_REQUEST])
Board update KiWay request may now contain options in the message
payload:
- "no-annotate": do not enforce annotation
- "quiet-annotate": annotate without displaying a dialog
- "by-reference": update netlist by reference, no dialog displayed
- "by-timestamp": update netlist by timestamp, no dialog displayed
2018-02-16 19:37:23 +01:00
Robbert Lagerweij b356275e76 pcbnew: add align center and align middle tools and related icons
NEW: add placement tools that allow aligning the centers of items in a selection, both vertically and horizonally
2018-02-16 12:01:01 -05:00
Robbert Lagerweij 7683364bdb pcbnew: code improvements align tools 2018-02-16 11:46:38 -05:00
Wayne Stambaugh a2df82537b Change how version strings are generated.
Git is always used to generate the KiCad version string using the
command `git describe --dirty`.  This gives a more concise and
accurate version string than the previous method.  When git is not
available, the version string defaults to the value defined in
KiCadVersion.cmake.  It is imperative that moving forward that the
default version string be updated the commit following a git tag
so that when git is not available, the last known commit following
a git tag will at least give some usable information about which
development branch of KiCad was used for a build.
2018-02-16 11:45:58 -05:00
Maciej Suminski c95340fbaf Eagle importer: replace invalid character with '_' to match PCB<->SCH 2018-02-16 16:52:14 +01:00
Jeff Young e2f82118a2 Rebuild project tree when unarchiving into project dir.
Fixes: lp:1749955
* https://bugs.launchpad.net/kicad/+bug/1749955
2018-02-16 16:01:32 +01:00
Maciej Suminski 67ccf769c7 Symbol Editor: fix a crash when saving/reverting a library not present in sym-lib-table 2018-02-16 12:13:02 +01:00
jean-pierre charras 0ab15fa0ee Pcbnew cross-probing: highlight in GAL canvas doesn't work properly when selecting a symbol in Eeschema on some installs.
This fix forces a refresh.

Fixes: lp:1749799
https://bugs.launchpad.net/kicad/+bug/1749799
2018-02-16 12:08:31 +01:00
Maciej Suminski 3c9a5b0966 Library Editor: make 'Save All' the default save action
Fixes: lp:1748555
* https://bugs.launchpad.net/kicad/+bug/1748555
2018-02-16 11:28:37 +01:00
Maciej Suminski 81b3c420fd Set OK as the default button in Select{Single,Multi}Option() dialogs 2018-02-16 11:28:37 +01:00
Maciej Suminski ed9a14f01d PNS: disable autopanning in case of an error 2018-02-16 11:28:37 +01:00
jean-pierre charras 07e939ed5a Remove unused code. 2018-02-16 09:02:25 +01:00
Jeff Young 24b5152240 Don't set modified flag for render settings in modedit.
Fixes: lp:1744521
* https://bugs.launchpad.net/kicad/+bug/1744521
2018-02-15 18:34:33 -05:00
Jeff Young ce0d1aca8d Draw the grid and the grid origin in the grid colour.
Fixes: lp:1749564
* https://bugs.launchpad.net/kicad/+bug/1749564
2018-02-15 18:29:56 -05:00
Jeff Young ea1474307c Allow very large grids.
Some folks use them for panelization, drawing board edges, etc.
Whatever the use, we shouldn't get in the way.

Fixes: lp:1484207
* https://bugs.launchpad.net/kicad/+bug/1484207
2018-02-15 18:21:21 -05:00
Jeff Young 7c506f5b3a Add PTH, NPTH and Background to Footprint Editor render settings.
Fixes: lp:1744521
* https://bugs.launchpad.net/kicad/+bug/1744521
2018-02-15 16:27:10 -05:00
Jeff Young e7d98f89a1 Fix display of datasheet URLs and shorten them if necessary.
Fixes: lp:1676174
* https://bugs.launchpad.net/kicad/+bug/1676174
2018-02-15 22:01:35 +01:00
Jeff Young 908697c9c8 Turn place footprint's browser back on for Mac.
Fixes: lp:1749436
* https://bugs.launchpad.net/kicad/+bug/1749436
2018-02-15 14:45:01 -05:00
Jeff Young 29b28de317 Promote pad renumberer to a proper tool.
This gives it a context menu with a Cancel item.
Commit also includes a couple of fixes to the Pads submenu.
2018-02-15 17:15:26 +01:00
Jeff Young 93999f7af6 Change "Automatic neckdown" to "Optimize pad connections".
Fixes: lp:1485202
* https://bugs.launchpad.net/kicad/+bug/1485202
2018-02-15 17:02:44 +01:00
Michael 2e00b8ceba Remove duplicate track menu item 2018-02-15 16:56:01 +01:00
Michael d2e6f3a0e6 Improve edit menu and use common hotkeys 2018-02-15 16:46:17 +01:00
Michael 62487fa891 Fix spelling error 2018-02-15 16:46:10 +01:00
Maciej Suminski 461b6aff5e Do not set bitmaps for wxITEM_RADIO menu items on Linux and macOS 2018-02-15 16:40:29 +01:00
Michael Geselbracht 5d738dcb6d Coverity fix for libeval (CID #169327) 2018-02-15 15:43:12 +01:00
Maciej Suminski 4a8a168079 Netlist dialog: highlight nets on selection 2018-02-15 15:35:29 +01:00
Maciej Suminski d08f19a0a2 FP placer: enable autopanning/cursor capture only during placement
Fixes: lp:1749548
* https://bugs.launchpad.net/kicad/+bug/1749548
2018-02-15 11:53:23 +01:00
Jeff Young 809093acd0 Don't bail out of loading when one library couldn't be found.
Also includes some cleanup to the error dialog (removing
sunken border, fixing OK button, etc.)

Fixes: lp:1749572
* https://bugs.launchpad.net/kicad/+bug/1749572
2018-02-15 10:53:03 +01:00
Maciej Suminski 570f4dd991 Coverity fixes
CIDs:
174166
174170
174171
2018-02-15 10:27:01 +01:00
Maciej Suminski 1e054071fc Refresh track & via net names after netlist update
Fixes: lp:1749411
* https://bugs.launchpad.net/kicad/+bug/1749411
2018-02-15 10:26:19 +01:00
jean-pierre charras 4012aa70da Fix a few minor Coverity warnings 2018-02-15 10:16:17 +01:00
Maciej Suminski bfa0b98b14 Corrected hotkey description to reflect new canvas naming 2018-02-15 09:30:10 +01:00
jean-pierre charras dded3429fd Add missing hotkey to help menu 2018-02-15 09:23:42 +01:00
Wayne Stambaugh b8c00a0d07 Fix hierarchical schematic file sheet path bug.
Sheet file name paths were not being saved and restored properly under
certain conditions when walking the sheet hierarchy causing schematic
load errors.

Changed debugging output to use wxLogTrace left over from last fix.

Fixes lp:1748401

https://bugs.launchpad.net/kicad/+bug/1748401
2018-02-14 13:45:41 -05:00
Seth Hillbrand fd0b364b91 Eeschema: Ensure all items in a block are deleted
Deleting lines can create new ones when old lines are merged as the
result of a delete operation.  This checks that all items inside a
selection block are deleted before finishing.

Fixes: lp:1748907
* https://bugs.launchpad.net/kicad/+bug/1748907
2018-02-14 13:16:42 -05:00
Jeff Young f69d499527 Use async footprint loader for Place Footprint.
Fixes: lp:1674053
* https://bugs.launchpad.net/kicad/+bug/1674053
2018-02-14 13:05:28 -05:00
jean-pierre charras c16af6f2ff Pad properties dialogs: allow positive values for solder paste mask layer (unusual but existing case)
Footprint properties dialogs: add test for negative net clearance, similar to the Pad properties dialog test.
Add also a info message in dialogs, to avoid mistakes when setting the local clearances.
2018-02-14 17:52:21 +01:00
Maciej Suminski 6afdf1cf87 PNS router: reset forced cursor position
Track dragging forces the cursor position, which is still kept when PNS
router is launched again. It is avoided by resetting the force cursor
position option before running the event loop.
2018-02-14 17:34:32 +01:00
Maciej Suminski 104b606ca9 Disable autopanning when starting certain tools
Tools preserve their state between runs, so it could happen that
activating a tool restores the state when autopanning is enabled, even
though it should not be.
2018-02-14 15:40:20 +01:00
Maciej Suminski 11d8b9ff55 Fix double disambiguation menu when dragging 2018-02-14 15:34:09 +01:00
Maciej Suminski 151021919e Tool Manager: yet another approach to handling tool view control settings
All calls to {save,apply}ViewControls() have been replaced with a new
method: setActiveState(). The advantage is that setActiveState() always
saves view controls settings to the tool that set them. As long
as setActiveState() is called every time there is a tool context
switch, the changes are kept up-to-date.

Fixes: lp:1748613
* https://bugs.launchpad.net/kicad/+bug/1748613
2018-02-14 15:34:05 +01:00
Maciej Suminski 21a2c8d562 Fix cursor control with arrow keys
Fixes: lp:1749328
* https://bugs.launchpad.net/kicad/+bug/1749328
2018-02-14 09:23:44 +01:00
Maciej Suminski 5c8accef8e Enable GL debug output only if available 2018-02-14 08:52:08 +01:00
Jeff Young f68bf33cd3 Implement progress reporter for cvpcb footprint loading.
Fixes: lp:1676910
* https://bugs.launchpad.net/kicad/+bug/1676910
2018-02-13 20:21:38 -05:00
Jeff Young 4bae901dc8 Centralize zoom-to-fit code.
Fixes a bunch of errors:
- libedit and libbrowser would zoom to bounding box but centre on canvas
- libedit, libbrowser and gerbview didn’t take the scroll bars into account
- pcbnew didn’t take scroll bars into account or apply the 10% margin
- appending a board file would re-centre, but not re-zoom

Fixes: lp:1504302
* https://bugs.launchpad.net/kicad/+bug/1504302
2018-02-13 20:06:03 -05:00
Maciej Suminski ac9fc949bd Code formatting for 013f7b4d 2018-02-13 14:56:11 +01:00
Russell Oliver 34b52c91b7 Add empty eeschema page layout for Eagle schematic import.
Fixes: lp:1729722
* https://bugs.launchpad.net/kicad/+bug/1729722
2018-02-13 14:56:11 +01:00
Maciej Suminski 90d53df790 Fix double disambiguation menu on track removal
Commit complementary to 4f0c9b6b. In case there were multiple tracks
under the cursor, disambiguation was shown twice because
SELECTION_TOOL::selectConnection() cleared the selection and requested
it again.
2018-02-13 14:56:11 +01:00
jean-pierre charras a1af13f34d replace '%s' by \"%s\" in a few sentences to be consistent with all other messages 2018-02-13 10:22:05 +01:00
jean-pierre charras 6371e341de demos update 2018-02-13 09:55:41 +01:00
Maciej Suminski 365ab99a6a GAL: update cursor position on panning and scrolling
Fixes: lp:1749082
* https://bugs.launchpad.net/kicad/+bug/1749082
2018-02-13 09:45:06 +01:00
Maciej Suminski c9d9cec6ad LIB_MANAGER: exception handlers display error messages 2018-02-13 08:50:51 +01:00
Wayne Stambaugh 6f6a02615c Pcbnew: fix dialog button sizer padding in pad properties dialog. 2018-02-12 20:15:17 -05:00
Jeff Young cd2f5cdbd5 Standardize pad properties terminology.
Fixes: lp:1743153
* https://bugs.launchpad.net/kicad/+bug/1743153
2018-02-12 19:51:32 -05:00
Jeff Young ac09cfaef4 Wire up <return> for eeschema find dialog.
Fixes: lp:1749026
* https://bugs.launchpad.net/kicad/+bug/1749026
2018-02-12 19:41:34 -05:00
Maciej Suminski 3ee93caafe Converted PNS track/via size settings dialog to use Transfer{To,From}Window()
Dialogs were non functional since they were converted to take advantage
of TEXT_CTRL_EVAL.
2018-02-12 23:20:06 +01:00
Jeff Young 53e705f634 Add Get and Move Footprint to empty-selection-context menu.
Also adds Cancel context menu items for Place Footprint,
Place Target, Place Drill Origin and Place Grid Origin tools,
as well as the standard Zoom and Grid choices.

Removes the Paste context menu item from the Place Drill
and Place Grid Origin tools.

Fixes: lp:1568396
* https://bugs.launchpad.net/kicad/+bug/1568396
2018-02-12 21:50:51 +01:00
Wayne Stambaugh 01faca2799 Fix release build error caused by previous commit. 2018-02-12 13:36:03 -05:00
Jeff Young 9d26253b2c Don't rely on live pointers in search data.
Try as you might to keep them fresh, there's no gaurantee.
Instead, just treat them as weak references and search the
existing items for a pointer-value match.

This also allows us to remove some code which kept recycling
the search position back to the start ever time a replace
was done.

Fixes: lp:1559258
* https://bugs.launchpad.net/kicad/+bug/1559258
2018-02-12 11:46:39 -05:00
Jeff Young 2a9aa11422 Clean up Pad Properties layout
Fixes: lp:1684376
* https://bugs.launchpad.net/kicad/+bug/1684376
2018-02-12 11:10:41 -05:00
Jeff Young a16430a725 Treat %R and %V texts as references and values when rendering.
Fixes: lp:1733894
* https://bugs.launchpad.net/kicad/+bug/1733894
2018-02-12 10:50:43 -05:00
Russell Oliver e340e8a838 Eagle Schematic Import: Label Placement fix.
Extra labels to preserve eagle named nets feature are now placed at the
end of a wire segment instead of the middle of a wire. Prevents a label
being placed on crossing wires that are not connected by a junction
resulting in an incorrent netlist.
2018-02-12 15:35:28 +01:00
Maciej Suminski d3998a2d08 Do not override cursor position when context menu is active
It affected just started tools that did not have cursor settings
stored, so could not be reverted after the context menu is gone.

Fixes: lp:1748613
* https://bugs.launchpad.net/kicad/+bug/1748613
2018-02-12 11:21:07 +01:00
Maciej Suminski 4f0c9b6b20 Fix double disambiguation menu when removing footprints
Second disambiguation menu was caused by another call to
SELECTION_TOOL::RequestSelection() meant to get the list of
connected tracks. When there were only footprints under the cursor,
it asked the user again to pick an item to remove.

Fixes: lp:1748521
* https://bugs.launchpad.net/kicad/+bug/1748521
2018-02-12 10:34:22 +01:00
Jeff Young ed127e866a Fix bone-headed mistake in selection highlighting patch.
(__UNIX__ *is* defined for Mac/OSX)
2018-02-12 08:41:37 +01:00
jean-pierre charras 62ef63501c Cvpcb: remove fixed size and use the last stored size.
It fixes a bug created by commit b1eed74b55.
Other very minor fix in Cvpcb
2018-02-11 20:14:48 +01:00
Jeff Young 6588bef1b1 Make Ignore-DRC button tooltip Legacy-specific.
Fixes: lp:1664173
* https://bugs.launchpad.net/kicad/+bug/1664173
2018-02-11 12:33:33 -05:00
Jeff Young 2b0f789b85 Treat %R and %V texts like Reference and Value for plotting.
Fixes: lp:1677321
* https://bugs.launchpad.net/kicad/+bug/1677321
2018-02-11 12:27:22 -05:00
Jeff Young 916f79d5a1 Performance fixes for the place footprint list all dialog.
Smartens the cache freshness checking, and adds checksums of
constituent-directory last-mod-dates to the footprint info
list.

Also inserts the dataPtrs into the list at the same time as
the text to keep wxWidgets from measuring the width of the
text twice (yes, really).  And converts the list to default-
column widths in case the wxWidgets patch is present to
greatly speed list creation (by not measuring all that text).

On my machine drops the first-load time from 4s to 2.5s and
the subsequent-load times from 2.5s to < 1s.  With the
wxWidgets patch subsequent-loads become near-instantaneous.
2018-02-11 11:51:48 -05:00
Jeff Young a7cdd94212 PCBnew clarify selection menu doesn't highlight individual selection on Windows
(Use Mac solution to disambiguation highlighting on MSW).

Fixes: lp:1594029
https://bugs.launchpad.net/kicad/+bug/1594029
2018-02-11 13:29:45 +01:00
Damien Espitallier a04965c36c Enable exception handler for python LoadBoard function 2018-02-10 18:34:20 -05:00
Jeff Young 0bbf961881 Clean up Cancel vs Close buttons in dialogs.
Many had already been fixed but weren't working on Mac because
of the DIALOG_SHIM hack (now fixed).  Others hadn't been updated
yet.  Also includes some cleanup for elipses in buttons and
layout.

Fixes: lp:1748506
* https://bugs.launchpad.net/kicad/+bug/1748506
2018-02-10 17:53:12 -05:00
Jeff Young 1afbfad44a Use "..." uniformly in menus.
See the bug report for some wording changes and a couple of
menu restructurings that were also cleaned up.

Fixes: lp:1597827
* https://bugs.launchpad.net/kicad/+bug/1597827
2018-02-10 17:32:28 -05:00
Wayne Stambaugh e832212d89 Pcbnew: fix bug in footprint library plugin cache reloading.
Check the footprint library path modification against the last load
time and reload the cache if the path modification time has changed
when a new file is added to the footprint library path.

Fixes lp:1727977

https://bugs.launchpad.net/kicad/+bug/1727977
2018-02-10 17:14:53 -05:00
Wayne Stambaugh 5ef0b6b67e Pcbnew: add refill zone option to DRC.
Make refilling zones during DRC optional to prevent the board from being
changed by changes in the polygon filling.  Default to off to prevent
changes by default.

Fixes lp:1721547

https://bugs.launchpad.net/kicad/+bug/1721547
2018-02-10 15:17:30 -05:00
jean-pierre charras b4a17808b0 pcbnew: Fix bug (Linux specific): change Footprints dialog: All radio buttons selected
* Cleanup .fbp file, and remove fixed sizes in a few widgets.
* use wxID_CANCEL in close button ID, to allow closing the dialog by the ESC key

Fixes: lp:1748626
https://bugs.launchpad.net/kicad/+bug/1748626
2018-02-10 18:40:39 +01:00
jean-pierre charras 5ecfd32654 OpenGl fix: call enableGlDebug( true ) only in Kicad debug build, and only on Linux
(Because we have crashes on OSX and some Window installs)
2018-02-10 11:57:22 +01:00
jean-pierre charras dba198e576 Fix code after renaming files
Change class names according to the new name of the main dialog
2018-02-09 17:36:54 +01:00
jean-pierre charras 35a0688bf7 rename dialog_bom_editor* files to dialog_fields_editor_global*
rename also associated files
2018-02-09 17:36:52 +01:00
Maciej Suminski 8a68a21570 Enable OpenGL debug output in debug builds 2018-02-09 16:20:38 +01:00
Maciej Suminski 6dbd7a8d73 Selection Tool: compare footprint area ratio only if there are >1 footprints
There is no point in comparing candidate footprint areas when there is
only one footprint, because it is always equal to 1 and rejected.

Fixes: lp:1745787
* https://bugs.launchpad.net/kicad/+bug/1745787

Fixes: lp:1747378
* https://bugs.launchpad.net/kicad/+bug/1747378
2018-02-09 16:19:48 +01:00
Maciej Suminski 86566fc142 Fix a hang-up during zone filling
On OpenMP single core systems only the first thread launched. It means
that only the UI updating thread was running, without the one
responsible for actual computation. It is fixed by enforcing at least
two threads.
2018-02-09 14:26:06 +01:00
Maciej Suminski c39fd46c07 PROGRESS_REPORTER: code formatting 2018-02-09 14:20:25 +01:00
Tomasz Włostowski bc7ca08f07 router: check type before static_cast-ing 2018-02-09 13:00:57 +01:00
Jeff Young 15f1300221 Flip sense of Plot pads on silkscreen.
Added a better tooltip too.

Fixes: lp:1372233
* https://bugs.launchpad.net/kicad/+bug/1372233
2018-02-09 11:03:03 +01:00
Kristoffer Ödmark 8f4a954236 Differ the dialog text for when choosing power-symbols and all symbols 2018-02-09 11:00:32 +01:00
Maciej Suminski 2c3a7c9dc4 CMP_TREE_MODEL: Reset SearchTextNormalized flag when a node is updated 2018-02-09 11:00:32 +01:00
jean-pierre charras ab73c80ee6 Dialog pad properties: minor fixes.
Fix incorrect text for non flipped footprints.
minor cosmetic enhancements.
2018-02-09 10:50:45 +01:00
jean-pierre charras 07fff6ed35 Eeschema, choose component dialog: remember the relative size of the component tree and the symbol viewer canvas during a session 2018-02-09 08:08:14 +01:00
Michael Geselbracht b04b1dcfb5 Update fields: Add option to omit empty fields
Fixes lp:1747405

https://bugs.launchpad.net/kicad/+bug/1747405
2018-02-08 21:05:10 -05:00
Jeff Young 6c61a46721 Rationalize label orientations for dialog display.
Fixes: lp:593795
* https://bugs.launchpad.net/kicad/+bug/593795
2018-02-08 20:16:26 -05:00
Jeff Young 60a4ce6623 Don't let pads that *should* be NPTHs get lost.
Borrow the hidden text colour so that they can be distinguished
from PTHs and correctly-marked NPTHs.

Fixes: lp:1494738
* https://bugs.launchpad.net/kicad/+bug/1494738
2018-02-08 15:04:23 -05:00
Russell Oliver 864c152a5b Add converted footprint library to library table during Eagle project. 2018-02-08 13:54:40 -05:00
Jeff Young a6c436c2cd Move Pad Properties flipped warning.
This makes it more visible and keeps it from messing up the layout
of the dialog.

Fixes: lp:1426756
* https://bugs.launchpad.net/kicad/+bug/1426756
2018-02-08 13:14:41 -05:00
Robbert Lagerweij 54ce01f8d5 pcbnew: make the distribute horizonally and vertically tools gap based
This changes the distribute horizonally and vertically tools to place
items with constant gaps between them. The previous implementation put
item centers evenly apart but thereby ignored the relative width and
height of the items (i.e. wide items appeared closer together than
narrow items).

Fixes lp;1745366

https://bugs.launchpad.net/kicad/+bug/1745366
2018-02-08 08:44:55 -05:00
Robbert Lagerweij 3556c4b8d6 pcbnew: change alignment tools use footprint rect where appropriate
Using footprint rects instead of the larger bounding box means that
reference and value texts no longer influence the positioning of the
footprint in unexpected ways. Treatment of non-module items is
unchanged.
2018-02-08 08:44:55 -05:00
Andrzej Wolski 936a8c1a7e Initialize color of vias netnames text
LAYER_VIAS_NETNAMES color was not initialized which resulted in black text, not visible in outline mode.
2018-02-08 08:09:04 -05:00
Jon Evans 9452c61462 Use vector instead of bitset for VIEW_ITEM_DATA layer storage
Shows 10-15% speed improvement in rendering large files in MacOS
2018-02-08 11:54:18 +01:00
Tomasz Włostowski c0b61c19b7 router: fixed use-after-free error occuring when a newly routed segment covered exactly an older one
Fixes: lp:1747973
* https://bugs.launchpad.net/kicad/+bug/1747973
2018-02-08 11:34:31 +01:00
Maciej Suminski 835fc22892 wxWidgets/GTK3 compatibility fixes for eeschema
- Keep refreshing the screen as the cursor is moved.
- Invert the cursor color as it is not drawn using XOR mode anymore.
2018-02-08 11:08:17 +01:00
Maciej Suminski 4561b2cba9 GTK3: Display a warning and enable wxGraphicsContext 2018-02-08 11:07:25 +01:00
jean-pierre charras 2fad12bda0 Fix bug: Pressing Enter in the Move Relative dialog doesn't close the dialog.
Fix also minor issues in this dialog.

Fixes: lp:1748054
https://bugs.launchpad.net/kicad/+bug/1748054
2018-02-08 10:51:05 +01:00
jean-pierre charras be70ce7d4a Global pad edition:Custom Pad Shapes incorrectly exported (push command)
Fixes: lp:1748043
https://bugs.launchpad.net/kicad/+bug/1748043
2018-02-08 09:24:38 +01:00
jean-pierre charras 826efab999 Add comments. 2018-02-07 14:24:10 +01:00
jean-pierre charras a088ea84fd Rename files 2018-02-07 14:16:05 +01:00
Jeff Young 17ce87a7a5 Add library descriptions to component tree.
Fixes: lp:1747547
* https://bugs.launchpad.net/kicad/+bug/1747547
2018-02-07 08:45:33 +01:00
Jon Evans a35cc44bd1 Change mechanism for updating gerbview toolbar widths 2018-02-06 17:44:15 +01:00
Maciej Suminski f0adf81a99 Do not draw circles of 0 radius
Apparently calling wxDC::DrawEllipse() with parameters resulting in a
circle with radius equal to 0 lead to printing problems.

Fixes: lp:1746210
* https://bugs.launchpad.net/kicad/+bug/1746210
2018-02-06 17:28:56 +01:00
Russell Oliver 8f07da7953 Fix empty footprints when using Eagle libraries
This removes a line that deletes the templates created from the eagle
library every time EAGLE_PLUGIN::init( const PROPERTIES* aProperties )
is called, which seems quite often. The templates are deleted though if
the library path for the plugin is changed or the file has been
modified.

Fixes: lp:1731802
* https://bugs.launchpad.net/kicad/+bug/1731802
2018-02-06 14:50:08 +01:00
Jean Philippe EIMER e0f7958dbd Compatibility fixes for GLM 0.9.9
Fixes: lp:1746546
* https://bugs.launchpad.net/kicad/+bug/1746546
2018-02-06 13:30:13 +01:00
jean-pierre charras 8d0932dd58 Fix MSW issue with Exchange Footprints dialog, step 2 2018-02-06 10:59:48 +01:00
Jeff Young 7c48fad737 Fix MSW issue with Exchange Footprints dialog.
Fixes: lp:1747413
* https://bugs.launchpad.net/kicad/+bug/1747413
2018-02-06 10:59:47 +01:00
Tomasz Włostowski 271363f822 router: support for board outline 2018-02-06 09:43:56 +01:00
Tomasz Włostowski 2faf1a1ed3 Initial support for keepout zones in the P&S router. 2018-02-06 09:43:56 +01:00
Chris Pavlina d1a45d1476 Remove icon scaling diagnostic from eeschema 2018-02-05 19:49:07 -07:00
Wayne Stambaugh 00749af914 Eeschema: fix using subpaths in sheets.
Fix double path name issue when using sheet file name paths that differ
from the project path.

This fix also allows for nesting schematics in subfolder in multiple
root paths.

Fixes lp:1745109
https://bugs.launchpad.net/bugs/1745109

Fixes lp:1735982
https://bugs.launchpad.net/bugs/1735982
2018-02-05 17:07:33 -05:00
jean-pierre charras ac3bf11bc4 Fix a minor render issue in GAL mode: hole contours inside a zone outline are not drawn. 2018-02-05 19:50:02 +01:00
Maciej Suminski 351a8d72b8 Better test whether a symbol library is saved to its original file
File names can be reliable compared only after normalization. The
problem is the easiest to observe on Windows, where one can use slash or
backslash as path separator, so even though C:/file.txt and C:\file.txt
pointed to the same file - simple string comparison would indicate they
are different files.

Fixes: lp:1744724
* https://bugs.launchpad.net/kicad/+bug/1744724
2018-02-05 17:04:10 +01:00
Maciej Suminski fe62760f39 Corrected a BOARD::SetElementVisibility() invocation.
Supplementary fix to 6b12fef2.
2018-02-05 12:20:31 +01:00
Jon Evans 1f487593fa Respect item polarity when redrawing cached gerber view items
Fixes: lp:1746825
* https://bugs.launchpad.net/kicad/+bug/1746825
2018-02-05 07:55:15 +01:00
Jeff Young b0d1e49319 Fix plotting of 360 degree arcs and printing of mirrored arcs.
The second issue is OSX-only; the first is universal.
2018-02-05 07:53:51 +01:00
Jeff Young 6b12fef288 Print items irrespective of render settings.
This fixes SMD pads and module text.  All the other setting were
already correct.

Fixes: lp:1744730
* https://bugs.launchpad.net/kicad/+bug/1744730
2018-02-04 21:26:52 +01:00
jean-pierre charras 141ef0c4be Dialog footprint generators list selector: open the first page (generators list) by default. 2018-02-04 18:38:01 +01:00
jean-pierre charras b11b9b9d0d Fix forgotten change in kicadplugins.i, after changing he class name PYTHON_FOOTPRINT_WIZARDS to PYTHON_FOOTPRINT_WIZARD_LIST
This bug prevent loading Python wizards.
2018-02-04 18:27:32 +01:00
jean-pierre charras c7bc154045 Track cleaner: make option "Delete dangling tracks" working again. 2018-02-04 15:05:31 +01:00
jean-pierre charras 821668d96c rename class_collector.h to collector.h 2018-02-04 10:49:37 +01:00
jean-pierre charras 9c22303551 Pcbnew: Fabrication Outputs: Footprint position (.pos) file CSV format : double quote ref, value and package name.
It avoid issues with texts containing a comma, as fields are separated by comma in csv file.

Fixes: lp:1747186
https://bugs.launchpad.net/kicad/+bug/1747186
2018-02-03 21:30:09 +01:00
jean-pierre charras a7a7f62cb7 Specctra export: export roundrect pads with the right shape 2018-02-03 18:50:55 +01:00
Seth Hillbrand fddd5abef1 Merges a line after manually removing its junction.
Fixes: lp:1746998
* https://bugs.launchpad.net/kicad/+bug/1746998
2018-02-03 10:50:10 +01:00
jean-pierre charras 1858852f57 rename files 2018-02-02 21:57:12 +01:00
jean-pierre charras dc66b73a2c Make specctra export of custom pad shapes working with Freerouter 2018-02-02 18:52:44 +01:00
Maciej Suminski 95864780e2 Fix cursor freezes in GAL
Launching right click context menu overrides the cursor position, so all
actions executed by the tools will be performed in the right click
position. It created an issue, as the overridden cursor settings were
saved into wrong context if there was another tool activated in the
meantime.

Current implementation saves cursor settings for all tools and restores
them once the right click context menu disappears.

Fixes: lp:1745981
* https://bugs.launchpad.net/kicad/+bug/1745981

Fixes: lp:1746507
* https://bugs.launchpad.net/kicad/+bug/1746507
2018-02-02 19:08:05 +01:00
Maciej Suminski b497673b89 Point Editor: do not modify cursor snap settings 2018-02-02 19:08:05 +01:00
jean-pierre charras d00fafe2ab GAL mode: Ensure a minimal zoom level change on mouse wheel, especially when canvas redraw takes a long time (more than 100ms)
Previously, the zoom level change could be very small ( <= 1.05, that is a very small zoom level change), especially for large boards.
2018-02-02 13:19:59 +01:00
jean-pierre charras d7cfacb6f3 Specctra/Freerouter export fix a few issues:
* Specctra exported polygons are now closed (as required)
* export custom shape is provided in code, but not activated, because i have no way to text it
* fix Specctra export dialog (replace OK and Cancel buttons by only one Close button)
2018-02-02 12:55:11 +01:00
jean-pierre charras b420845242 Update demos 2018-02-01 13:25:56 +01:00
jean-pierre charras 0c8b852e52 rename files 2018-02-01 11:05:01 +01:00
jean-pierre charras e69ddf0e13 rename files 2018-01-31 17:10:01 +01:00
Wayne Stambaugh 277b65b88e Remove macos patches.
The KiCad maintains a custom wxWidgets repo for macos builds so these
patches are not longer required.  The KiCad macos wxWidgets repo can be
found at:

https://github.com/KiCad/wxWidgets
2018-01-31 10:18:41 -05:00
Jeff Young 53a05f18e1 Code review issues from exchange footprints dialog.
Fixes: lp:1466857
* https://bugs.launchpad.net/kicad/+bug/1466857
2018-01-31 10:07:46 -05:00
jean-pierre charras c758e72c1d Remove a useless file and move the 2 methods to suitable files. 2018-01-31 14:54:31 +01:00
jean-pierre charras be746a8e3d rename a few files related to the footprint viewer. 2018-01-31 13:37:36 +01:00
Maciej Suminski 0668cd9d4c Symbol Library Editor: save sym-lib-table only if it had been modified 2018-01-31 10:46:39 +01:00
Maciej Suminski 0e9dedf3cd Fixed a memleak in About dialog. Updated the copyright year. 2018-01-31 10:05:00 +01:00
jean-pierre charras 39b4afecfa fix code after file renaming 2018-01-31 09:24:02 +01:00
jean-pierre charras 32aedc99b7 rename files 2018-01-31 09:24:00 +01:00
jean-pierre charras 6d6ef0097b Fix code after renaming files. Minor other fix. 2018-01-30 20:23:35 +01:00
jean-pierre charras d8b9f1081b rename file 2018-01-30 20:23:35 +01:00
jean-pierre charras d4192b4646 rename files 2018-01-30 20:23:34 +01:00
Wayne Stambaugh 3b2452ca8e Update .gitignore to reflect recent file renaming changes. 2018-01-30 14:14:16 -05:00
Jeff Young 99ad5cf394 More performance optimizations for symbol libraries
1) don't call UI-level LIB_PIN routines when reading library --
not only are they a performance hit, they set the modified flag
too
2) limit progress dialog updating to 15 times a second (this
had crept back up to 31% of the time spent loading libraries)

Fixes: lp:1734773
* https://bugs.launchpad.net/kicad/+bug/1734773
2018-01-30 10:31:51 -05:00
jean-pierre charras b43dc7954c fix code after renaming files 2018-01-30 15:34:09 +01:00
jean-pierre charras ab0a82db19 rename files 2018-01-30 13:55:02 +01:00
jean-pierre charras eb9070fa74 forgotten fix after renaming files 2018-01-30 13:31:50 +01:00
jean-pierre charras 8022f1cc01 fix code after renamin files 2018-01-30 11:49:51 +01:00
jean-pierre charras 833d6223a0 rename files 2018-01-30 11:08:03 +01:00
jean-pierre charras 2bc9cac234 rename files 2018-01-30 10:51:55 +01:00
jean-pierre charras 1f88b466de move SCH_EDIT_FRAME methods from netlist.cpp to netform.cpp 2018-01-30 10:45:35 +01:00
jean-pierre charras 795a36c9fe Fix code after renaming files, and a bit of code cleanup (remove useless includes and multiple includes of the same files) 2018-01-30 09:57:25 +01:00
jean-pierre charras 87a437c26e rename files in eeschema 2018-01-30 09:57:22 +01:00
jean-pierre charras 342197bb3e fix forgotten code change after renaming 2018-01-30 08:13:33 +01:00
jean-pierre charras 8552f3fedf fix code after renaming files 2018-01-29 22:00:44 +01:00
jean-pierre charras edf9821014 rename files 2018-01-29 21:59:27 +01:00
jean-pierre charras 39fc0656d1 move specctra. files in a specific folder specctra_import_export 2018-01-29 18:09:18 +01:00
jean-pierre charras 30e3f2e781 fix forgotten change after renaming files 2018-01-29 17:34:12 +01:00
jean-pierre charras 5d72aebd22 Fix code after renaming files 2018-01-29 16:40:22 +01:00
jean-pierre charras bc76ec4d67 Rename files according to the name of classes they are defining 2018-01-29 16:40:20 +01:00
jean-pierre charras a0ac1a48c2 Gerbview: fix code after renaming files 2018-01-29 13:26:58 +01:00
jean-pierre charras 6255239b52 Gerbview: rename files class_xxx to xxx according to the class names of classes defined inside the files 2018-01-29 11:51:47 +01:00
jean-pierre charras d0754acf00 Fix code after renaming files 2018-01-29 11:37:29 +01:00
jean-pierre charras 398f6d7b32 rename a few files 2018-01-29 09:50:58 +01:00
jean-pierre charras d44494beda Update code after file renaming 2018-01-29 09:39:49 +01:00
jean-pierre charras fa10e1b7fe rename a few files 2018-01-29 09:39:47 +01:00
Jon Evans 14abe8723d Rework GERBVIEW_FRAME::ReCreateAuxiliaryToolbar to fix layout issues
Fixes: lp:1745203
* https://bugs.launchpad.net/kicad/+bug/1745203
2018-01-29 07:52:42 +01:00
jean-pierre charras 1bc3dfef10 fix compil issue in kicad.i and a minor compil warning 2018-01-28 22:24:51 +01:00
jean-pierre charras 4c5bd01887 Rename a few files 2018-01-28 22:02:31 +01:00
jean-pierre charras ac0dd118fd fix compil issue in swig interface. 2018-01-28 20:03:46 +01:00
jean-pierre charras e499d337d8 rename files: update filenames in sources 2018-01-28 19:12:26 +01:00
jean-pierre charras 5868202c28 rename files, mainly files for plotter control 2018-01-28 18:13:27 +01:00
jean-pierre charras 93fd0c9358 move plotter related files to subdir plotters 2018-01-28 17:49:55 +01:00
jean-pierre charras 19e3815c85 Cvpcb: rename files: fix names in files and remove a old file not used. 2018-01-28 17:30:36 +01:00
jean-pierre charras 56d970b90f Rename some cvpcb files 2018-01-28 17:30:36 +01:00
Jeff Young 899afa1e90 Reinstate OSX cursor shape selection
Mark it as not supported in Legacy graphics.

Fixes: lp:1745097
* https://bugs.launchpad.net/kicad/+bug/1745097
2018-01-28 10:47:20 -05:00
Jeff Young 3ad3869ae8 Make sure OSX modal event loops end.
WindowModal works fine, but nested AppModals never get the inner
eventloop cancelled.

Fixes: lp:1718079
* https://bugs.launchpad.net/kicad/+bug/1718079
2018-01-28 15:16:07 +01:00
jean-pierre charras ce02798533 Fix a minor compil warning. 2018-01-28 14:13:16 +01:00
jean-pierre charras 5d08f1a0d9 Breaks the large create_layer_items.cpp file into 2 smaller specialized files, to make changes in 3D shapes calculations more easy. 2018-01-28 14:05:17 +01:00
Wayne Stambaugh f4273b9e41 Fix coding policy fixes from previous commit along with a few others. 2018-01-27 20:34:14 -05:00
Martin Sivak d5cdd78062 eeschema: keystroke zoom should obey disabled centering
Keystroke zoom (F1/F2) always centered the screen, because it
was handled as ID_POPUP_ZOOM_IN event. Mousewheel scrolling
was ok, because it is handled using different event based
on the configuration.

This patch introduces special event ids for keystroke
zooming that are then properly translated to either
ID_POPUP_ZOOM_IN or ID_OFFCENTER_ZOOM_IN depending
on the configuration.

The same issue is fixed for legacy canvas pcbnew.

Fixes: lp:1742567
* https://bugs.launchpad.net/kicad/+bug/1742567

Signed-off-by: Martin Sivak <mars@montik.net>
2018-01-27 20:20:32 -05:00
Jeff Young 7a28f3d4cf Implement undo/redo for origins in legacy
PICKED_ITEMS_LIST knows the architecture of the undo commands so
that it can delete those ITEMs which it owns.  This represents poor
encapsulation so instead of adding yet another case, I added a
UR_TRANSIENT item flag which is set by callers whenever they create
new objects to “give to” the undo/redo stack.  This allowed some
cleanup of other code, but cleaning up UR_DELETE and UR_WIRE_IMAGE
will be a bigger task and have to wait for another day.

Fixes: lp:1542018
* https://bugs.launchpad.net/kicad/+bug/1542018
2018-01-27 19:51:44 -05:00
Jeff Young 4784ee7fe4 Implement undo/redo for drill and grid origins.
The undo/redo operations are essentially the same as for
UR_CHANGED: we store both the origin marker item and a copy
of it and flip back and forth between the two.  This also
required the implementation of clone() for the markers.

The ORIGIN_VIEWMARKER is moved from being a subclass of
EDA_ITEM to BOARD_ITEM to facilitate the use of a UR_CHANGE-
like implementation without having to know the internals
of the ORIGIN_VIEWMARKER.

In the command processors, the setting of the origins is
broken into two parts: one for UI-level access which includes
setting up undo, and one for low-level access which does not.
The undo/redo code itself of course uses the lower level.

Fixes: lp:1542018
* https://bugs.launchpad.net/kicad/+bug/1542018
2018-01-27 19:40:51 -05:00
Jeff Young f88c4ccb02 Add an Edit button to the Symbol Properties aliases list
Fixes: lp:1248451
* https://bugs.launchpad.net/kicad/+bug/1248451
2018-01-27 18:57:33 -05:00
jean-pierre charras 17739859b3 DXF plot: fix incorrect plotting of oval holes
Due to missing DXF_PLOTTER::ThickSegment code to plot a thick segment in SKETCH mode (outline mode)
2018-01-27 17:33:39 +01:00
Jeff Young 45386ccbf3 Honor SMALL_DRILL_SHAPE option when plotting DXF.
Fixes: lp:1566744
* https://bugs.launchpad.net/kicad/+bug/1566744
2018-01-27 17:33:37 +01:00
Wayne Stambaugh aa18aa13b9 Remove worksheet templates.
There is no reason two have these in two places.  They are now
maintained in the KiCad template repository at:

https://github.com/KiCad/kicad-templates
2018-01-27 10:19:29 -05:00
Jeff Young 829c236437 Symbol library load performance enhancements.
1) Edit Symbol gets similar fix as Place Symbol
2) progress dialog updating reduced to once every 50ms
3) SearchText gets lazy normalization
4) TypeNames get lazy translation
5) default fieldNames get translated a single time per language change

These fixes reduce first-load-time of both Edit Symbol and Place Symbol
by about 2/3, and second-load-time of Edit Symbol to near-instantaneous.
2018-01-27 08:29:43 -05:00
jean-pierre charras 54ebd45749 DIALOG_EDIT_COMPONENT_IN_SCHEMATIC: ensure mandatory field names are always correctly translated after changing the locale. 2018-01-26 20:21:12 +01:00
jean-pierre charras 06dddb50e6 Avoid fixed min or max size of widgets in dialog 2018-01-26 20:17:55 +01:00
Jon Evans b547c5cdf0 Reapplied: Save view control settings before dispatching new tool events
Unintentionally removed in b8ecc95d.
2018-01-26 19:23:08 +01:00
Tomasz Włostowski 7a6e3bf3ed eeschema: remember last browsed directory in the Symbol Lib Table dialog 2018-01-26 18:39:09 +01:00
Maciej Suminski 5f2e9a1e57 Disable right click context menu for measurement tool 2018-01-26 15:55:43 +01:00
Maciej Suminski b8ecc95d9c Forward context menu events to the tool that created the menu
It fixes the case when a tool sets up a menu and starts its event loop
waiting exclusively for menu events. If none arrived, the tool was stuck
in the loop forever.

Fixes: lp:1744915
* https://bugs.launchpad.net/kicad/+bug/1744915
2018-01-26 15:53:52 +01:00
Maciej Suminski 3aafa2b574 Clear selection box when another tool is invoked while selecting items 2018-01-26 15:10:48 +01:00
jean-pierre charras d54418c14a Fix minor compil warnings 2018-01-26 09:35:22 +01:00
ludovic léau-mercier 0d532b43de Support .title directive in spice netlist exporter
Spice netlist exporter processes all texts on the exported schematic
sheet to find spice directives and include them in the output file.
By default it also added ".title KiCad schematic" in the first line, so
if there was another .title directive in the exported schematic sheet,
the generated file would contain two .title directives.

This patch looks for .title directive and when one is found - it uses
the specified title in the first line.
2018-01-26 08:57:35 +01:00
Maciej Suminski 8e18aea11d New ERC rule verifying if all units of a component use the same footprint 2018-01-25 12:19:41 +01:00
Jeff Young 89a5a84af9 Remove refereces to OpenGL and Cairo from Display Settings
Fixes: lp:1745131
* https://bugs.launchpad.net/kicad/+bug/1745131
2018-01-25 12:11:17 +01:00
Maciej Suminski 42857d60cf Split cvpcb first run message to multiple lines
Fixes: lp:1745228
* https://bugs.launchpad.net/kicad/+bug/1745228
2018-01-25 12:10:41 +01:00
Maciej Suminski 0ef785981b Add pin numbering exception to sync pin edit mode description 2018-01-25 12:08:29 +01:00
Maciej Suminski 4872f77113 New pin2pin icon (synchronized pin edit mode) 2018-01-25 11:45:35 +01:00
Maciej Suminski 6c32b6f955 Pin edit coupling: renamed and changed the description
This commit aims at making the pin edit coupling easier to understand.
It renames the mode to 'synchronized pin edit', shortens the description
and inverts the logic to avoid double negation.

To make the code clearer, two items have their name changed to fit the
new description:
- m_editPinsSeparately       -> m_syncPinEdit
- ID_LIBEDIT_EDIT_PIN_BY_PIN -> ID_LIBEDIT_SYNC_PIN_EDIT
2018-01-25 11:45:34 +01:00
Seth Hillbrand 7a2d9dff62 Sets additional conditions for when a wire is trimmed
This adds a set of conditions that will prevent a wire from being
automatically trimmed.  Wires that are currently being moved or are
newly created or are explicitly avoided will not be removed.  This also
adds a function to set a flag on items in a block.

Fixes: lp:1744632
* https://bugs.launchpad.net/kicad/+bug/1744632
2018-01-24 19:47:14 -05:00
Wayne Stambaugh 2b460bc1ff Eeschema: improve alias load performance.
Don't use wxFileName == operator when comparing cache file name.  There
is a lot of overhead the wxFileName == operator that is not necessary
so just do a comparison with the original string used to create the
cache.
2018-01-24 19:37:07 -05:00
Jeff Young eb7ecf1dfd Load each symbol library atomically for better performance. 2018-01-24 19:21:56 -05:00
jean-pierre charras 888a9e7371 VRML export: add support of S_POLYGON in DRAWSEGMENT export. 2018-01-24 16:06:31 +01:00
Jeff Young 4c29ab6c09 Simplify Exchange Footprints dialog and add Update mode.
This commit also adds a no-selection-mode, which allows the user
to specify what gets update (through the various match modes).
The no-selection-mode is accessed via the Edit menu, although
it could also be applied to the context menu.

Fixes: lp:1466857
* https://bugs.launchpad.net/kicad/+bug/1466857
2018-01-24 09:55:39 -05:00
Maciej Suminski a99d0c44e1 Code comments 2018-01-24 15:18:19 +01:00
jean-pierre charras 875a2b0e10 Fix incorrect vrml export of footprint edge type S_POLYGON. 2018-01-24 14:59:17 +01:00
jean-pierre charras 270a63daac DRAWSEGMENT, S_POLYGON shape: remove useless copies or conversion to std::vector<wxPoint> of SHPE_POLY_SET polygon shape.
Rename GetPolyPoint() to BuildPolyPointsList(), because GetPolyPoint() looks like an accessor, but it is not an accessor.
(Using it as accessor can creates a *very long calculation time* for very basic access to polygon vertices)

Fixes: lp:1745050
https://bugs.launchpad.net/kicad/+bug/1745050
2018-01-24 14:22:43 +01:00
Wayne Stambaugh c95c77c51a KiCad: fix assertion when adding new path configuration entry.
The fix for this is a crude hack.  The assertion is caused by the fact
that KICAD_MANAGER_FRAME is not a KIWAY_PLAYER.  The only way to fix
this correctly is to derive KICAD_MANAGER_FRAME from KIWAY_PLAYER so
the window ordering can be corrected and the dialog can be called using
ShowQuasiModal().

Fixes lp:1744228

https://bugs.launchpad.net/kicad/+bug/1744228
2018-01-23 14:48:56 -05:00
Jeff Young c6d0075076 Keep value, footprint and datasheet in sync in multi-unit parts
Fixes: lp:1731743
* https://bugs.launchpad.net/kicad/+bug/1731743
2018-01-23 11:46:27 -05:00
jean-pierre charras 6436b70176 Fix aDRC issue: sometimes DRC did not detect a track collision with long oval pads. 2018-01-23 17:39:13 +01:00
Jeff Young 76885169c4 Fix delete issues in symbol aliases list in libedit.
The alias list now displays the user model (multiple aliases *of*
a root part, rather than a collection of names *including* the
root part).  This simplified the error detection logic, fixing
the first bug in the bug report.

Updating the part in the library is now done uniformly on OK
(which was the second bug in the bug report).

Fixes: lp:1744656
* https://bugs.launchpad.net/kicad/+bug/1744656
2018-01-23 14:49:20 +01:00
Oliver 7613d04b32 Updated import and export icons
- Pixel alignment of arrows
- Moved import arrow to top-right corner
2018-01-23 08:22:42 -05:00
Oliver 80ad4c956f Pixel align PCB icons 2018-01-23 08:18:46 -05:00
Maciej Suminski cbf433fe04 Symbol Library Editor: save anchor position when modified
OnModify() stores the edited symbol in its edit buffer, therefore it has
to be called after a modification.

Fixes: lp:1744540
* https://bugs.launchpad.net/kicad/+bug/1744540
2018-01-23 14:04:31 +01:00
Maciej Suminski 2d3ef0fa6e Symbol Editor: Remove a redundant separator from symbol context menu 2018-01-23 12:19:19 +01:00
Tomasz Włostowski 3456b6e3c3 pcbnew: fixed incorrect ratsnest computation when all nodes in a net are on a single line 2018-01-23 11:55:11 +01:00
Maciej Suminski 121e670508 TEXT_CTRL_EVAL: Close the parent dialog after pressing Enter
Fixes: lp:1744721
* https://bugs.launchpad.net/kicad/+bug/1744721
2018-01-23 11:49:39 +01:00
Maciej Suminski 975c08c464 get_libngspice_so.sh: use any bison version built with brew (OSX) 2018-01-23 08:47:24 +01:00
jean-pierre charras c702646c25 pcbnew: layers visibility affects printing
Fixes: lp:1744730
https://bugs.launchpad.net/kicad/+bug/1744730
2018-01-22 21:23:47 +01:00
jean-pierre charras 61193dcd13 Fix assertion failure quitting gerbview
Fixes: lp:1744600
https://bugs.launchpad.net/kicad/+bug/1744600
2018-01-22 21:16:10 +01:00
Maciej Suminski 6b9a286a85 Fix crash when a renamed part is saved
The crash happened when during rename operation, when the original part
buffer has been marked as deleted, but its memory was not yet freed. The
renamed part was still using the original SCH_SCREEN object, which was
freed together with the original part buffer.
2018-01-22 17:46:30 +01:00
jean-pierre charras 6322c90c50 Symbol editor: Fix incorrect pin edition coupling for non interchangeable multi-units symbols.
Fixes: lp:1744680
https://bugs.launchpad.net/kicad/+bug/1744680
2018-01-22 13:33:24 +01:00
Jeff Young 2201482e47 Add '*' to modified files in libedit cmptree, and change highlighting.
The highlight colour on some platforms (OSX, for instance)
renders nearly invisible against a white background.  However,
wxWidgets doesn't handle background colours on OSX and GTK+.
A separate commit to the new kicad/wxWidgets fork fixes OSX,
and we continue to use the old highlighting on GTK+

Fixes: lp:1741719
* https://bugs.launchpad.net/kicad/+bug/1741719
2018-01-22 10:37:06 +01:00
Maciej Suminski 9b7d499c51 Fix a memleak in Footprint Library Table Wizard 2018-01-22 10:05:58 +01:00
Jeff Young 8c4874866a Set a selection reference point in get-and-move-module.
This will cause InteractiveEdit to move the reference point to
the cursor before waiting for mouse move events.

Fixes: lp:1571217
* https://bugs.launchpad.net/kicad/+bug/1571217
2018-01-22 09:58:57 +01:00
Maciej Suminski da305e7750 Move SwitchCanvas() implementation to EDA_DRAW_FRAME
Share more code between pcbnew and gerbview. Fix warnings regarding
shadowing EDA_DRAW_FRAME::SwitchCanvas().
2018-01-22 09:06:55 +01:00
Maciej Suminski b3cb6be48e Minor memleak fixed in gerbview 2018-01-22 09:04:24 +01:00
Jon Evans 5ea277d229 Reset tools when clearing gerber draw layers
Fixes: lp:1744600
* https://bugs.launchpad.net/kicad/+bug/1744600
2018-01-22 08:44:55 +01:00
jean-pierre charras 81642dddd1 Track polygon clearance: use the new TransformOvalClearanceToPolygon function, to avoid underestimation of clearance areas.
(issue already found for oval pads)
Add some comments.
2018-01-21 11:32:37 +01:00
jean-pierre charras 2fd00b1d23 Revert "Ensure DrawRectangle() stroke outline will always be visible"
This reverts commit 74d47d8173 because
it breaks DrawRectangle in outline mode because it modify line width.
2018-01-21 10:14:02 +01:00
Jeff Young 6b9866de8b Sort pins in pin-table.
Fixes: lp:1744509
* https://bugs.launchpad.net/kicad/+bug/1744509
2018-01-21 08:47:26 +01:00
jean-pierre charras 6dd398bd6f Better calculation of polygon clearance area of oval pads.
Fixes: lp:1665582
https://bugs.launchpad.net/kicad/+bug/1665582
2018-01-20 20:44:04 +01:00
jean-pierre charras 1db14d44b7 Better calculation of polygon clearance area of oval pads. Wip. 2018-01-20 19:34:50 +01:00
Jeff Young cba430deab Fix undo/redo and revert for libedit name changes and aliases
Three interrelated issues:
1) Implement an undo/redo type for renames so that we know to delete
the old lib entry and add a new lib entry
2) When doing so (for the undo/redo OR the original edit), we must
make a copy of the 'original' LIB_PART which is used for revert, and
hand it to the new lib entry
3) When comparing a modified component tree item with the current item
we must also check for aliases.

Fixes: lp:1743857
* https://bugs.launchpad.net/kicad/+bug/1743857

Fixes: lp:1744371
* https://bugs.launchpad.net/kicad/+bug/1744371

Fixes: lp:1744373
* https://bugs.launchpad.net/kicad/+bug/1744373
2018-01-20 11:20:22 +01:00
jean-pierre charras 448dbf476c Dialog symbol lib table editor: fix incorrect tool tips
Fixes: lp:1744416
https://bugs.launchpad.net/kicad/+bug/1744416
2018-01-20 10:47:19 +01:00
jean-pierre charras b4ea875c5e Add comments. 2018-01-20 10:07:12 +01:00
jean-pierre charras d4dbdcd638 Symbol editor, Pin table editor: always display a icon in Pin Type column
At least on Linux, if a null icon is used as icon in Pin Type column, other icons are not
displayed. So the workaround is to use a neutral icon when a specific icon cannot be used
(i.e. when pins are grouped)

Fixes: lp:1559542
https://bugs.launchpad.net/kicad/+bug/1559542
2018-01-20 09:59:15 +01:00
jean-pierre charras 673f03e595 Convert circle to polygon: minimize rounding errors.
Fixes: lp:1735206
https://bugs.launchpad.net/kicad/+bug/1735206
2018-01-19 21:10:40 +01:00
jean-pierre charras ab2333bcf0 Footprint Editor, GAL mode: make option tool "show footprint in outline mode" working.
Fix also option tool "show footprint texts in outline mode" code,
but because there is no code to show texts in outline mode in GAL canvas, this option still works only in legacy canvas
2018-01-19 19:26:48 +01:00
Jeff Young 90cc896af2 Fix compile error in quasi-modal wxWidgets patch. 2018-01-19 17:26:21 +01:00
Maciej Suminski 388d07a808 Fix disappearance of placed objects after 'Properties' action 2018-01-19 14:20:42 +01:00
Maciej Suminski 903e33375f Fix rotation & flip of newly placed texts
When a rotation/flip command was issued when a newly placed text
was hovering over an existing item - the item underneath would be
affected by the command and the new text would be discarded.

Fixes: lp:1744152
* https://bugs.launchpad.net/kicad/+bug/1744152
2018-01-19 14:20:42 +01:00
jean-pierre charras afeaf909fa Better error message 2018-01-19 11:51:01 +01:00
Michael Geselbracht d8f0527677 Fix crash while reading netlist and delete extra footprints enabled
Fixes: lp:1710492
* https://bugs.launchpad.net/kicad/+bug/1710492
2018-01-19 11:25:32 +01:00
jean-pierre charras 41eeb05d81 Fix compil warnings 2018-01-19 11:01:42 +01:00
jean-pierre charras 2e83103c3d WIDGET_NET_SELECTOR: speedup the net list creation.
Add comments and better names for variables.
2018-01-19 11:01:42 +01:00
jean-pierre charras 1b8ab1c23d Demos update 2018-01-19 11:01:41 +01:00
Jon Evans 10b635ffe2 Clear autoplaced flag when modifiying field orientation/justification
Fixes: lp:1743893
* https://bugs.launchpad.net/kicad/+bug/1743893
2018-01-19 10:09:00 +01:00
Maciej Suminski 7d821cb08c Fix netname layers visibility when copper layers are initially off
Fixes: lp:1744183
* https://bugs.launchpad.net/kicad/+bug/1744183
2018-01-19 10:03:42 +01:00
Jeff Young 959767c09f Don't warp mouse when context menu was cancelled.
Fixes: lp:1674199
* https://bugs.launchpad.net/kicad/+bug/1674199
2018-01-18 13:43:24 -05:00
Maciej Suminski 8721f7ed70 Changed remaining occurences of 'part' to 'symbol' in the symbol editor 2018-01-18 11:24:02 +01:00
Maciej Suminski d87a7ae58e Fallback to Cairo when OpenGL is not supported
Fixes: lp:1741787
* https://bugs.launchpad.net/kicad/+bug/1741787
2018-01-18 10:17:06 +01:00
Jon Evans b21f301097 Defer canvas type setting save until destruction of EDA_DRAW_FRAME
Fixes: lp:1741787
* https://bugs.launchpad.net/kicad/+bug/1741787
2018-01-18 10:17:06 +01:00
jean-pierre charras 47d392d83e Fix incorrect name (typo) of a method. 2018-01-18 10:11:45 +01:00
Maciej Suminski ef13b97ff7 Complementary patch to 3114fa4a (filter invisible vias when selecting)
This patch handles items selected with selection box.

Fixes: lp:1743894
* https://bugs.launchpad.net/kicad/+bug/1743894
2018-01-18 09:56:43 +01:00
Jon Evans 2b2612120c Filter via selection based on render settings
Fixes: lp:1743894
* https://bugs.launchpad.net/kicad/+bug/1743894
2018-01-18 09:56:43 +01:00
jean-pierre charras 08b15a6990 Pcbnew: graphic segments type S_POLYGON: allows 0 for outline thickness (this allows to create easily the exact polygonal shape).
Fixes: lp:1743982
https://bugs.launchpad.net/kicad/+bug/1743982
2018-01-18 09:32:28 +01:00
Jeff Young 3f6af59cac Avoid selection disambiguation menu when possible.
Some actions, such as select trivial connection, don't need the
user to choose which trace at a corner to start from -- either
one will do.  Same for moving a simple trace corner.

Likewise, Edit in Footprint Editor shouldn't ask if you mean the
footprint or the pad.  Obviously it's the footprint.

This change adds a CLIENT_SELECTION_FILTER which allows clients
to do tool- or action-specific filtering of the selection before
the disambiguation menu is run.

It also removes some tool- and action-specific code which was
in the selection_tool and shouldn't have been.

Fixes: lp:1708869
* https://bugs.launchpad.net/kicad/+bug/1708869
2018-01-18 09:09:25 +01:00
Jeff Young 17e6720bc9 Implement undo for eeschema's "Import existing drawings"
Fixes: lp:1522189
* https://bugs.launchpad.net/kicad/+bug/1522189
2018-01-17 15:30:36 -05:00
Seth Hillbrand 2fa5c723d8 Don't cleanup schematic when symbols are rescued.
Schematic cleanup only makes sense after the libraries are fully updated
and loaded.  Before pin caching, this was a minor difference but once we
needed to update pin caches, schematic cleanup can remove junctions from
pin-wire connections incorrectly.

Instead, we use the global OpenProjectFiles() schematic cleanup call to
be sufficient and not call a second time, prior to all libraries being
rescued and loaded.

Fixes: lp:1743148
* https://bugs.launchpad.net/kicad/+bug/1743148
2018-01-17 12:53:38 -05:00
Jeff Young e1c01e1e7f Render transparent layer colors over the correct background.
This fixes the layer comboboxes, the copper zones properties
dialog, and the differental-pair icon in the htoolbar.

Fixes: lp:1741049
* https://bugs.launchpad.net/kicad/+bug/1741049
2018-01-17 11:36:37 -05:00
jean-pierre charras 6014307d06 Pcbnew, DRC dialog: Fix a few issues:
Gal mode: graphic cross-air cursor moved on items when clicking on & DRC error, like in legacy mode.
Make popup menu shown when right clicking on a DRC error item working.
2018-01-17 15:36:04 +01:00
Maciej Suminski 60963fe2fc Fixes for 590cac9d
The original patch did properly recognize the case when all transient
source definition fields are empty, which is perfectly valid.
2018-01-17 10:37:57 +01:00
Dan Weatherill 590cac9d55 Fix transient SPICE source field check logic
Fixes: lp:1743486
https://bugs.launchpad.net/kicad/+bug/1743486
2018-01-17 10:36:35 +01:00
Maciej Suminski c1649b1138 Code formatting fixes for 3d177e9c 2018-01-17 10:35:40 +01:00
Jeff Young 3d177e9c2a Thaw pcb window to scroll markers into view.
Fixes: lp:1606849
* https://bugs.launchpad.net/kicad/+bug/1606849
2018-01-17 10:11:02 +01:00
Maciej Suminski ac1771a9f0 Handle block selection removal of libraries in SYMBOL_LIB_TABLE dialog
Fixes: lp:1741543
* https://bugs.launchpad.net/kicad/+bug/1741543
2018-01-17 09:59:48 +01:00
Jeff Young a386da9ee9 Make sure wxWidgets updates DRC notebook when switching pages.
Fixes: lp:1583466
* https://bugs.launchpad.net/kicad/+bug/1583466
2018-01-17 08:38:47 +01:00
jean-pierre charras 2e79b93b99 Eeschema: fix issue (2 tools not working in left vertical toolbar) created by commit 7e6a6540c8 2018-01-16 19:39:31 +01:00
Maciej Suminski d85cf732b6 TEXT_CTRL_EVAL: Evaluate expressions when Enter key is pressed
Fixes: lp:1741320
* https://bugs.launchpad.net/kicad/+bug/1741320
2018-01-16 14:53:13 +01:00
Jeff Young 947a4839fd Use generic Save (and New and Open) commands where unambiguous.
Fixes: lp:1743426
* https://bugs.launchpad.net/kicad/+bug/1743426
2018-01-16 08:39:12 -05:00
Seth Hillbrand e53fa2dda6 Partially revert 316ddad that added warnings but no functionality
Fixes: lp:1742978
* https://bugs.launchpad.net/kicad/+bug/1742978
2018-01-16 14:25:45 +01:00
jean-pierre charras 6b9740e681 Fix issues when in Pcbnew the Update PCB from schematic command is run.
Now, if not yet opened, the schematic editor frame is created, and shown iconized.
(although iconize it is perhaps not the best option)

It fixes a few (minor) issues (when the schematic editor frame is created, but not shown):
- On OSX the schematic frame is shown as a "ghost" frame.
- If later, the schematic editor is opened from Kicad, a message saying the schematic is already opened is shown.
This is technically true, but unexpected by user.
- If symbols need an annotation, the annotation dialog is opened, can can modify the schematics.
  So it could be better to really open the schematic editor frame.
2018-01-16 13:53:03 +01:00
Jeff Young d4ddc009e1 Don't include module drawings in coverage ratio calculation.
If we do, we'll almost always conclude that coverage is near 100%
due to the outline drawing.

Fixes: lp:1743164
* https://bugs.launchpad.net/kicad/+bug/1743164
2018-01-16 13:45:32 +01:00
jean-pierre charras 433b2bff40 Add comments in progress_reporter.h; Remove unused parameter in Fill_All_Zones and remove empty file. 2018-01-16 10:22:25 +01:00
Maciej Suminski 495c4125f9 Set line width for SELECTION_AREA
Fixes: lp:1743242
* https://bugs.launchpad.net/kicad/+bug/1743242
2018-01-16 09:27:56 +01:00
Jon Evans 74d47d8173 Ensure DrawRectangle() stroke outline will always be visible
Fixes: lp:1743242
* https://bugs.launchpad.net/kicad/+bug/1743242
2018-01-16 09:20:02 +01:00
jean-pierre charras 94c8a947ad Progress reporter: remove wxPD_APP_MODAL style, not useful, that creates issues on OSX.
All platforms now use the same code.
2018-01-15 17:57:03 +01:00
Maciej Suminski 5141a4ecf0 Remove dangerous 'rm *' from a bash script
Fixes: lp:1545337
* https://bugs.launchpad.net/kicad/+bug/1545337
2018-01-15 11:37:13 +01:00
jean-pierre charras b327da6e5a Fix incorrect parsing in kicad2step when a footprint has both locked and placed options activated.
Fixes: lp:1742700
https://bugs.launchpad.net/kicad/+bug/1742700
2018-01-15 11:24:09 +01:00
Jon Evans 11fa7cdaf3 Save view control settings before dispatching new tool events
Fixes: lp:1741357
* https://bugs.launchpad.net/kicad/+bug/1741357
2018-01-15 10:46:09 +01:00
Jon Evans 6eb5733a0b LSET::UIOrder and LSET::Technicals now match layer widget order
Fixes: lp:1673792
* https://bugs.launchpad.net/kicad/+bug/1673792
2018-01-15 10:08:30 +01:00
jean-pierre charras 63e55e9180 Try to fix a regression on OSX
Fixes: lp:1740909
https://bugs.launchpad.net/kicad/+bug/1740909
2018-01-14 17:38:48 +01:00
jean-pierre charras e0f819d02e Fix minor compil warning (not used var) 2018-01-14 15:57:46 +01:00
jean-pierre charras 0ee38bcb6b fix incorrect filename 2018-01-14 15:04:24 +01:00
jean-pierre charras 5a74fe373b Fix incorrect parent in dialog edit_module_text, when this dialog is called from an other dialog.
Fix also a coding style issue.
2018-01-14 14:28:48 +01:00
jean-pierre charras 82174b5b2d Speed up zone fill calculations after a zone parameters edition. 2018-01-14 11:27:11 +01:00
jean-pierre charras 67a152ee8d zone filler: fix incorrect calculation of segments when filling zones with segments.
The calculation was made too early, before removing insulated islands.
Note: filling zones with segments is an old option, not very useful:
using only polygons has never created issues in gerber files.
2018-01-14 09:51:32 +01:00
Baranovskiy Konstantin 2f6e0117f1 Fix the option inversing in CvPcb->FootprintPreview->DisplayOptions
Option 'Center and warp cursor on zoom' has inverted (opposed) value
in the display options dialog of Footprint preview of CvPcb. If this
option is set the cursor does not moves to center on zooming but if
option is unset it does.
2018-01-14 08:57:22 +01:00
Seth Hillbrand cc836903bd Disable live resizing for wxAUI as it glitchy
Fixes: lp:1695897
* https://bugs.launchpad.net/kicad/+bug/1695897
2018-01-13 17:28:28 -05:00
jean-pierre charras 39dfc2c762 pad editor: add option to show pad in outline mode. better code and fix minor issues. 2018-01-13 17:09:01 +01:00
Wayne Stambaugh 650207a6e1 Pcbnew: fix 3D viewer panel default size issue.
The 3D viewer panel had a default size that was causing sizing issue
with the footprint properties dialog.  Set the default size to -1;-1
and set the proportion setting to 1 when adding the panel to the sizer
which allows the panel to file in the correct size.

Fixed some minor control spacing issues in the footprint properties
dialog properties tab.

Please note that is only a partial fix for this issue.  There is still
too much vertical space which is partially due to the use of wxSpinCtrl
instead of wxDoubleSpinCtrl.

Fixes lp:1742701

https://bugs.launchpad.net/kicad/+bug/1742701
2018-01-12 20:58:44 -05:00
jean-pierre charras b07cf47591 bigger dialog_fp_lib_table size. 2018-01-12 21:30:48 +01:00
jean-pierre charras f95cceeff0 Update demos 2018-01-12 21:30:07 +01:00
jean-pierre charras 52eedc7192 Footprint editor: Fix a crash when trying to create a custom pad from selected graphic primitives. 2018-01-12 21:25:45 +01:00
Oliver 195b85b0c5 Cleanup of KiCad Icons
Major cleanup of many icons (started as a simple effort to tweak libedit and modedit icons)
Ref: https://lists.launchpad.net/kicad-developers/msg32860.html
* Each application icon has been updated
* Consolidated icon "modifiers" across many icons
* Replaced confusing arrows with "load" and "save" icons
* Slight code updates to reference correct icons
* Consolidate multiple representations of single icon type(s)
2018-01-12 14:06:45 -05:00
Seth Hillbrand 273f0d56cd Suppress Boost::Optional unitialized compile warning
Fixes: lp:1743009
* https://bugs.launchpad.net/kicad/+bug/1743009
2018-01-12 19:58:33 +01:00
Seth Hillbrand 98c8a5ac0c Fix non-conforming signbit test
Fixes: lp:1742803
* https://bugs.launchpad.net/kicad/+bug/1742803
2018-01-12 19:58:33 +01:00
jean-pierre charras 79a9f401a3 Fix a minor issue in pad editor dialog: in GAL mode, the pad was sometimes shown in outline mode, sometimes in filled mode
Fixes: lp:1740668
https://bugs.launchpad.net/kicad/+bug/1740668
2018-01-12 19:58:32 +01:00
Jeff Young 786312b103 wxWidgets and KiCad fixes for quasi-modal dialogs.
OSX activates windows before telling the application, so there's
no good way to implement wxWidgets window enable/disable.  This
patch keeps the quasi-modal dialog and its parent windows order
in the z-list fixed, and re-activates the quasi-modal dialog
whenever the OS activates the parent window.
2018-01-12 12:06:00 -05:00
Wayne Stambaugh 41f5c754e5 Eeschema: fix minor component tree model bug.
The component tree model was always saving the root symbol name which
prevented the actual alias from be selected in the symbol chooser
dialog.  This also prevented the correct documentation information
from being shown in the information panel.

Fixes lp:1740742

https://bugs.launchpad.net/kicad/+bug/1740742
2018-01-12 11:59:26 -05:00
Wayne Stambaugh 3c9316957d Eeschema: allow remapping if a project symbol library table exists.
Change the behavior of the remapping algorithm to remap even if a
project symbol library table exists in the project file in case a
previous attempt to remap failed.  The existing symbol library table
is backed up to the back folder and rebuilt.

Fixes lp:1741983

https://bugs.launchpad.net/kicad/+bug/1741983
2018-01-12 10:13:41 -05:00
jean-pierre charras d8e38d6d3f Fix Pcbnew crash when try to fill zone, due to a bug created by commit 8de0598789 2018-01-12 12:55:22 +01:00
jean-pierre charras 6f2beebf2c PANEL_PREV_3D: replace wxStaticBoxSizers by a wxBoxSiser and a static text.
On KDE, wxStaticBoxSizers do not work very well (incorrect sizes).
2018-01-11 18:14:50 +01:00
Kristoffer Ödmark 98d330f395 Test the via types to the design rules
Fixes: lp:1741695
* https://bugs.launchpad.net/kicad/+bug/1741695
2018-01-11 18:13:59 +01:00
jean-pierre charras bb694b97c2 Update demos 2018-01-11 14:21:58 +01:00
jean-pierre charras de9161be85 Larger dialog size. 2018-01-11 14:21:36 +01:00
jean-pierre charras e926ec42f8 Update demo 2018-01-11 11:45:43 +01:00
Jon Evans 5fd1236d7a Use worksheet bounding box when the board is empty
Fixes: lp:1742140
* https://bugs.launchpad.net/kicad/+bug/1742140
2018-01-11 11:28:19 +01:00
jean-pierre charras 47dfabc6c8 Add size control to HTML_MESSAGE_BOX. Fix incorrect default size of a few dialogs.
Clean code: remove useless code and not used parameters.
2018-01-11 10:48:52 +01:00
Chris Pavlina 7e6a6540c8 Implement primitive icon scaling for high DPI
This is meant as a stopgap for 5.0, with plans to add proper scaled
icons in the 6.0 cycle. A function KiScaledBitmap() is added, which
works like KiBitmap() except it scales the bitmap according to the
calling window's font size. Controls have been added to all the main
applications to let the user select scaling manually (these were omitted
from smaller apps that didn't already have a place to put them).

In addition, in eeschema only, the pixel height of the system font is
shown in the options dialog for diagnostics. This is only for collecting
feedback before 5.0 release from users with different displays and will
be removed.
2018-01-10 21:26:06 -07:00
Wayne Stambaugh 998d9179e9 Eeschema: fix library naming bugs in symbol rescuer and re-mapper.
File names with spaces were causing invalid symbol names in both the
rescue library and the cache which would cause both libraries to fail
to load because library symbol names are not escaped so the spaces
tripped up the library parser.  Replace the spaces in the file names
with hyphens and in both the rescuer and the remapping code so the
library nickname in the symbol library table does not contain spaces.

Update the symbol library table dialog to prevent users from defining
library nicknames with spaces.  This is different than the footprint
library table which allows nicknames with spaces.  This solution is
a temporary fix until the new symbol library and schematic file formats
are implemented.

Fix off by one row in illegal nickname error message in the symbol
library table editor.
2018-01-10 16:04:32 -05:00
Kristoffer Ödmark 5051dc8848 Implemented missing via dialog functions 2018-01-10 15:55:16 +01:00
jean-pierre charras 87045ea94c Fix tipo and tooltip 2018-01-10 14:48:14 +01:00
Maciej Suminski efe55b6f0a Symbol Library Editor: fix renaming symbols with multiple aliases
Fixes: lp:1737964
* https://bugs.launchpad.net/kicad/+bug/1737964
2018-01-10 12:15:12 +01:00
Maciej Suminski c09cf252c6 Symbol Library Editor: update node information on library sync 2018-01-10 12:04:34 +01:00
Maciej Suminski 12041551a1 Removed unnecessary debug messages 2018-01-10 12:03:53 +01:00
Maciej Suminski dc62c0717c Fixed shadowed variable warnings in libdxf 2018-01-10 09:04:15 +01:00
Maciej Suminski 7f9202842d Fix an initialization order warning in coroutine.h 2018-01-10 08:52:17 +01:00
Maciej Suminski 8c42abc10c Symbol Library Editor: fix crash after renaming a symbol
Crash was caused by removal of the selected item from the
wxDataViewModel, which was later accessed in
COMPONENT_TREE::GetSelectedLibId(). To avoid the problem, the selection
is validated before regenerating the tree widget.

Fixes: lp:1740952
* https://bugs.launchpad.net/kicad/+bug/1740952
2018-01-10 08:52:17 +01:00
Maciej Suminski 6e65049a56 Do not modify LIB_ID in LIB_PART::SetLib()
This commit is a partial revert of aa81f5b9 & 445ac505. LIB_ID should
not be modified when a library is assigned to its part, as the library
nickname cannot be evaluated during the assignment and might be
different than its filename.
2018-01-10 08:52:17 +01:00
Camille f5f7ba4746 Fix loop variable copy in for-range loop, use const reference instead 2018-01-09 19:18:44 -05:00
Camille 5c4f8abd24 Fix type promotion in math function 2018-01-09 19:11:27 -05:00
Camille 9ff66a5274 Fix unnecessary value parameter detected by clang-tidy. - Replace value parameter by const reference parameter or move-assignement in some cases 2018-01-09 18:55:51 -05:00
Camille 3168d03fe5 Fix unnecessary copy initialization detected by clang-tidy 2018-01-09 18:22:10 -05:00
Wayne Stambaugh 28692c40e1 Eeschema, project rescue bug fix and other minor improvements.
Fix a bug where the full LIB_ID was not being used to look up the name
of the symbol in the cache library preventing the rescue to work when
rescuing symbol library table projects.

Add information as to why a symbol was rescued rather than only showing
what symbols were rescued.

Do not add rescue suffix to symbol name for symbol library table rescues
because if a symbol name exists in multiple libraries that need rescued
at the same time will cause subsequent symbol rescues to be overwritten.
Append the nickname of the schematic symbol library to prevent symbol
name clashes in the rescue library.
2018-01-09 15:41:26 -05:00
Wayne Stambaugh 00fb70088f Eeschema: fix progress dialog title capitalization. 2018-01-09 10:58:01 -05:00
Wayne Stambaugh 69560ec587 Eeschema, fix bug in edit one field dialog.
Verify the library symbol of the field being edited still exists rather
than use an assertion because it is entirely feasible that the library
symbol or library containing this symbol has been deleted and will cause
a segfault.  Unfortunately there is no way to determine if the symbol is
a power symbol or not so just set it as a regular symbol so the user can
still edit the schematic symbol field.

Fixes lp:1742111

https://bugs.launchpad.net/kicad/+bug/1742111
2018-01-09 09:20:54 -05:00
Maciej Suminski 82fc038c9b Fixed wxLogTrace for LIB_ALIAS
When a LIB_PART object is removed, it deletes all of its aliases.
When the last one is removed, it tries to report the name of the
parent part, but as it has no aliases - it cannot return a valid name.
2018-01-09 09:55:05 +01:00
Maciej Suminski ee140ce6c8 Symbol Library Editor: do not leave the old part after renaming 2018-01-09 09:55:01 +01:00
jean-pierre charras 019eed0d28 Symbol editor: rework on multi-unit symbols: pin edition synchronization is now only between units (Work in progress)
The synchronization between body styles of the same units is removed.
This is easier to understand by users.
2018-01-09 08:54:48 +01:00
jean-pierre charras 1d2752ee47 Symbol editor: rework on multi-unit symbols are pin edition synchronization between units (work in progress)
User Interface: better tooltips and better messages.
Code: better comments, and better member name.
Fix a few minor issues.
2018-01-09 08:54:47 +01:00
Chris Pavlina 87cc3ea445 Update message in Findngspice.cmake 2018-01-08 23:30:48 -07:00
Wayne Stambaugh 0e9c8a4238 Prevent segfault when remapping project with corrupt cache library.
Use the symbol found in the library when the symbol is not in the cache
library.

Add an assert to prevent dereferncing a null pointer in the future even
thought this should not happen as the rescue algorithm does not add a
candidate when a symbol cannot be found in either the cache or any other
library.

Fixes lp:1741964

https://bugs.launchpad.net/kicad/+bug/1741964
2018-01-08 17:33:32 -05:00
Maciej Suminski 3fb60f7709 Update copyright.h 2018-01-08 16:53:05 +01:00
Maciej Suminski 7fe6249ac3 Alternative fix for lp:1741050
Calling wxListBox::SetSelection( wxNOT_FOUND ) changes the internal
state of the widget without the intended visual effect (show nothing
selected). It leads to a situation when the default choice is overridden
with wxNOT_FOUND, even though the list box shows a valid value.

As there is no point in calling wxListBox::SetSelection( wxNOT_FOUND ),
the confusing call has been removed.
2018-01-08 16:02:34 +01:00
Maciej Suminski 12c6b3337b LIB_MANAGER does not hold a SYMBOL_LIB_TABLE pointer
SYMBOL_LIB_TABLE might be destroyed without a forewarning, so
it is safer to request it every time it is needed.

Fixes: lp:1741820
* https://bugs.launchpad.net/kicad/+bug/1741820
2018-01-08 15:19:25 +01:00
ludovic leau-mercier 31902f967a Fixed an assert when selected the default semiconductor model
Fixes: lp:1741050
* https://bugs.launchpad.net/kicad/+bug/1741050
2018-01-08 12:53:57 +01:00
Maciej Suminski ea9b568743 Formatting fixes for the previous commit 2018-01-08 12:52:17 +01:00
Dan Weatherill efed38ad3e Fix hotkey import persistence
Fixes: lp:1738875

This patch saves hotkeys to default file when a hotkeys file is
imported, so they remain persistent in future sessions.

Also, a few minor tidy ups (e.g. c++11 nullptr) internal to
common/hotkeys_basic.cpp.
2018-01-08 11:43:01 +01:00
Maciej Suminski 4ec24badb9 Enlarge OpenGL glyphs to match Cairo and legacy text size 2018-01-08 10:46:27 +01:00
Kristoffer Ödmark e7ddcca569 Fix some netname rendering issues
Fixes: lp:1739074
* https://bugs.launchpad.net/kicad/+bug/1739074
2018-01-08 10:29:50 +01:00
Maciej Suminski 89cbb079a9 Added get_libngspice_so.sh script 2018-01-08 09:58:24 +01:00
Chris Pavlina 6cee19d37d eeschema: neatly wrap placeholder text in symbol chooser 2018-01-07 19:30:56 -07:00
Jon Evans 04beb20e3e Scale and zoom view to fit when cross-probing a net on the board 2018-01-07 14:44:36 -05:00
Jon Evans ca264f8982 Add bidirectional net highlight cross-probing
Fixes: lp:1738875
* https://bugs.launchpad.net/kicad/+bug/1738875
2018-01-07 14:12:50 -05:00
Jon Evans a4bb6ec3e4 Allow selecting footprints that are only silkscreen using silk layers
In high-contrast mode, items that don't exist on the current layer are
not selectable, but this is problematic since there are library
components that only exist in the silkscreen layer (logos, etc).

By adding one of the silkscreen layers to the ViewGetLayers() output,
these components are now editable when viewing the silkscreen layer in
high-contrast mode.  Silkscreens attached to footprints that have pads
or drawings on non-silkscreen layers are still not selectable.

Fixes: lp:1741350
* https://bugs.launchpad.net/kicad/+bug/1741350
2018-01-07 14:12:50 -05:00
Chris Pavlina 445fc0000f COLOR_SWATCH, INDICATOR_ICON: DPI-independent scaling 2018-01-07 09:28:47 -07:00
jean-pierre charras 504e7a4a51 Very minor fix in a menuitem label 2018-01-07 16:31:15 +01:00
jean-pierre charras 20e66253bb symbol editor: add icons in popup menus of the symbol tree list. 2018-01-07 13:18:18 +01:00
jean-pierre charras 47989ccfc0 fix a minor compil warning 2018-01-07 09:13:00 +01:00
Jon Evans ce8c2752f9 Force a refresh when changing render colors
This fixes Cairo not updating until mouse is moved over the canvas
2018-01-07 08:51:17 +01:00
Chris Pavlina a06e3bef33 Layer Setup: DPI-independent default size
Also, remove a wxPanel border as it makes device-independent sizing
nearly impossible. For some reason wxPanel::GetClientSize() is returning
garbage here and breaks centering text without fudge factors. I think it
still looks good without the border, maybe better.
2018-01-07 00:06:57 -07:00
Chris Pavlina 8bc063abda Pads-Mask Clearance: size dialog properly to avoid cut off text 2018-01-06 23:02:01 -07:00
Chris Pavlina ccd6b5c46e Diff pair dimensions: sizing fixes
- Remove maximum size from unit labels (which led to cut-off text)
- Add a spacer so dialog resizes gracefully
2018-01-06 22:55:10 -07:00
Chris Pavlina f3865214d7 Hotkey editor: DPI-independent default size 2018-01-06 22:33:46 -07:00
Chris Pavlina c5b2ad9595 simulator: DPI-independent default size 2018-01-06 22:23:58 -07:00
Chris Pavlina b1eed74b55 cvpcb: DPI-independent default size 2018-01-06 22:15:48 -07:00
Chris Pavlina 34b19e4ec3 HTML_MESSAGE_BOX: DPI-independent default size 2018-01-06 21:27:08 -07:00
Chris Pavlina 7b1c9c145f DIALOG_BOM_EDITOR: DPI-independent size 2018-01-06 20:37:49 -07:00
Chris Pavlina e971b0e698 Don't call FinishDialogSettings in DIALOG_EDIT_COMPONENTS_LIBID
Dialogs displaying a lot of scrollable data should use SetSizeInDU()
instead, as FinishDialogSettings() will set a minimum size equal to
whatever can contain all the data (making it overflow the screen for
large amounts).
2018-01-06 20:08:57 -07:00
Chris Pavlina 917804ef12 Make eeschema color select widget DPI-independent 2018-01-06 17:29:07 -07:00
Chris Pavlina 119a0f665b DIALOG_SYMBOL_REMAP: raise after remap is complete
On macOS in particular, there is a tendency for this to fall behind
other windows where the user has no clue it's still up.
2018-01-06 14:51:53 -07:00
Chris Pavlina 4d3b16bbd9 Simplify DIALOG_SHIM::SetSizeInDU()
I missed in the wx documentation that ConvertDialogToPixels() has a
wxSize overload.
2018-01-06 14:51:07 -07:00
Chris Pavlina 13bc706518 Fix several dialogs with bad default sizing
- Add helper methods for DPI-independent sizes
- Make splitter sashes visible on macOS
- Remove SetSizeInChars() - wx has a built-in way that I missed
- DIALOG_CHOOSE_COMPONENT: DPI-indep splitter sizes
- DIALOG_RESCUE_EACH: DPI-indep default size and sensible HTML window
  size
- COMPONENT_TREE: DPI-indep sizing
- DIALOG_FP_LIB_TABLE, DIALOG_SYMBOL_LIB_TABLE
2018-01-06 14:39:17 -07:00
Jon Evans 53ae5c36f4 Flip horizontal scrollbar behavior in flipped board view mode
Fixes: lp:1741327
* https://bugs.launchpad.net/kicad/+bug/1741327
2018-01-06 14:58:05 -05:00
Jeff Young 38227161bf Fix drawing of transparent layer swatches.
Also fixes a related bug to redraw holes when changing the
pcb background colour.

Fixes: lp:1741049
* https://bugs.launchpad.net/kicad/+bug/1741049

Fixes: lp:1741101
* https://bugs.launchpad.net/kicad/+bug/1741101
2018-01-06 12:12:39 -05:00
Dan Weatherill 0dcf95ee1a automatically add extension to sim workbook files
CHANGED: When a workbook file is saved from the simulation dialog
in eeschema, the extension is automatically added if it is not
specified. This behaviour is consistent with the workbook loading
dialog, which filters the filelist for only ".wbk" files with no
"all files" option.
2018-01-06 12:04:53 -05:00
Jon Evans 9689200984 OpenGL: Fix background color being drawn twice in no-AA mode
Fixes: lp:1741363
* https://bugs.launchpad.net/kicad/+bug/1741363
2018-01-06 17:32:19 +01:00
Jon Evans 47b8b6dc6a Fix typo causing isolated thermal removal to not work
Fixes: lp:1741265
* https://bugs.launchpad.net/kicad/+bug/1741265
2018-01-06 16:55:02 +01:00
Jon Evans c3d0489863 Always bring LAYER_CURSOR to the front
Fixes: lp:1741357
* https://bugs.launchpad.net/kicad/+bug/1741357
2018-01-06 16:54:14 +01:00
Christoph Riehl f6023d22e4 Minor Python pad array improvement.
Allow selection of square pads and allow to rotate the pads in the
circular pad array wizard
2018-01-06 10:39:32 -05:00
jean-pierre charras b98f6a2fd1 Minor fixes in strings and I18N fix. 2018-01-06 10:57:46 +01:00
jean-pierre charras cb60da3bc5 Fix Symbol editor: some hotkeys are not working (Delete item and Drag item)
Fixes: lp:1741145
https://bugs.launchpad.net/kicad/+bug/1741145
2018-01-06 10:36:56 +01:00
Mark Roszko b98cc0b937 Some coverity fixes 2018-01-05 22:51:03 -07:00
Chris Pavlina 57fe3739ca Symbol chooser: base default size on font for DPI flexibility 2018-01-05 22:02:05 -07:00
Chris Pavlina aeefa45608 Fix old layer name "Edges_Pcb" in Print dialog 2018-01-05 15:52:48 -07:00
Chris Pavlina 6f90053020 pcbnew: fix sizing of design rules dialog
Fixes: lp:1741369
* https://bugs.launchpad.net/kicad/+bug/1741369
2018-01-05 14:31:38 -07:00
Wayne Stambaugh c842787492 Minor UI menu string improvements.
Change term "Flip Horizontal" to "Mirror About Horizontal(X) Axis" in
the schematic editor symbol context menu to improve clarity.

Change term "Flip Vertical" to "Mirror About Vertical(Y) Axis" in the
schematic editor symbol context menu to improve clarity.

Change to the same mirror terminology in the block context menu.

Change "Exchange Footprint" to "Change Footprint" in the board footprint
context menu for improved clarity.

Fixes lp:1740593

https://bugs.launchpad.net/kicad/+bug/1740593
2018-01-05 13:07:59 -05:00
Thomas Pointhuber 786ac8143e Request refresh of 3d canvas on resize event
This is a partial fix for https://bugs.launchpad.net/kicad/+bug/1695897
2018-01-05 07:25:13 -07:00
jean-pierre charras 33cbbc95d9 * Gerbview: update a old code in a dialog.
Fixes: lp:1741410
https://bugs.launchpad.net/kicad/+bug/1741410
2018-01-05 11:45:50 +01:00
Jeff Young 658d181ec7 Don't capture cursor if zone or polygon cancelled.
If the client tool indicates it isn't happy for us to continue
(because, for instance, the user has cancelled the Zone Properties
dialog), then make sure we don't capture the mouse.

Fixes: lp: 1740780
* https://bugs.launchpad.net/kicad/+bug/1740780
2018-01-04 13:10:37 -05:00
Jeff Young 5bc5942f36 When selecting a track keep going to pad center.
The previous algorithm stopped whenever it entered a pad, which
sometimes leaves small track segments inside the pad.  This one
keeps going as long as each segment gets us closer to the center
of the pad.

Fixes: lp:1662398
* https://bugs.launchpad.net/kicad/+bug/1662398
2018-01-04 11:52:04 -05:00
Jeff Young 8de0598789 Honor Fill_All_Zones()'s aVerbose parameter.
Fixes: lp:1740909
* https://bugs.launchpad.net/kicad/+bug/1740909
2018-01-04 11:40:40 -05:00
Jon Evans 2dec95b4e6 Add a first-run dialog to encourage user to switch to OpenGL 2018-01-04 10:14:40 -05:00
Chris Pavlina 0945c319f0 eeschema: make footprint preview optional
The footprint preview and selection has been problematic for some users;
I'd rather option it out for 5.0 and work on polishing it for 6.0.
2018-01-03 18:28:44 -07:00
Wayne Stambaugh 4298d4ff4e Change missed UI string termonology from part/component to symbol. 2018-01-03 14:19:26 -05:00
Wayne Stambaugh 202cd43864 Eeschema: minor remapping improvements.
Create separate folder in project path to backup files changed during
remapping.

Add time stamp to backup file names in case multiple remappings are
performed.

Add backup file information to report panel instead of using debug
trace messages.

Disable the remap button if the user does not have write privileges to
the current project path.
2018-01-03 11:25:19 -05:00
Wayne Stambaugh bf44d394c3 Eeschema: fix remapping bug on windows builds.
The Windows drive specifier C: was being interpreted as a valid URL by
wxURI which was performing a URL comparison instead of a file comparison
which always failed in LIB_TABLE_BASE::FindRowByURI().  Change test for
URI to search string for "://" to determine if the comparison should be
a URI (string) comparison or a file (wxFileName) comparison.

Don't run final rescue unless the user performs the remapping.
2018-01-03 08:37:54 -05:00
Jeff Young b1b3a89f72 Set document dirty flag for various dialogs.
Fixes the callers of the Design Settings and Zone Settings dialogs.

Fixes: lp:793420
* https://bugs.launchpad.net/kicad/+bug/793420
2018-01-02 13:34:08 -05:00
Jeff Young f76e7568bc Don't warp cursor if the disambiguation menu is cancelled.
Also fixes the empty-selection-context-menu coming up after
a cancelled disambiguation menu.

Fixes: lp:1738339
* https://bugs.launchpad.net/kicad/+bug/1738339
2018-01-02 13:01:55 -05:00
Tomasz Włostowski 44d4559f84 pcbnew: avoid segfault reported on certain OSX builds
Fixes: lp:1732274
* https://bugs.launchpad.net/kicad/+bug/1732274
2018-01-02 00:49:59 +01:00
Tomasz Włostowski aab4c59615 SHAPE_POLY_SET: fix segfault in unfracturing of polygons with 0-width slits
Fixes: lp:1740253
* https://bugs.launchpad.net/kicad/+bug/1740253
2018-01-02 00:49:59 +01:00
Jeff Young 9fd53c4753 Add standard pan and zoom options to cvpcb footprint viewer.
Fixes: lp:1732881
* https://bugs.launchpad.net/kicad/+bug/1732881
2018-01-01 13:57:42 -05:00
jean-pierre charras c5b8c749da minor fix: use right parent to show the symbol or footprint viewer in dialog 2018-01-01 18:06:02 +01:00
jean-pierre charras 7d6230ab38 Eeschema: Cannot close opening Library Browser frame when reassigning symbols from the Library Browser (wxGTK specific)
Fixes: lp:1740607
https://bugs.launchpad.net/kicad/+bug/1740607
2018-01-01 13:40:23 +01:00
jean-pierre charras 6bb349e933 Better management of KIWAY_PLAYER frame when called in modal mode, and having the wxFLOAT_ON_PARENT style option.
(previously, did not use the actual parent)
2018-01-01 10:41:43 +01:00
jean-pierre charras 2fd7ab248e Fix compil warnings 2018-01-01 09:20:23 +01:00
jean-pierre charras 11d1188fdf MODULE::CoverageRatio(): replace wxRegion (not working for us on Windows) by polygons to calculate areas.
At least on Windows, using wxRegion generates crashes.

Fixes: lp:1740646
https://bugs.launchpad.net/kicad/+bug/1740646
2017-12-31 17:46:56 +01:00
Wayne Stambaugh 03e9f0c94a Eeschema: fix broken library symbol link for missing libraries.
When an attempt to resolve a library symbol link having a library
nickname that was no longer found in the symbol library table, the
symbol resolution was not falling back to the cache library due to
a silently handled exception.  Add check for valid symbol library
table nickname before attempting to resolve symbol link to prevent
exception bypassing falling back to the cache library.

Fixes lp:1740609

https://bugs.launchpad.net/kicad/+bug/1740609
2017-12-31 10:07:58 -05:00
Jeff Young fb597f4298 Enable tab navigation and shift-return-for-OK in multiline text controls for text objects.
Fixes: lp:1420916
* https://bugs.launchpad.net/kicad/+bug/1420916
2017-12-31 09:08:42 -05:00
Wayne Stambaugh b55eb0b5f1 Eeschema: fix assertion in LIB_PART destructor.
A new legacy symbol library plugin deletes all of the aliases from each
LIB_PART object that it owns cause an assertion in the dtor which calls
GetName() which checks for an empty alias list to prevent a segfault.
Remove the call to GetName() from the dtor trace message.

Fixes lp:1740597

https://bugs.launchpad.net/kicad/+bug/1740597
2017-12-30 19:55:11 -05:00
Seth Hillbrand e062780e9c Eeschema: Clears the active block after mirroring
Fixes: lp:1740549
* https://bugs.launchpad.net/kicad/+bug/1740549
2017-12-30 09:37:11 -05:00
Wayne Stambaugh 93683d0021 Enable all build configuration options ready for stable 5 release.
Enable Python scripting, OCE, and spice build configuration options.

Update compiling.md to reflect new option settings.
2017-12-29 17:38:42 -05:00
Seth Hillbrand cfe20e22fb Eeschema: Correcting missing cleanup calls
Adds cleanup (wires and junctions) to two commands:
rotate/orient and drag without block.

Fixes: lp:1739951
* https://bugs.launchpad.net/kicad/+bug/1739951
2017-12-29 16:24:58 -05:00
Seth Hillbrand 6073bf3ea7 Library Editor: Moving current item to the base screen
Store the currently-edited item in the base screen class
instead of the libedit_frame.  This allows us to access it
for double-click disambiguation and harmonizes the library
editor with the schematic editor code that already does this.

Fixes: lp:1738694
* https://bugs.launchpad.net/kicad/+bug/1738694
2017-12-29 15:51:51 -05:00
Wayne Stambaugh 09cff5d8ed Eeschema: minor UI string spelling and coding policy fixes. 2017-12-29 10:44:33 -05:00
Wayne Stambaugh ae7cc5c868 Eeschema: only show the symbol library load progress dialog once. 2017-12-29 10:26:05 -05:00
Wayne Stambaugh 51717aad22 Eeschema: fix segfault bug when LIB_PART has no aliases.
The GetName() method attempts to access the first LIB_ALIAS pointer in
the m_aliases member without checking if m_aliases is empty.  This
should never happen because a new LIB_PART creates a LIB_ALIAS object
in the ctor.  Some how, this is getting bypassed and causing Eeschema
to crash in the LIB_PART dtor on debug builds.  GetName() now checks
for an empty alias list to prevent a null pointer segfault.

Fixes lp:1739614

https://bugs.launchpad.net/kicad/+bug/1739614
2017-12-29 09:57:12 -05:00
Wayne Stambaugh 70f516bde4 Eeschema: changed missed instances of component in UI strings.
Fixes lp:1740440

https://bugs.launchpad.net/kicad/+bug/1740440
2017-12-29 08:46:24 -05:00
Jeff Young 88f23f17c1 Fix dialog OK button event issues on OSX.
Move the OSX dialog fix ups later so they come after some wxWindow
deferred processing.

Also provides a facility for doing a selectAll in each text field
so that tabbing between text fields behaves correctly.

Fixes: lp:1599157
* https://bugs.launchpad.net/kicad/+bug/1599157
2017-12-29 08:14:41 -05:00
jean-pierre charras 8bb03067c1 Update demos 2017-12-29 10:44:08 +01:00
Nick ?stergaard 4f1b510750 Use same path icon for the Configure Paths menu option
Also move the path configure item above the General Options to align
better with the menu in pcbnew.
2017-12-28 17:08:15 -05:00
Jeff Young 8a21641639 Eeschema: fix block copy and cut command event handlers.
Popup menu IDs must be between START_RANGE and END_RANGE to get bound to
the right event handler.

Fixes: lp:1667730
* https://bugs.launchpad.net/kicad/+bug/1667730
2017-12-28 16:12:33 -05:00
Jeff Young 0f943f1e4b Disambiguation menu fix for footprints with a single pad.
Fix selection disambiguation to allow for selecting of footprints which are
mostly covered by their pads, text, etc.

Fixes: lp:1739425
* https://bugs.launchpad.net/kicad/+bug/1739425

Fixes: lp:1723469
* https://bugs.launchpad.net/kicad/+bug/1723469
2017-12-28 15:36:34 -05:00
Robbert Lagerweij bd7f5081d1 Pcbnew: make the line/arc drawing tool show segment length
This patch adds functionality to the Pcbnew draw tool to show the dx and
dy of the current segment being drawn if the relative origin (pressing
spacebar) is not already set (i.e. if those coordinates are ( 0, 0 ) ).
You can set the relative origin while using the draw tool by pressing
spacebar. The relative origin is reset on exit of the tool.

fixes: lp:1736133
* https://bugs.launchpad.net/kicad/+bug/1736133
2017-12-28 15:14:14 -05:00
Wayne Stambaugh 1175d50486 Eeschema: fix default ERC dialog tab. 2017-12-28 14:17:47 -05:00
Wayne Stambaugh fd72c91acd Pcbnew: fix design rule dialog sizing on high DPI displays.
Remove maximum dialog width setting to allow the dialog to resize
properly on high DPI displays.

Fixes lp:1740356

https://bugs.launchpad.net/kicad/+bug/1740356
2017-12-28 13:56:13 -05:00
jean-pierre charras 5ca5783448 3D viewer, view options dialog: add missing option. 2017-12-28 14:14:46 +01:00
jean-pierre charras 00c2257b26 3D viewer: Remove outdated option "show holes in zones" that was no longer used in opengl mode, and useless in ray tracing
(it was only used to reduce the calculation time)
Also add a wxBusyCursor when rebuilding the 3D scene.
2017-12-28 11:01:10 +01:00
jean-pierre charras 27171e1a88 3D viewer: re-enable 3D viewer display options, and update this dialog. 2017-12-28 09:30:18 +01:00
Jeff Young fab6fc69e3 wxWidgets OSX patch for tabbing in staticBoxes in dialogs
Fixes: lp:1740187
* https://bugs.launchpad.net/kicad/+bug/1740187
2017-12-27 16:25:15 -05:00
Jeff Young 064f4c4ba7 Commit in-place edits before transfering data from window.
Fixes: lp:1592767
* https://bugs.launchpad.net/kicad/+bug/1592767
2017-12-27 16:12:41 -05:00
Wayne Stambaugh 70fab83b4f Fix UI policy issue in CvPcb footprint association file dialog. 2017-12-27 16:10:17 -05:00
Jeff Young d3923de7b9 Don't dim markers when in high-contrast mode.
Fixes: lp:1706570
* https://bugs.launchpad.net/kicad/+bug/1706570
2017-12-27 21:55:28 +01:00
Simon Richter b4ad8ec560 Order source file names alphabetically 2017-12-27 14:01:05 -05:00
Wayne Stambaugh 4d64a2f53f Set reasonable 3D model select dialog default path.
Passing an empty path to the 3D model select dialog results in the file
select control displaying the root path which requires the user to drill
down to get to the 3D models.  Use the KISYS3DMOD path as the default
and fall back to the project path as required for the initial file
select control path.

Clean up some coding policy violations.

Fixes lp:1737094

https://bugs.launchpad.net/kicad/+bug/1737094
2017-12-27 12:43:26 -05:00
Wayne Stambaugh 5102c8ac1f Gerbview and Pcbnew dialog tweaks.
Improve dialog layout and fix UI policy issues with all of the dialog
boxes in the Gerbview and Pcbnew code paths.

Updated the use of component to footprint where appropriate.
2017-12-27 12:09:56 -05:00
jean-pierre charras 90818afedd Try to fix: pad editor: incorrect zoom scale of pad preview on some installs.
Fixes: lp:1670086
https://bugs.launchpad.net/kicad/+bug/1670086
2017-12-26 20:46:52 +01:00
Wayne Stambaugh 71ea6dc2b9 Common, 3D viewer, CvPcb, and Eeschema dialog tweaks.
Improve dialog layout and fix UI policy issues with all of the dialog
boxes in the common, 3D viewer, CvPcb, and Eeschema code paths.

Updated the use of component to symbol.
2017-12-26 09:38:45 -05:00
Wayne Stambaugh 570866557f Add environment variable configuration dialog to Eeschema.
Fixes lp:1739910

https://bugs.launchpad.net/kicad/+bug/1739910
2017-12-24 12:57:57 -05:00
Wayne Stambaugh f7ab50f791 UI string normalization.
Replace all instances of "component" and "part" with "symbol" when
referring to schematic and library symbols.

Replace all instances of "component" with "footprint" when referring to
board and library footprints.

Minor dialog layout fixes to some of the dialogs impacted by the UI
string changes.
2017-12-24 10:04:32 -05:00
jean-pierre charras fe6ade185a DIALOG_UPDATE_FIELDS: make it resizable and fix a few very minor UI policy issues. 2017-12-24 10:38:10 +01:00
jean-pierre charras b05a40e728 FOOTPRINT_WIZARD_FRAME: fis a serious issue when changing a parameter page when a parameter was currently edited
Also Fixes: lp:1739881
2017-12-23 18:34:57 +01:00
Wayne Stambaugh 3a74e5253b Environment variable dialog fixes.
Remove redundant sizers from environment variable dialog.

Improve sizers and layout spacing of environment variable and environ-
ment variable edit dialogs.

Remove path from dialog box titles since environment variables are not
limited to file paths.

Improved help messages for both environment variable and environment
variable edit dialogs.

Restore highlighting of externally defined environment variables.
2017-12-22 17:34:03 -05:00
Miles McCoo 5cc1cda29f BuildConnectivity and re-DisplayBoard in python Refresh function
Refresh is used in the python domain to refresh the display with the current
design. If something has changed, board connectivity likely needs rebuilding.
If using GAL canvas, update its display db.
2017-12-22 08:59:19 -05:00
Wayne Stambaugh 8f0e6469ca Minor symbol remapping fixes.
The remapping utility would create a new project specific library when a
symbolic link pointed to a library already defined in the symbol library
table.  Now the comparison checks to see if the library path and file
name are actually a symbolic link if the file names are not the same when
the symbol library table entry is a file name rather than a URL.  URLs
are simple string comparisons.

Disable the remap button after the remapping completed.

Remove some commented out code from the edit symbol in schematic dialog.

Fixes lp:1738634

https://bugs.launchpad.net/kicad/+bug/1738634
2017-12-22 08:03:49 -05:00
jean-pierre charras 992820f722 shape_line_chain ans shape_poly_det: add Rotate() geometric transform, useful for DRAWSEGMENT transforms 2017-12-22 10:54:47 +01:00
jean-pierre charras 7586afd530 graphic items properties dialog: fix incorrect handling of S_POLYGON DRAWSEGMENT items 2017-12-21 19:47:18 +01:00
Oliver Walters 900ddca0b4 Changed default text size to 50mils
- Text size is now always written to file
- Unspecified text sizes are read as 60mils

Fixes lp:1737878

https://bugs.launchpad.net/kicad/+bug/1737878
2017-12-21 12:16:57 -05:00
Seth Hillbrand 1396ab0941 Eeschema: Consider buses for junctions
Allows buses to acquire junctions based on their connections.  Buses
can only have junctions with other buses.  Also allows buses to be
draggable junctions for collections
2017-12-21 11:04:46 -05:00
jean-pierre charras 23d71cfa93 fix typo 2017-12-21 15:08:10 +01:00
jean-pierre charras d9a2b5161c Fix issues due to internal code change in DRAWSEGMENT class, for S_POLYGON shape.
Remove also duplicate code in 3D viewer, for this DRAWSEGMENT shape.
2017-12-21 15:07:03 +01:00
Maciej Suminski 783b5e2616 Forbid colon, slash and backslash characters in symbol names 2017-12-21 13:56:35 +01:00
Jeff Young dbf39e6333 A bit more commenting for the guessSelectionCandidates logic. 2017-12-21 13:15:23 +01:00
Maciej Suminski 158bc0619d Footprints with pads taking most of area are kept in the selection menu
Improved the selection heuristics to keep footprints in the
disambiguation menu when they contain pads with high pad-to-footprint
area ratio.
In other words: make it possible to select a footprint when
most of its area is taken by a pad. Previously pads were given the
priority, so it was very tricky to select the parent footprint.

Fixes: lp:1739425
* https://bugs.launchpad.net/kicad/+bug/1739425
2017-12-21 10:32:00 +01:00
jean-pierre charras 49cedf7950 Pad properties dialog: Disambiguate connection to zone options for custom shaped pads and predefined shaped pads 2017-12-21 10:23:37 +01:00
jean-pierre charras b93cc8423e qrcode_footprint_wizard.py fix (due to DRAWSEGMENT recent changes)
Fixes: lp:1739265
https://bugs.launchpad.net/kicad/+bug/1739265
2017-12-21 10:23:37 +01:00
Maciej Suminski 2fc07561f1 Fix crash when drawing a polygon with empty outline
In theory there should be no polygons with empty outline, but as you see
there was at least one leading to a crash.

Fixes: lp:1739455
* https://bugs.launchpad.net/kicad/+bug/1739455
2017-12-21 09:51:26 +01:00
Oliver Walters 5c6c60def4 Remove custom font from lib_table_grid
Fixes: lp:1738617
* https://bugs.launchpad.net/kicad/+bug/1738617
2017-12-21 09:35:52 +01:00
jean-pierre charras 59c527c40c Excellon drill file generation: allows 4 digits in mantissa in Tool Information command when units are inches.
Fixes: lp:1738657
https://bugs.launchpad.net/kicad/+bug/1738657
2017-12-20 17:49:25 +01:00
Maciej Suminski 69ceae0ccf Selection tool: do not select relatively large modules
To avoid situations when a large footprint covering most of the board
area (e.g. shield connector) is always selected, even when user clicks
in a seemingly empty spot, a simple filter has been added. In case
the footprint area covers more than 90% of the view area, the large
footprint is not selected. This way large footprints do not disturb
editing when the zoom is high enough.

Fixes: lp:1636214
* https://bugs.launchpad.net/kicad/+bug/1636214
2017-12-20 17:32:00 +01:00
Seth Hillbrand a061fe1f99 Eeschema: Adding connection block selections
This adjusts the selection addition criteria for
blocks to allow items such as labels to connect to
lines not at the endpoints.  It also uses the same
logic to correctly gather bus-wire, bus-bus entries.

Fixes: lp:1738941
* https://bugs.launchpad.net/kicad/+bug/1738941
2017-12-20 10:04:25 -05:00
Maciej Suminski 7f9876ec27 Fix lexical sort in component tree widget on Windows
Apparently explicitly requesting a column to be sorted breaks component
filtering on Windows. Without SetSortOrder() call the list is sorted and
filtering still works as expected.

Fixes: lp:1739412
* https://bugs.launchpad.net/kicad/+bug/1739412
2017-12-20 14:50:36 +01:00
Maciej Suminski 320fa7120d Expand/collapse library nodes with Enter key in component chooser 2017-12-20 12:25:12 +01:00
Maciej Suminski 5fac73fc21 Fixed browsing order with arrow keys in component chooser on Windows
As Windows displays the component list in inverted order, the direction
of scrolling had to be reversed as well.
2017-12-20 12:23:05 +01:00
Maciej Suminski 6344e238b3 Fix random node selection in symbol library editor on Windows
Selecting a node while wxDataViewCtrl is frozen selects a random node on
Windows.

Fixes: lp:1739202
* https://bugs.launchpad.net/kicad/+bug/1739202
2017-12-20 12:06:21 +01:00
Maciej Suminski 457bbbed15 Added a comment for a1b70601 (fixed filtering in component chooser) 2017-12-20 11:48:00 +01:00
Maciej Suminski f3a6bc6651 Fix crash on cut/remove a part in symbol library editor
Fixes: lp:1738635
* https://bugs.launchpad.net/kicad/+bug/1738635

Fixes: lp:1738999
* https://bugs.launchpad.net/kicad/+bug/1738999
2017-12-20 09:46:02 +01:00
Maciej Suminski 7741b90c78 gal: Draw grid from edge to edge
Fixes: lp:1677211
* https://bugs.launchpad.net/kicad/+bug/1677211
2017-12-20 09:28:39 +01:00
Seth Hillbrand f4f0c09fe4 Eeschema: Clear drawing state when loading project
Prevents stray flags from entering schematic editing process

Fixes: lp:1738894
* https://bugs.launchpad.net/kicad/+bug/1738894
2017-12-19 11:49:25 -05:00
Maciej Suminski a1b7060189 Fixed filtering in component chooser on Windows
Please never ask me about the SetSortOrder() part. When it is set to
'true', wxDataViewCtrl::EnsureVisible() does not always work correctly,
so sometimes the best search result is not shown in the window (no
pattern found). Now it is set to 'false' to avoid the described
behavior, but the sorting order is reversed on Windows, not on Linux.
I could not test it on OSX, but I am sure it paints walls in your room
pink. /me burst into tears.

Fixes: lp:1738696
* https://bugs.launchpad.net/kicad/+bug/1738696
2017-12-19 15:19:04 +01:00
Bernhard Stegmaier 29e1d3d98a Fix Eagle plugin build errors on macOS
Fixes: lp:1738865
* https://bugs.launchpad.net/kicad/+bug/1738865
2017-12-19 13:38:28 +01:00
Maciej Suminski d4c8e1b5e9 Fixed ignored hot keys for save part/library commands in Symbol Editor
Previously wxUpdateUIEvent::SetText() stripped hotkey from menu entries.

Fixes: lp:1737819
* https://bugs.launchpad.net/kicad/+bug/1737819
2017-12-19 12:21:07 +01:00
Maciej Suminski 017fc4da8f Fixed capitalization and accelerators in Symbol Library Editor
Menu item labels follow the KiCad UI guideline.
Removed an accelerator conflict for 'Place' and 'Part' menus.
2017-12-19 12:21:07 +01:00
jean-pierre charras f85a886ae4 Bug fix: Custom shaped pads having a not convex shape not magnetic on PnS router. 2017-12-19 11:13:28 +01:00
jean-pierre charras 3183fcb4bc Fix minor compil warnings (some are for old compilers). 2017-12-18 19:52:44 +01:00
Tomasz Włostowski 3c6d17026e pcbnew: router now respects local pad clearances correctly
Fixes: lp:1558858
* https://bugs.launchpad.net/kicad/+bug/1558858
2017-12-18 18:51:47 +01:00
Tomasz Włostowski a4528988ca pcbnew: fix graphical polygon movement, rotation, flipping and edit points synchronization.
Fixes: lp:1738449
* https://bugs.launchpad.net/kicad/+bug/1738449

Fixes: lp:1738032
* https://bugs.launchpad.net/kicad/+bug/1738032
2017-12-18 18:25:45 +01:00
Simon Richter 758d5727b0 Minor string fixes 2017-12-18 18:09:48 +01:00
Maciej Suminski f039e0bb6d Eagle parser: declare Convert() specialization for wxString in eagle_parser.h 2017-12-18 17:45:40 +01:00
Maciej Suminski 4b62b3519c Update units in 'select track/via size' context menu
Fixes: lp:1485941
* https://bugs.launchpad.net/kicad/+bug/1485941
2017-12-18 17:03:07 +01:00
Bernhard Stegmaier 02d1b2611e Remove wx-3.1 only constructor from HIDPI_GL_CANVAS wrapper. 2017-12-18 16:26:01 +01:00
Bernhard Stegmaier 0135d11412 Fix macOS pinch-to-zoom for 3d-viewer. 2017-12-18 16:26:01 +01:00
Bernhard Stegmaier 19d7112fa2 Merge HIDPI_GL_CANVAS wrapper with OPENGL_GAL implementation. 2017-12-18 16:26:01 +01:00
Bernhard Stegmaier 909d95b5be Create HIDPI_GL_CANVAS wrapper for transparent wxGLCanvas HiDPI/Retina support. Enable HiDPI/Retina for 3d-viewer. 2017-12-18 16:26:01 +01:00
Tomasz Włostowski 9da1dc4c51 pcbnew: highlight net highlights ratnsest too
Fixes: lp:1738636
* https://bugs.launchpad.net/kicad/+bug/1738636
2017-12-18 15:30:35 +01:00
jean-pierre charras 1f78de409f Define "template<> struct hash<wxString>" in Kicad only if wxWidgets version < 3.1.0, because it is already defined in 3.1.0 2017-12-18 09:53:14 +01:00
jean-pierre charras 9d4bfbded8 libedit, UI very minor change:
Enable "save curr lib" tool of main toolbar when modified even if this lib is empty.
It happens when all items are erased, and it is consistent with the close libedit dialog
that ask for saving all modified libraries
2017-12-18 09:50:28 +01:00
Christian Jacobsen ff4829eee6 Added a validity check in SIM_PLOT_PANEL::IsGridShown()
Fixes: lp:1712086
* https://bugs.launchpad.net/kicad/+bug/1712086
2017-12-18 09:34:25 +01:00
Andrew Wygle 9413793ef4 Eeschema: Correctly assign unit when copy/pasting
Fixes: lp:1738656
* https://bugs.launchpad.net/kicad/+bug/1738656
2017-12-17 22:27:31 +01:00
Seth Hillbrand 3f24128f17 Eeschema: Updates pin cache correctly for multi-unit components
Fixes: lp:1738615
* https://bugs.launchpad.net/kicad/+bug/1738615
2017-12-17 14:44:12 -05:00
Maciej Suminski 2e00169ae7 Explicitly cast wxString to std::string when throwing std::exception 2017-12-17 20:17:02 +01:00
Maciej Suminski 3f68af177a Eagle Schematic Importer fixes 2017-12-17 19:55:23 +01:00
Maciej Suminski 378846c2e3 Eagle Schematics Importer: support for UTF-8
Fixes: lp:1736083
* https://bugs.launchpad.net/kicad/+bug/1736083
2017-12-17 19:54:21 +01:00
Maciej Suminski 812b8b081d Implemented std::hash<wxString> specialization
Thanks to that wxString objects can be stored in certain
STL containers, e.g. unordered_map.
2017-12-17 18:45:40 +01:00
Maciej Suminski 124c82f1cf Eagle Schematic Import: fixed imported libraries location
Standalone eeschema did not have the project path set when importing
a non-KiCad sheet. Due to this any libraries created during the import
were saved to the directory of eeschema executable instead of the actual
schematic directory.
2017-12-17 18:45:40 +01:00
Maciej Suminski 7665a839cd Eagle Schematic Import: try harder to generate a meaningful library name
The previous implementation relied only on the project name. When it is
set, the imported library was named '-eagle-import'. Now it tries
the project name and then the file name, using 'noname-eagle-import'
as fallback.

The library name is stored in the plugin to avoid changing the library
name after the project name has been set.
2017-12-17 18:45:40 +01:00
Maciej Suminski a13c89c83d Removed old debug output 2017-12-17 18:43:43 +01:00
Eldar Khayrullin 9f2c6e20cb P-Cad PCB importer fixes 2017-12-17 11:27:19 +01:00
Eldar Khayrullin 4cd3992b94 pcad2kicadpcb_plugin: import graphic polygons from modules
Fixes: lp:1725931
* https://bugs.launchpad.net/kicad/+bug/1725931
2017-12-17 10:58:29 +01:00
Eldar Khayrullin d62d3b8e21 pcad2kicadpcb_plugin: map layers Top/Bot Assy to F/B Fab 2017-12-17 10:58:29 +01:00
Eldar Khayrullin 87566eedc5 pcad2kicadpcb_plugin: fix size of text 2017-12-17 10:58:29 +01:00
Eldar Khayrullin 613272852d pcad2kicadpcb_plugin: fix import a flipped RefDes
Fixes: lp:1730172
* https://bugs.launchpad.net/kicad/+bug/1730172
2017-12-17 10:58:29 +01:00
Eldar Khayrullin 9620a43022 pcad2kicadpcb_plugin: correct text position with arbitrary angle 2017-12-17 10:58:29 +01:00
Eldar Khayrullin 6f0e0826fa pcad2kicadpcb_plugin: unlock orientation of footprint fields 2017-12-17 10:58:29 +01:00
Eldar Khayrullin c9852d7c81 pcad2kicadpcb_plugin: import circles 2017-12-17 10:58:29 +01:00
Eldar Khayrullin 08b71cd252 pcad2kicadpcb_plugin: use a valid font properties
Use current selected font (Stroke, TrueType) properties.
Import TrueType Font properties: bold, italic.
2017-12-17 10:58:29 +01:00
Eldar Khayrullin 897702b2dc pcad2kicadpcb_plugin: prepend numerical Ref with '.'
Kicad (EESchema) doesn't support only numerical references (like '1').
Prepend with '.' same references (convert reference '1' to '.1').
2017-12-17 10:58:29 +01:00
Eldar Khayrullin 21ddb2d989 pcad2kicadpcb_plugin: use default text parameters if not defined 2017-12-17 10:58:29 +01:00
jean-pierre charras 845ca5f641 very minor fixes in a few strings (replace ' by ", and module by footprint) 2017-12-16 20:46:55 +01:00
jean-pierre charras 2b4a2ce67b update demo ecc83 2017-12-16 20:44:52 +01:00
jean-pierre charras 766a9bec1e Allows negative solder-mask margin in dialog pad properties.
However, this is not allowed for custom shapes pads, because it can create very strange solder mask shapes.
2017-12-16 20:43:47 +01:00
Seth Hillbrand 0ef2a7f08b Eeschema: Mark wire-bus entries correctly
Marks wire-bus entries as not dangling if there is at least a wire
and a bus on each end.  Corrects behavior when wires and buses overlap
at the endpoint.
2017-12-16 09:03:23 -05:00
jean-pierre charras 2398d5ef8b DIALOG_EDIT_COMPONENTS_LIBID: enhancement in orphan automatic remap:
add dialog to choose the right candidate when more than one is found
2017-12-16 14:50:37 +01:00
Jeff Young 833534537d Fix touchpad tapping.
Don't apply missing-mouse-up logic to mouse-down events.  The
logic depends on mouse-state, and the OS-synthesized mouse-up
and mouse-down events from a tap don't contain any state.

Fixes: lp:1737010
* https://bugs.launchpad.net/kicad/+bug/1737010
2017-12-15 16:59:19 -05:00
Seth Hillbrand 6f3e55d344 wx: Add double-click handling in disambiguation cases
Fixes: lp:1154020
* https://bugs.launchpad.net/kicad/+bug/1154020
2017-12-15 16:32:19 -05:00
Jeff Young 27a55c5cd4 Commit in-place editing changes when dialog OK'ed.
Grid control in-place editing changes are not automatically
committed (at least on OSX).

Fixes: lp:1736836
* https://bugs.launchpad.net/kicad/+bug/1736836
2017-12-15 08:01:43 -05:00
Simon Richter a9ccf1161b Fix quotes in UI messages
This replaces all single and angle bracket quotes in UI messages with
double quotes, for consistency.

Sorry to all translators.
2017-12-15 07:33:07 -05:00
jean-pierre charras 9ed0f2184b Fix: Gerber plot output creates incorrect custom pads when a rectangular anchor pad with x size > y size is used.
Fixes: lp:1738384
https://bugs.launchpad.net/kicad/+bug/1738384
2017-12-15 12:33:28 +01:00
Tomasz Włostowski 75b21d010b pcbnew: more thread (and nested wx event loop) safety for the zone filling/connectivity algo 2017-12-14 23:49:46 +01:00
Seth Hillbrand 87938b06b4 Eeschema: TestDanglingEnds on Cross-probe
Fixes: lp:1672381
* https://bugs.launchpad.net/kicad/+bug/1672381
2017-12-14 16:04:30 -05:00
Eldar Khayrullin 185c77e2fd pcad2kicadpcb_plugin: fix compiling warning override 2017-12-14 18:52:11 +01:00
Maciej Suminski 9bb660a6bc Fix P-Cad importer plugin warnings
A few methods differed by the number or type of arguments in derived
classes. They were changed to match the base class method signature and
marked as 'override'.
2017-12-14 18:52:05 +01:00
jean-pierre charras dee93e5eeb Minor fix: rename LIB_PART::m_dateModified to LIB_PART::LIB_PART::m_dateLastEdition
and use m_dateLastEdition type for LIB_PART::m_dateLastEdition
2017-12-14 17:27:40 +01:00
Maciej Suminski 4671b9b34e Fixed module removal when rotating/flipping a placed module
Module placer did not mark the newly placed modules as selected,
but all edit functions (rotate/place/etc.) rely on getting a selected
item. When a rotation/flip command was issued, the newly placed module
was dropped and the one underneath the cursor has been rotated.

To fix this the newly placed modules are marked as selected.
It also simplifies the placer code a bit.

Fixes: lp:1738148
* https://bugs.launchpad.net/kicad/+bug/1738148
2017-12-14 17:13:42 +01:00
Maciej Suminski 9c2d1cf890 Fixed BOARD_COMMIT::Revert()
Revert() method was still not aware of CHT_DONE flag, therefore
the switch statement was always invalid. To fix it, the commit
type is split to type and flags as is done in Push() method.
2017-12-14 17:13:42 +01:00
Maciej Suminski d599a83c4b Removed unused variables in PCB_VIEW 2017-12-14 17:13:42 +01:00
jean-pierre charras dc6c98310f Export drawing in symbol editor results in error message and no drawing file (.sym file) saved
Fixes: lp:1737875
https://bugs.launchpad.net/kicad/+bug/1737875
2017-12-14 16:45:30 +01:00
jean-pierre charras a287748921 Cosmetic enhancement: Add icons to track length tuner menu. 2017-12-14 14:33:20 +01:00
Tomasz Włostowski b47a06e42a poly2tri: include stdexcept in each file throwing an std::exception. 2017-12-14 02:29:33 +01:00
Tomasz Włostowski a83ece88fd poly2tri use std::runtime_error, fixes builds on many Linux distributions 2017-12-14 02:14:35 +01:00
Tomasz Włostowski eed924fe45 Fixed zone filling crash & thermal stubs inconsistency
Fixes: lp:1737557
* https://bugs.launchpad.net/kicad/+bug/1737557
Fixes: lp:1737542
* https://bugs.launchpad.net/kicad/+bug/1737542
Fixes: lp:1737541
* https://bugs.launchpad.net/kicad/+bug/1737541
2017-12-14 01:29:08 +01:00
Tomasz Włostowski 2831268b60 PROGRESS_REPORTER: KeepRefreshing shouldn't block on non-OpenMP systems
Fixes: lp:1737277
* https://bugs.launchpad.net/kicad/+bug/1737277
2017-12-14 01:26:41 +01:00
Tomasz Włostowski 941ebe376c poly2tri: throw exceptions instead of crashing on non-supported polygons 2017-12-14 01:25:28 +01:00
jean-pierre charras c18b638c17 Cosmetic enhancement in GAL: disambiguationMenu: add icons in menuitems, like in Legacy mode. 2017-12-13 19:42:33 +01:00
Maciej Suminski 8ab8a11cf8 Faster zone and custom shape pad drawing, minor PCB_PAINTER refactor
Zones: it turned out that for every zone point, the set of hatch lines
has been drawn, resulting in numerous redundant lines. Now the set is
drawn only once per zone.

Custom shape pads: as GAL supports SHAPE_POLY_SETs, there is no need to
create a temporary vector to copy there a list of points to be drawn.
Changed the drawing calls to use SHAPE_POLY_SETs directly.

Thanks to Andreas Buhr patch, code for drawing filled polygons and their
outlines has been unified. Previously it was done by changing the
drawing method (GAL::DrawPolygon() vs GAL::DrawPolyline()), now it is
done by modifying attributes (stroke/fill).
2017-12-13 17:01:32 +01:00
Andreas Buhr 6205363b50 bugfix: OPENGL_GAL::DrawPolygon did not close closed polygons
The polygon drawing routing in the OpenGL-GAL did
not plot polygons which are "closed", i.e. have a segment
from their last point to their first point, correctly.
That segment was omitted.
This commit fixes this bug.
2017-12-13 17:01:32 +01:00
Jeff Young df76380a2d Don't leave a hidden item behind.
If the object changes between a TA_CONTEXT_MENU_UPDATE
event and a TA_CONTEXT_MENU_CHOICE event (usually as
a result of a cancel), the old code would leave the
last item hidden.

Fixes: lp:1737562
* https://bugs.launchpad.net/kicad/+bug/1737562
2017-12-13 15:59:21 +01:00
Jeff Young dc9d17100b Fix update of brightened objects on OSX.
The OSX implementation needs to be poked to update the
brightening / unbrightening during running of the
disambiguation menu.  (FWIW, now that I've finally seen
it in action, it's a REALLY cool feature.)

Fixes: lp:1715440
* https://bugs.launchpad.net/kicad/+bug/1715440
2017-12-13 11:31:24 +01:00
jean-pierre charras 33c2d6e4ba Fixed disappearing components in COMPONENT_TREE in library editor
The reason the component tree widget was cleared on Windows is the fact
m_adapter->UpdateSearchString( m_query_ctrl->GetLineText( 0 ) ) is
called on any change of the symbol. But if m_query_ctrl is empty,
m_query_ctrl->GetLineText( 0 ) returns the "hint" (currently the word
"Search") not the actual value, so there is no "candidate" symbol in
list. Using m_query_ctrl->GetValue() returns the actual value and fixes
this issue.

Fixes: lp:1737132
* https://bugs.launchpad.net/kicad/+bug/1737132
2017-12-13 10:34:14 +01:00
Seth Hillbrand 8e764f85a4 Optimizing speed of sch_component pin references
Pins are weak_ptrs to the library, so they require a lock() before
accessing.  This imposes a performance hit on fast loops that access
the pin list repeatedly.  This patch caches the pin position locally
for each component, updating only when needed.

Fixes: lp:1737363
* https://bugs.launchpad.net/kicad/+bug/1737363
2017-12-12 17:48:50 -05:00
Oliver 0871719cc9 Add links to list of library contributors on GitHub
- Apologies to "leet hackers"
- Add URL option to contributor entity
2017-12-12 07:40:15 -05:00
jean-pierre charras 5f6f03b16c HIERARCHY_NAVIG_DLG: allows closing the dialog by ESC key (like other dialogs)
cleanup hierarch.cpp code
2017-12-12 09:54:42 +01:00
jean-pierre charras b395b55a20 Fix a few (minor) issues in microwave tools. 2017-12-11 12:54:44 +01:00
Maciej Suminski aedf24d944 Fix crash when renaming a component in symbol library editor
COMPONENT_TREE::STATE used wxDataViewItem to store the selection, but it
will point to a deleted object if the selection was removed. Switched to
storing the selection using LIB_ID as it is much safer to use.
2017-12-11 11:22:24 +01:00
Maciej Suminski f19aed9d5c Workaround for OSX freeze when filling zones in GAL
More details:
https://lists.launchpad.net/kicad-developers/msg32306.html
2017-12-11 10:39:58 +01:00
Andreas Buhr 5572183c22 bugfix: OPENGL_GAL::drawPolygon did not respect fill settings
The OPENGL_GAL::drawPolygon function and all functions using it
did not respect the isFillEnabled member set by
GAL::SetIsFill. This is fixed by this patch.
2017-12-11 10:21:37 +01:00
Andreas Buhr 084eea6781 Bugfix: EDA_RECT to BOX2I generated wrong boxes
The "operator BOX2I() const" of EDA_RECT produced
wrong boxes, usually much to big. It passed its
end-position as second argument to the constructor
of BOX2I. However, BOX2I expects its size as second
argument.

This caused a dramatic performance penalty in some
cases.
2017-12-11 09:48:13 +01:00
Jon Evans b6ac603f0a Fix AlignLeft / AlignRight when using Flip Board view
Fixes: lp:1734377
* https://bugs.launchpad.net/kicad/+bug/1734377
2017-12-11 09:40:08 +01:00
Jon Evans 6ee26fdd8c Remove LAYER_WORKSHEET from forced visibility since it now has a control
Fixes: lp:1737315
* https://bugs.launchpad.net/kicad/+bug/1737315
2017-12-10 17:41:00 -05:00
Jon Evans 1955f25226 Remove outdated check on endAngle to fix arc draw direction
Fixes: lp:1737420
* https://bugs.launchpad.net/kicad/+bug/1737420
2017-12-10 11:45:33 -07:00
Jon Evans 48388695ae Use explicit shift in hotkeys instead of mixed-case characters
Because of how wxMenuItem decodes the label text, the case of
alphabetic hotkeys is not preserved when displaying the menu.  So,
alphabetic hotkeys that use the Shift key must be defined this way.

Fixes: lp:1737303
* https://bugs.launchpad.net/kicad/+bug/1737303
2017-12-09 19:59:55 +01:00
Seth Hillbrand cb422e29df Eeschema: Filter out empty libraries
Fixes: lp:1736930
* https://bugs.launchpad.net/kicad/+bug/1736930
2017-12-09 08:33:58 -05:00
Seth Hillbrand 394749f1d6 Eeschema: calculate not-connected pins correctly
Show the NC box only on pins connected via the same component,
indicating a stacked pin group.  Do not show NC box on pins for
different components with the same symbol.
2017-12-08 17:20:08 -05:00
Seth Hillbrand f0fecba9e1 Eeschema: add junction to 3-component/wire connection
Fixes: lp:1737014
* https://bugs.launchpad.net/kicad/+bug/1737014
2017-12-08 17:19:47 -05:00
Maciej Suminski d205366da7 Add support for wchar_t to SWIG 2017-12-08 18:04:51 +01:00
jean-pierre charras 4c4b11b45f change UTF8& operator+=( wchar_t ch ) to UTF8& operator+=( unsigned ch ), because swig does not like wchar_t.
(on Linux, wchar_t is a unsigned int, on Windows a unsigned short, so always using a unsigned int do not create issues)
2017-12-08 17:57:53 +01:00
Andreas Buhr b33bf2eafe fix double free and memory leak in SHAPE_POLY_SET
There were two problems in the triangulation caching
of SHAPE_POLY_SET:
First there was a double free:
While SHAPE_POLY_SET implements the copy constructor,
it did not implement the operator=, which resulted
in the default operator= being generated by the
compiler. The default operator= copied the member
m_triangulatedPolys, which is a std::vector of pointers.
So after operator= execution, there are two SHAPE_POLY_SET
having pointers to the same TRIANGULATED_POLYGONs, each
of them deleting them in their destructors. This led
to segfaults, because calling
TransformShapeWithClearanceToPolygon on a Zone
uses operator= to copy the contained SHAPE_POLY_SET.
The new SHAPE_POLY_SET then went out of scope and
deleted the cached triangulation within the Zone.

This first problem is fixed by implementing operator=
for SHAPE_POLY_SET.

Second, there was a memory leak: Calling
"CacheTriangulation" on a SHAPE_POLY_SET,
then changing the polygon and then calling
"CacheTriangulation" again led to
leaking the
triangulations generated in the first call.

This second problem is fixed by holding
the cached triangulations in a unique_ptr.
2017-12-08 14:55:46 +01:00
jean-pierre charras d958ab9460 Fix operator+= for UTF8 class
Added operator+=(wchar_t), as operator+=(char) was not sufficient to
handle multibyte characters present in UTF8.

Fixes: lp:1737143
* https://bugs.launchpad.net/kicad/+bug/1737143
2017-12-08 14:37:55 +01:00
Wayne Stambaugh 7ca7d9078e Eeschema: fix potential symbol cache library name collisions.
If a schematic contains two symbols with the same name from different
libraries, the cache will contain the last symbol saved with that name.
Prepend the library nickname with the original schematic symbol library
nickname when saving the cache library to prevent name collisions.
2017-12-08 08:32:23 -05:00
Maciej Suminski f7072cc7c6 Moved DRC::doEdgeZoneDrc to drc_clearance_test_functions.cpp 2017-12-08 11:33:40 +01:00
Maciej Suminski 9b5dc5c215 GAL show markers for zone outlines gap test
Moved a DRC function (BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines)
from BOARD class to DRC (DRC::TestZoneToZoneOutline). Added BOARD_COMMITs
to handle marker visibility updates.

Fixes: lp:1619124
* https://bugs.launchpad.net/kicad/+bug/1619124
2017-12-08 11:33:32 +01:00
Maciej Suminski 693c8bce40 Moved text_utils.cpp from libcommon to libgal 2017-12-08 09:01:49 +01:00
jean-pierre charras 81357eb584 Update demo to use latest libraries. 2017-12-07 18:28:11 +01:00
Maciej Suminski 9da8398cf3 Added files missing in 602ecf75 2017-12-07 18:14:19 +01:00
Maciej Suminski ef8f5db024 Handle space character in OPENGL_GAL::BitmapText()
Fixes: lp:1668455
* https://bugs.launchpad.net/kicad/+bug/1668455
2017-12-07 17:58:54 +01:00
Maciej Suminski 602ecf7502 Fix overbar display in OpenGL canvas
Moved the code handling text overbars to a single function
(ProcessOverbars()) to replace similar pieces of code trying to do the
same thing.

Fixes: lp:1735906
* https://bugs.launchpad.net/kicad/+bug/1735906
2017-12-07 17:58:54 +01:00
Seth Hillbrand 86b4a3c3e6 pcbnew: Correct spectra output default filename
Fixes: lp:1736724
* https://bugs.launchpad.net/kicad/+bug/1736724
2017-12-07 09:07:47 -05:00
jean-pierre charras bfc3804115 Minor fixes related to timestamp_t. Move timestamp_t definition to base_struct.h 2017-12-07 13:33:59 +01:00
Henner Zeller 3f57fa5d24 Change time_t in the functions that deal with timestamps to a new typedef timestamp_t (defined as a long).
that makes sure the c++ side and swigged Python side agree on the type, because time_t create problems in Python scripts.
2017-12-07 13:16:33 +01:00
Seth Hillbrand a63e9b863b pcbnew: Fix multiple delete bug
Delete events when using GAL are handled by only one tool handler
instead of ROUTER_TOOL and EDIT_TOOL both deleting items.

Fixes: lp:1715158
* https://bugs.launchpad.net/kicad/+bug/1715158
2017-12-07 09:31:20 +01:00
Seth Hillbrand ee56e21f81 Fix touchpad scrolling with mousewheelPan
Fixes: lp:1735669
* https://bugs.launchpad.net/kicad/+bug/1735669
2017-12-06 19:52:52 -05:00
Simon Richter 0dad728e86 Pass -DBOOST_TEST_DYN_LINK to all parts of test 2017-12-06 19:28:57 -05:00
Simon Richter d075387c24 Link pcb_test_window with /SUBSYSTEM:WINDOWS
This is required for wx apps.
2017-12-06 19:28:32 -05:00
Simon Richter 227afe77c0 Avoid C-style array member init (illegal in C++)
This is not part of the C++ language, and only supported in some compilers.
2017-12-06 19:28:17 -05:00
Simon Richter eaa31dc11b Avoid initialization from non-constexpr
In-class initializers for "static const" class members must be constexpr,
however std::string is only "static const" itself and cannot be used
without compiler extensions.
2017-12-06 19:27:53 -05:00
Simon Richter 2f8e60352b Avoid nonstandard variable length array 2017-12-06 19:27:34 -05:00
Simon Richter abd0d7fb58 Add missing include 2017-12-06 19:26:05 -05:00
Wayne Stambaugh 8af9aa7574 Eeschema: allow for partial schematic loading.
With the implementation of the legacy schematic plugin, any I/O error
when parsing the schematics would prevent the entire schematic from
being loaded.  This change restores (somewhat) the previous behavior
where as long as the root schematic is loaded properly, then all of
the remaining sub-sheet will attempt to load.

Add GetError() method the SCH_PLUGIN object to allow for partial
schematic loading.

Check the error message contents when no exception was caught to warn
the user of any accumulated errors.

Fixes lp:1690644

https://bugs.launchpad.net/kicad/+bug/1690644
2017-12-06 19:11:09 -05:00
Maciej Suminski f44d4d01ea Fix segfault when removing the last corner of a cutout
Fixes: lp:1736147
* https://bugs.launchpad.net/kicad/+bug/1736147
2017-12-06 16:28:03 +01:00
Bernhard Stegmaier 1e88695001 Fix initial sizing of 'Fields' table columns in component table view. 2017-12-06 07:30:44 -05:00
jean-pierre charras cdad02336d fix minor compil warnings 2017-12-05 18:02:53 +01:00
Tomasz Włostowski 000f810161 pcbnew: fixed build error with python-enabled builds 2017-12-05 16:47:44 +01:00
Tomasz Włostowski c50da7e163 poly2tri: fixed some warnings 2017-12-05 14:54:57 +01:00
Tomasz Włostowski 7ad436c7aa pcbnew: now PROGRESS_REPORTER should work in multi-threaded context under Windows... 2017-12-05 14:54:57 +01:00
Tomasz Włostowski 4bf90f9717 WX_PROGRESS_REPORTER: fixed windows build error 2017-12-05 14:54:57 +01:00
Tomasz Włostowski 4facfd846a WX_PROGRESS_REPORTER: fix assert warnings 2017-12-05 14:54:57 +01:00
Tomasz Włostowski f34b86d39e pcbnew: made zone filling algorithm thread-safe.
- moved zone filling algo outside ZONE_CONTAINER class
- const'ified methods that don't need to modify zone's properties
- cleanup: m_FillMode -> enum
2017-12-05 14:54:57 +01:00
Tomasz Włostowski 8df299a6bc pcbnew: Optimized zone filling algorithm: code cleanup 2017-12-05 14:54:57 +01:00
Tomasz Włostowski d1d9e57b86 pcbnew: removed unused files 2017-12-05 14:54:57 +01:00
Tomasz Włostowski fdd5023aee pcbnew: factored out ZONE_FILLER to a separate file 2017-12-05 14:54:57 +01:00
Tomasz Włostowski 56336fdafe POINT_EDITOR: migrate to ZONE_FILLER class 2017-12-05 14:54:57 +01:00
Tomasz Włostowski 83b020d4da PCB_TOOL: added convenience methods for accessing current SELECTION 2017-12-05 14:54:57 +01:00
Tomasz Włostowski fa31d5308a Sample tool for generating board geometyr as polygons 2017-12-05 14:54:57 +01:00
Tomasz Włostowski 58ce865352 pcbnew: made TransformShapeWithClearanceToPolygon virtual 2017-12-05 14:54:57 +01:00
Tomasz Włostowski c6a15f1b9b SHAPE_POLY_SET: fix empty triangulation bug 2017-12-05 14:54:57 +01:00
Tomasz Włostowski dbdf085555 SHAPE_FILE_IO: default constructor outputs to stdout 2017-12-05 14:54:57 +01:00
Tomasz Włostowski 316ddadec1 pcbnew: Optimized zone filling algorithm. 2017-12-05 14:54:57 +01:00
Seth Hillbrand 8b68a1736a Eeschema: Set "edited" flag on newly created sheets
Forces newly created sheet to be considered for saving when created.

Fixes: lp:1736054
* https://bugs.launchpad.net/kicad/+bug/1736054
2017-12-05 08:19:55 -05:00
Seth Hillbrand bdc1fb04be Eeschema: Correct wire/bus/entry connections
Fixes the connection display and dragging behavior of wires,
busses and their entries.

The implemented drag logic is:
-busses and bus-bus entries drag each other when connected at endpoints
-wires and wire-bus entries drag each other when connected at endpoints
-entries do not drag wires or busses when connected to wire middles
-wire-bus entries do not drag busses

The implemented connection logic is:
-bus-bus entries connect busses to busses but not wires
-wire-bus entries connect wires to busses but not wire to wires or
busses to busses
2017-12-04 15:19:46 -05:00
jean-pierre charras cd3122d8cd Refactor hierarch.cpp: remove old dead code and clean current code. 2017-12-04 12:46:13 +01:00
jean-pierre charras c0a539959e Fix a few Coverity warnings 2017-12-04 12:46:11 +01:00
Maciej Suminski 36a54aef21 Component Tree: fixed the sort order 2017-12-04 10:52:05 +01:00
Maciej Suminski 45bf919923 Restoring the previous performance of COMPONENT_TREE widget
It turns out the fastest way to update wxDataViewCtrl is to nuke the
model and rebuild it from scratch rather than via
ItemAdded()/ItemDeleted() update notifications.

Fixes: lp:1734773
* https://bugs.launchpad.net/kicad/+bug/1734773
2017-12-04 10:42:37 +01:00
Seth Hillbrand a240f88785 Eeschema: Remove wire under a placed component
CHANGE: In Eeschema, when placing a component directly over an existing
wire, the wire is automatically removed where it shorted pins.

This helps workflow in Eeschema, allowing one to quickly add components
to existing lines.

Fixes: lp:1678449
* https://bugs.launchpad.net/kicad/+bug/1678449
2017-12-03 18:42:57 -05:00
Nick ?stergaard c74437a44e Remove unused custom cmake target
This target seems to only create empty makefiles, tested on linux. And I
can not find any references to it in any of the current CMakeLists. Lets
remove it.
2017-12-03 18:21:40 -05:00
jean-pierre charras 6be5596620 Symbol Editor: fix a bug in global pin edit: changes were not always taken in account when saving the symbol in lib. 2017-12-03 11:50:50 +01:00
jean-pierre charras 3109343b96 Fix a compil issue with gcc 4.8.4
Fixes: lp:1735909
https://bugs.launchpad.net/kicad/+bug/1735909
2017-12-02 14:22:43 +01:00
jean-pierre charras 3e38b3dca3 Very minor fix in message to avoid a too long sentence 2017-12-02 09:52:02 +01:00
jean-pierre charras 687444b973 update demo 2017-12-02 09:52:02 +01:00
Wayne Stambaugh 694ad93385 Move LIB_PART save code to legacy schematic plugin.
This is the last of the object save/load code that was not moved into
the SCH_LEGACY_PLUGIN object.  All schematic and library I/O is now
performed in the SCH_LEGACY_PLUGIN object and as been removed from the
schematic and library objects.

The old single symbol file format has been replaced with the normal
symbol library file format since there was no difference between them
except the SYMBOL token.  The SYMBOL token was no longer being read
since the introduction of the SCH_LEGACY_PLUGIN symbol library loader.

Update the Doxygen comments in all of the modified files.
2017-12-01 11:49:44 -05:00
Oliver b588c1902a Write "offset" only if non-zero
- Use "at" if all offset dimensions are zero
- Use "offset" otherwise
2017-12-01 16:21:50 +01:00
Oliver 76f5df8a43 Decode "offset" in STEP export tool
- Read "at" as inches
- Read "offset" as mm
2017-12-01 16:21:50 +01:00
Oliver cb97f68e35 CHANGE file format for 3D model offset
- Reverts behaviour of 3e71ed2421
- 3D model offset now explicitly written in mm, using "offset" tag
- Any read "at" tag is converted from inches to mm
- This will not break any 3D model offset when reading files
- It will however render files incompatible with old versions
2017-12-01 16:21:49 +01:00
Seth Hillbrand 76dbbfdf92 Eeschema: Clarify disambiuation of entry types
Replace the disambiguation menu entry for
wire2bus and bus2bus entries with their menu icon.
2017-12-01 08:19:52 +01:00
Seth Hillbrand 069448f20e Eeschema: Automatically manage junctions
CHANGE: eeschema automatically adds and removes junctions
when required by the schematic

Fixes: lp:593888
* https://bugs.launchpad.net/kicad/+bug/593888

Fixes: lp:1482111
* https://bugs.launchpad.net/kicad/+bug/1482111

Fixes: lp:1563153
* https://bugs.launchpad.net/kicad/+bug/1563153

Fixes: lp:1730219
* https://bugs.launchpad.net/kicad/+bug/1730219

Fixes: lp:1491052
* https://bugs.launchpad.net/kicad/+bug/1491052
2017-11-30 10:02:24 -05:00
Seth Hillbrand b5ec5f9a73 Eeschema: Moving BreakSegment into SCH_EDIT_FRAME
BreakSegment now breaks a known segment and BreakSegments
breaks all segments. This allows functions to break a
segment without needing to iterate through the whole list.
2017-11-30 10:02:15 -05:00
Seth Hillbrand e9a297de5b Eeschema: Removing DC dependencies 2017-11-30 10:02:05 -05:00
Seth Hillbrand bf32cc2555 Eeschema: Moving SchematicCleanup to SCH_EDIT_FRAME
SchematicCleanup function moved from SCH_SCREEN to
SCH_EDIT_FRAME to allow access to the undo stack as we
are changing the schematic.
2017-11-30 10:01:58 -05:00
Seth Hillbrand c6632bdded Eeschema: Remove zero-length wires in RemoveBacktracks
RemoveBacktracks call removes zero-length wires as well
2017-11-30 10:01:50 -05:00
Seth Hillbrand 692fecea9a Eeschema: don't cleanup unseen schematics
Changes to the schematic shouldn't be made
where the user isn't looking.  Removing the
cleanup in ERC and netlisting prevents
unintended consequences

CHANGE: ERC and Netlist calls do not modify schematic
2017-11-30 10:01:34 -05:00
Seth Hillbrand 0fd2405c00 Eeschema: Add two utility functions to sch_line
Add IsSameQuandrant and IsParallel functions
2017-11-30 10:01:26 -05:00
Seth Hillbrand d0b2f078fe Eeschema: Unify delete operations
DeleteItemsInList now shares the code for DeleteItem.
SCH_FRAME::DeleteItem removes junctions that are no longer needed.
2017-11-30 10:01:21 -05:00
Seth Hillbrand f8e0099ecc Eeschema: Add 'append' option to undo
Allows eeschema to add elements to previous undo commits,
permitting stacking of changes through multiple calls
2017-11-30 10:01:15 -05:00
Wayne Stambaugh a0c922e493 Fix broken contributor names with non-ASCII characters in about dialog. 2017-11-30 09:57:24 -05:00
Jon Evans 7860b0c4fe Restore "Flip Board" checkbox state when switching canvases
Fixes: lp:1733936
* https://bugs.launchpad.net/kicad/+bug/1733936
2017-11-30 08:44:53 +01:00
Wayne Stambaugh a74bad1630 About dialog fixes.
Remove developer email addresses as requested on the developers mailing
list.

Update source contributor list.

Add place holders for symbol and footprint library contributors.

Remove unnecessary wxT() macros.
2017-11-29 18:06:01 -05:00
Nick Østergaard 4e8e6d4823 Add explaining notes on when to use changelog tags 2017-11-29 17:36:03 +01:00
Maciej Suminski c5254bfec2 Documentation: changed git alias sections name to match the contents 2017-11-29 17:36:03 +01:00
Seth Hillbrand 7b1938d999 Eeschema: IsCorner check for layer match
SCH_LINE can represent a bus, wire or graphic line.  Checking
for the corner needs to distinguish between these types.

Fixes: lp:1635984
* https://bugs.launchpad.net/kicad/+bug/1635984
2017-11-29 08:54:00 -05:00
Jon Evans 8f79f0a66d Add DRC items when reloading board view (Fixes lp:1542420) 2017-11-29 11:40:02 +01:00
Maciej Suminski f3ea34e3c6 Documentation: described 'git changelog' alias
Added 'git changelog' alias description and moved both descriptions to a
single paragraph.
2017-11-29 11:33:07 +01:00
Maciej Suminski f9fd60350f Documentation: added a note about changelog tags 2017-11-29 10:44:47 +01:00
jean-pierre charras 68268973b7 To avoid mistakes between graphic layers for pads, holes and not plated holes, rename 3 GAL_LAYER_ID names:
LAYER_NON_PLATED to LAYER_NON_PLATEDHOLES
LAYER_PADS_HOLES to LAYER_PADS_PLATEDHOLES
LAYER_PADS to LAYER_PADS_TH
and add comments and fix a render issue in gal mode for non plated holes.
2017-11-29 09:48:41 +01:00
jean-pierre charras f992d144d9 Eeschema, LIB_PIN::SetNumber(): ensure spaces are replaced by _ and set modify flag on change.
Fixes: lp:1734187
https://bugs.launchpad.net/kicad/+bug/1734187
2017-11-28 21:02:29 +01:00
jean-pierre charras 0d57bfe71f demo test_xil_95108 update 2017-11-28 21:02:28 +01:00
Wayne Stambaugh 157db6351c Minor HTML message panel improvements.
Change action message color from "darkgreen" to "dark green" as the
former does not exist on windows and results in debug log warnings.

Change the information color from "grey" to "dark grey" for improved
contrast with the white backgrounds.  This may need to configurable
on systems where the HTML window has a dark background color.

Don't translate HTML formatting strings.
2017-11-28 13:14:11 -05:00
Maciej Suminski 769611b79e Do not ask for confirmation to open Properties dialog for a locked footprint
Opening Properties dialog normally does not ask the user to confirm the
action, even for locked items. The exception was a case when there was
nothing selected and Properties dialog was invoked via its hot key -
then SELECTION_TOOL::RequestSelection() tried to get the item under the
cursor, verifying the lock flag.

Fixes: lp:1734537
* https://bugs.launchpad.net/kicad/+bug/1734537
2017-11-28 17:35:46 +01:00
Maciej Suminski db3185723e Drop a locked item after a move operation with a single click
Locked items used to require two clicks to drop an item. This patch
enables dropping with a single click.

Fixes: lp:1716580
* https://bugs.launchpad.net/kicad/+bug/1716580
2017-11-28 15:09:18 +01:00
Maciej Suminski 6105b15b2e Renamed 'Display and Hide' menu to 'Display Options' 2017-11-28 14:46:37 +01:00
Maciej Suminski 6bd700c5dc Larger font for the ruler tool
Fixes: lp:1672040
* https://bugs.launchpad.net/kicad/+bug/1672040
2017-11-28 14:45:52 +01:00
Jon Evans 84ab71f8ec Allow changing LAYER_PADS color and visibility (Fixes lp:1672646) 2017-11-28 11:02:39 +01:00
Jon Evans 0564d3456b Preserve color scheme when switching to legacy (Fixes lp:1670669)
Instead of modifying the colors when switching to legacy canvas,
they will now be preserved and only returned as the "legacy" colors.
2017-11-28 10:47:04 +01:00
Maciej Suminski f36350cb88 Do not relaunch the move tool when it is active
Fixes: lp:1678575
* https://bugs.launchpad.net/kicad/+bug/1678575
2017-11-28 10:46:53 +01:00
Jon Evans 9e6956c9ac Reset tool transitions even when already active (Fixes lp:1733224) 2017-11-28 09:24:29 +01:00
Jon Evans f107545a82 Show message panel info for highlighted net in GAL (Fixes lp:1518626) 2017-11-28 08:16:58 +01:00
Chris Pavlina f576596375 Add "unlock" property to footprint texts
This property decouples the text orientation from the board orientation,
removing the restriction that it face the bottom or right side of the
board.
2017-11-27 18:21:00 -07:00
Oliver 8a32243b89 Slight tweaks to About dialog
- Small wording improvements
- Hyperlinks now show URL
- Remove links to outdated library sources
2017-11-27 18:20:59 -05:00
Wayne Stambaugh 0acdd9f02e Remove obsolete symbol library item load code. 2017-11-27 14:42:22 -05:00
jean-pierre charras 11eb8aa098 Minor changes in EDA_RECT to facilitate python scripts
3 EDA_RECT members were returned by reference by their accessors, now they are returned by value.
It avoid constraints when using them, especially when mixing Python and C++ in scripts.
2017-11-27 19:47:58 +01:00
Maciej Suminski 480b1c2592 Fixed a crash when _cvpcb.kiface is not available when opening cvpcb 2017-11-27 17:11:12 +01:00
Aurabindo J 7aa6f9bd3f Fix symbol library table URI for video demo
Signed-off-by: Aurabindo J <mail@aurabindo.in>
2017-11-27 13:09:59 +01:00
jean-pierre charras 23d1905c55 Update potrace to version 1.15 (that fixes some bugs) 2017-11-27 12:54:18 +01:00
Jon Evans e5847b7953 Gerbview: apply layer colors to GAL after sorting (Fixes lp:1720540) 2017-11-27 08:23:17 +01:00
Wayne Stambaugh b4e9d9b6f7 Symbol rescue dialog improvements.
Make the user prompt an HTML control for improved layout.

Fix some column title sizing issues.  This is not a complete fix but
it seems better than the default sizing done by wxWidgets.

Use symbol terminology instead of part and/or component.

Create trace string source files for a common place for them and their
Doxygen comments.
2017-11-26 18:14:10 -05:00
jean-pierre charras 48a37c2998 Fix minor bug: pcbnew file save: dimensions timestamp updated on every save
Fixes: lp:1733872
https://bugs.launchpad.net/kicad/+bug/1733872
2017-11-26 14:31:15 +01:00
jean-pierre charras 6e728739bb Eeschema: multi part with empty value (~) generates incorrect netlist
Fixes: lp:1734453
https://bugs.launchpad.net/kicad/+bug/1734453
2017-11-26 10:51:14 +01:00
Maciej Suminski a01d81e4b4 Math expression evaluation for text input controls in pcbnew 2017-11-24 21:42:07 +01:00
Maciej Suminski 1f70cc8c5f Expression evaluator: increased output precision 2017-11-24 21:16:13 +01:00
Maciej Suminski 9866196130 Expression evaluator: handle locale setting for decimal separator
NumericEvaluator uses the locale settings to determine the decimal
separator character which will be used when parsing expressions.
2017-11-24 21:16:13 +01:00
Maciej Suminski 78305c1de5 Converted most of pcbnew dialogs to use TEXT_CTRL_EVAL
This patch enables math expression evaluation for most of the text input
controls in pcbnew.

NEW: pcbnew text input controls are able to evaluate simple
mathematical expressions, including distance units (e.g. 5.0+(2*1.2mm)).
2017-11-24 21:16:05 +01:00
Maciej Suminski 1c4056e17a TEXT_CTRL_EVAL: wxTextCtrl wrapper supporting math expression evaluation 2017-11-24 21:15:40 +01:00
Michael Geselbracht b5fc6e45cf Numeric expression evaluator 2017-11-24 21:15:40 +01:00
Maciej Suminski 579d3f478d Renamed WX_UNIT_BINDER to UNIT_BINDER and moved to common/widgets
WX_ prefix should reserved for classes provieded by wxWidgets.
2017-11-24 21:15:40 +01:00
Wayne Stambaugh 84e360dd0d Symbol library table remapping improvements.
Don't back up schematic files unless the user requests a remap.

Back up all files that could be changed by a remap including the
schematic file(s), cache library, project file, and rescue library
files.

Use an HTML control instead of a static text control for improved layout
of the user remap prompt.

Improve the user prompt in the remap dialog to make it clear that changes
will be made to project files.
2017-11-24 11:43:42 -05:00
Maciej Suminski 1d48fd28e3 Generate safe alias names in case of name collisions
Duplicated aliases were given " (copy x)" suffix. There are two
problems: aliases cannot contain spaces and the string was translatable
which could create more issues. Now duplicated aliases receive "_x" suffix.
2017-11-24 17:39:58 +01:00
Julius Schmidt 9df938484a support "disable autopan" with gal canvas
Fixes: lp:1670712
* https://bugs.launchpad.net/kicad/+bug/1670712
2017-11-24 12:20:15 +01:00
jean-pierre charras 37f68f824b minor cosmetic enhancement: menu "Edit Components to Symbol Library Links": add specific icon. 2017-11-24 10:19:23 +01:00
jean-pierre charras cd9d81d720 dialog_edit_components_libid: add a tool to remap orphan components.
Orphan components are components that have a link (lib_id) pointing to a non existent symbol in any loaded libraries.
2017-11-23 19:49:53 +01:00
Miles McCoo d16a5c1d6c Changes to python interface enabling net->pads access.
Added new file connectivity.i to expose CONNECTIVITY_DATA to
python. enables access to d_pads from nets.

Added typemap to board_connected_item.i. since board_connected_item
doesn't use virtual inheritance, when returning a std::list of these
items, the typemap populates the return list with the child
types. This enables python scripts to use the full interface of those
classes (pad, track, zone)

Added typeinfo.i to enable passing a list of KICAD_T values to methods
GetNetItems. This list acts as a query filter. typeinfo.i is included
from pcbnew.i right after kicad.i (instead of in board.i like the
others) typeinfo.h is already being included kicad.i so to ensure the
typemap(s) are properly applied I put them next to each other.

The two new files (typeinfo.i and connectivity.i) were added to
pcbnew's CMakeLists.txt as dependencies.
2017-11-23 17:35:39 +01:00
Wayne Stambaugh b82bd8e0c5 Fix symbol names with illegal library ID characters.
Change the legacy schematic plugin to preserve illegal LIB_ID characters
when load schematics prior to version 4.

Check for illegal LIB_ID symbol names during project rescue.  Rename and
rescue any symbols with illegal LIB_ID names.

Add static methods to LIB_ID object for testing for and fixing names
with illegal characters so there is uniform code for doing so.

Update the Eagle plugin symbol loader to fix symbol names using the new
LIB_ID fix illegal names method.

Fixes lp:1732236

https://bugs.launchpad.net/kicad/+bug/1732236
2017-11-23 10:52:55 -05:00
jean-pierre charras d52fd5769d Show a tooltip if dialog_choose_component has no symbol selected. 2017-11-23 13:24:02 +01:00
jean-pierre charras 1aff677562 Eeschema, getpart.cpp: fix incorrect call to lib browser
(was not called if a symbol was not previously selected)
2017-11-23 12:09:35 +01:00
jean-pierre charras fea9d121b7 dialog_edit_components_libid: UI enhancements, and use viewlib for LIB_ID selection 2017-11-23 10:40:14 +01:00
jean-pierre charras c3015f4671 Fix incorrect LIB_ID exported by viewlib when used as component chooser
(was not to the new format libname::symbol_name)
2017-11-23 10:40:13 +01:00
Maciej Suminski 542040c474 Enable active project flag after importing an Eagle project
When active project flag is disabled, the application buttons are
disabled in the main launcher window. It usually happens when 'kicad'
runs without any project preloaded.
2017-11-23 10:33:40 +01:00
Maciej Suminski 0b66f29b58 Added a git alias to extract changelog (git changelog) 2017-11-23 10:16:20 +01:00
Jose I Romero 3d2b5e3922 Allow items to be moved from all anchor points
A change in commit 5731000135 caused kicad to stop allowing users
to move items like footprints, arcs and lines using anchors other
than the center point.

This was caused by the new code that stores reference points for
clipboard pasting, a call to updateModificationPoint() prevented
some old code paths from executing, which caused the selection to
snap into the cursor, always using the center anchor.

This fix moves the call within the if-cases that need it, and adds
a ClearReferencePoint call when the selection is "dropped" to allow
the user to grab the same selection again from a different anchor.

Fixes: lp:1722512
* https://bugs.launchpad.net/kicad/+bug/1722512
2017-11-23 09:35:39 +01:00
Wayne Stambaugh 78366f8f0b Revert commit bc0306ba as it did not fix the issue. 2017-11-22 15:54:18 -05:00
jean-pierre charras 59e5d3b762 pcbnew: plot dialog: Add advanced X2 features and Create job file options incorrectly saved in .kicad_pcb files (always saved ON)
Fixes: lp:1733876
https://bugs.launchpad.net/kicad/+bug/1733876
2017-11-22 20:27:33 +01:00
Seth Hillbrand faadbea10e Eeschema: Select component connections in drag
Dragging a full line that is connected to a component
now drags the component as part of the block, maintaining
connections.

Fixes: lp:1167714
* https://bugs.launchpad.net/kicad/+bug/1167714
2017-11-22 12:01:58 -05:00
jean-pierre charras 76d08c8bd2 UI fixes and enhancements in dialog_edit_components_libid. 2017-11-22 17:54:17 +01:00
jean-pierre charras 4d0d56fbd7 Fix incorrect handling of the last component in the component list. 2017-11-22 17:54:16 +01:00
Maciej Suminski 6b74f8ef48 Library Editor: fixed an assert after removing libraries with Symbol Library Table dialog 2017-11-22 14:15:51 +01:00
Maciej Suminski d76f7d7bd2 Library Editor: fixed an assert after canceling add library action 2017-11-22 14:03:01 +01:00
Maciej Suminski baec127852 Library Editor: show also empty libraries 2017-11-22 13:40:14 +01:00
Maciej Suminski aaabf8ab78 Library Editor: fixed a crash when creating a new library with existing file 2017-11-22 13:40:14 +01:00
Maciej Suminski 8b0041bf9a Library Editor: progress dialog when loading libraries 2017-11-22 13:40:14 +01:00
Maciej Suminski efaf429a71 class_zone.cpp: changed fabs() to std::abs()
Originally fabs() was invoked on an integer variable and compared with
an integer, so there is no reason to use the floating point variant.
2017-11-22 13:40:14 +01:00
jean-pierre charras 821c02af3c Kicad, menu Browse/Open Local file : shows all files by default, because all kicad files are editable ASCII files. 2017-11-22 09:43:29 +01:00
Wayne Stambaugh bc0306ba99 Fix a possible bug in path normalization code.
The NormalizePath() function always added a trailing separator when
normalizing environment variables.  Now it checks an environment
variable for a trailing separator and only adds one if it doesn't
already exist.

May be a partial fix for:

Fixes lp:1733217

https://bugs.launchpad.net/kicad/+bug/1733217
2017-11-21 19:05:23 -05:00
Maciej Suminski 527c6f0014 Symbol Library Editor refactor
NEW: Component Tree widget in the Symbol Library Editor
NEW: Multiple contexts enable switching between modified components
NEW: Cut/Copy/Paste to transfer components between libraries
NEW: Cut/Copy/Paste for symbol graphical items
CHANGE: Redone menu and toolbar in the Symbol Library Editor
CHANGE: Modified a few icosn to make the user interface look more
    coherent (new icons: import/export part, new library, add library;
    modified: save part)
2017-11-21 23:41:13 +01:00
Maciej Suminski 1625129054 Library Editor: removed duplicated 'Duplicate Block' (doh..) 2017-11-21 23:40:21 +01:00
Maciej Suminski d16e4e23d7 DIALOG_MULTI_OPTIONS: fixed disappearing buttons 2017-11-21 23:18:55 +01:00
Maciej Suminski 28608b1b52 Changed DIALOG_MULTIPLE_OPTIONS to use wxCheckListBox class 2017-11-21 23:18:55 +01:00
Maciej Suminski e25a1feb25 Component Tree: restore expanded nodes after search query is cancelled 2017-11-21 23:18:55 +01:00
Maciej Suminski 4a942a9810 Library Editor: do not change background for the active part/library 2017-11-21 23:18:55 +01:00
Maciej Suminski ed059383c7 Library Editor: removed library actions from the part context menu 2017-11-21 23:18:55 +01:00
Maciej Suminski 0b7ab40288 Updated cut/copy/paste toolbar icons
Removed cut & copy toolbar icons in the schematic editor, as they
were inaccessible. One cannot have an item selected and move the
mouse outside the canvas area due to autopanning.

Added paste icon to the library editor.
2017-11-21 23:18:55 +01:00
Maciej Suminski 256276cf1c Library Editor: copy/cut/paste for graphical items 2017-11-21 23:18:55 +01:00
Maciej Suminski 4fe06656a6 Minor refactor in LIB_EDIT_FRAME::Process_Special_Functions()
Shortened 'screen->m_BlockLocate' to 'block'.
2017-11-21 23:18:55 +01:00
Maciej Suminski 6b87c2d6b1 Library Editor: faster filtering on Windows
Preventing redraw by freezing wxDataViewTreeCtrl significantly
improves the performance.
2017-11-21 23:18:55 +01:00
Maciej Suminski 98c99ff129 DIALOG_SHIM: do not raise invisible windows on wxMSW
Raise() invokes SetFocus() on Windows OS, leading to an API error
(check wxWindowMSW::SetFocus() in wxWidgets/src/msw/window.cpp as
of wxWidgets 3.0.2). In certain cases it leads to a crash.
2017-11-21 23:18:55 +01:00
Maciej Suminski e0e4e5f1be Library Manager: alternative way to manage dynamic fixes
Tree nodes now have an additional field 'InTree' to determine
if the view is aware of its existence. This way, there is no need
to rebuild the data structures from scratch when they need to be
filtered.
2017-11-21 23:18:55 +01:00
Maciej Suminski db4bd0c2db Library Editor: fixed dynamic updates
Duplicate entries were caused by multiple model assignment done by
CMP_TREE_MODEL_ADAPTER_BASE::AttachTo().
2017-11-21 23:18:55 +01:00
Maciej Suminski 891cf783fb Library Editor: Windows fixes 2017-11-21 23:18:55 +01:00
Maciej Suminski 07c104af63 confirm: fixed signed vs unsigned comparison warnings 2017-11-21 23:18:55 +01:00
Maciej Suminski d3d2770093 Library Editor: fixed library manager synchronization to sym-lib-table 2017-11-21 23:18:55 +01:00
Maciej Suminski b229286313 Library Editor: fixed a crash after a library is removed 2017-11-21 23:18:55 +01:00
Maciej Suminski 6400e31d5b Library Editor: more coherent icons for part import/export 2017-11-21 23:18:55 +01:00
Maciej Suminski 8dabcc0125 Fixed signed vs unsigned integer comparisons 2017-11-21 23:18:55 +01:00
Maciej Suminski 658dd362cd Library Manager: clear the deleted part buffer when original file is saved 2017-11-21 23:18:55 +01:00
Maciej Suminski 86f71a9eb4 Library Editor: notify is library is read-only 2017-11-21 23:18:55 +01:00
Maciej Suminski d2d3680774 Library Editor: more descriptive symbol table picker dialog 2017-11-21 23:18:55 +01:00
Maciej Suminski 50dc0ffd9d libedit: Call OnModify after a pin has been moved
Library Editor updates its working copy of the edited part every time
it is modified. If LIB_EDIT_FRAME::PlacePin() calls OnModify() too early,
the working copy does not include the last change.
2017-11-21 23:18:55 +01:00
Maciej Suminski 95754632c2 Library Editor: renamed 'component' to 'part' 2017-11-21 23:18:55 +01:00
Maciej Suminski a4f475c97d Library Editor: icon improvements
- new icons: 'save part', 'add library'
- added a toolbar icon for 'add library'
- made icons on toolbar and menu consistent
2017-11-21 23:18:55 +01:00
Maciej Suminski 44117a7d5e Library Editor: added a hotkey to save a component 2017-11-21 23:18:55 +01:00
Maciej Suminski d900e89382 Library Editor: fixed a bug when multiple components were shown as active 2017-11-21 23:18:55 +01:00
Maciej Suminski ba4515885b Library Editor: select part in the widget component on create/paste/duplicate component 2017-11-21 23:18:55 +01:00
Maciej Suminski 7d45d8b23c Library Editor: made the component tree pane resizable 2017-11-21 23:18:55 +01:00
Maciej Suminski 076633bb5e Library Editor: disable 'save component' for read-only libraries 2017-11-21 23:18:55 +01:00
Maciej Suminski 33242fd111 Library Manager: do not clear modified flag on 'save library as' action 2017-11-21 23:18:55 +01:00
Maciej Suminski df8dc01e8d Library Manager & Editor: comments 2017-11-21 23:18:55 +01:00
Tomasz Włostowski 7fc1e1d53c Library Editor: component cut/copy/paste/duplicate 2017-11-21 23:18:55 +01:00
Maciej Suminski 2ed19668cd Eeschema: removed protos.h
Contained duplicated function declarations with invalid comments.
2017-11-21 23:18:55 +01:00
Maciej Suminski 8f1897adfd minor refactor 2017-11-21 23:18:55 +01:00
Maciej Suminski 3ace948197 block_libedit.cpp: minor refactor
Replaced numerous GetScreen()->m_BlockLocate with a shorter reference.
2017-11-21 23:18:55 +01:00
Tomasz Włostowski 72de4e1857 libedit: field edition should be undoable 2017-11-21 23:18:55 +01:00
Maciej Suminski f2257ccccc Eeschema: created a header for list operations 2017-11-21 23:18:55 +01:00
Maciej Suminski 03c5620efe Library Editor: removed 'load component' hot key 2017-11-21 23:18:55 +01:00
Maciej Suminski 73ec145c33 Library Manager: wrapped risky calls with try..catch 2017-11-21 23:18:55 +01:00
Maciej Suminski fb4875c681 Library Editor: refactored code for creating backup files 2017-11-21 23:18:55 +01:00
Maciej Suminski f6f1dff9d0 Library Editor: enable part buffering for faster save, better 'save as' implementation
Previous 'save as' implementation simply copied the original file, so
the buffered changes were not save.
2017-11-21 23:18:55 +01:00
Maciej Suminski 9fcaa83b7d Library Manager: fixed a memleak in LIB_EDIT_FRAME::OnCreateNewPart() 2017-11-21 23:18:55 +01:00
Maciej Suminski a2b6c8e20a Library Manager: select library when none is set for import/create new part 2017-11-21 23:18:55 +01:00
Maciej Suminski bb83b73f76 Library Editor: mark the current library/part with a different color 2017-11-21 23:18:55 +01:00
Maciej Suminski dfcd42f5ef Library Editor: save libraries added in the editor to sym-lib-tables 2017-11-21 23:18:55 +01:00
Maciej Suminski 26304c54ed Library Editor: fixed update UI event handlers 2017-11-21 23:18:55 +01:00
Maciej Suminski 24ddbbaf25 Library Editor: display a list of libraries to save on close 2017-11-21 23:18:55 +01:00
Maciej Suminski 2c20a10242 Removed friendship in LIB_PART and LIB_ALIAS classes.
It is not required and may a source of unnecessary temptation. There is
no place for friendship in rough C++ world.
2017-11-21 23:18:55 +01:00
Maciej Suminski aa81f5b98d Removed LIB_PART::SetLibId()
To avoid potential incoherency, LIB_ID is defined by setting the part
name and library.
2017-11-21 23:18:55 +01:00
Maciej Suminski 445ac50588 Keep LIB_ID and LIB_PART name/library in sync
Updates LIB_ID::LibItemName field when a part is renamed and LIB_PART
name when a new LIB_ID is set.

Similarly, LIB_ID::LibNickName field is updated when a library set, but
there is no easy way to assign library when LIB_ID::LibNickName is
modified.
2017-11-21 23:18:55 +01:00
Maciej Suminski 4c4f5ae962 Unified way of setting LIB_PART name
LIB_PART name is stored in three places that might be changed
independently:
- the first LIB_ALIAS in m_aliases
- LIB_FIELD with VALUE ID
- m_name wxString field

This is potentially leads to an incoherent LIB_PART state. To prevent
this, all fields are changed using only one method: LIB_PART::SetName().

LIB_PART::m_name has been removed as the same information is available
in two other variables.
2017-11-21 23:18:55 +01:00
Maciej Suminski 3589244ff3 Library Editor field edit dialog takes data from LIB_MANAGER 2017-11-21 23:18:55 +01:00
Maciej Suminski 5c61b61c27 Improved synchronization algorithm for LIB_MANAGER<->COMPONENT_TREE 2017-11-21 23:18:55 +01:00
Maciej Suminski a789b735e9 Library Manager: logic 2017-11-21 23:18:55 +01:00
Maciej Suminski 769c6a8d51 Library Manager: user interface 2017-11-21 23:18:55 +01:00
Maciej Suminski d29e115804 CMP_TREE_MODEL: set LibID for library nodes
LibID needs to be set for libraries as well to be able to tell which
library has been selected in the component tree widget.
2017-11-21 23:18:55 +01:00
Maciej Suminski 19a85a36a3 confirm: Added Select{Single,Multi}Option() to display generic selection dialogs 2017-11-21 23:18:55 +01:00
Maciej Suminski 5d8ed65675 Search Tree icon 2017-11-21 23:18:55 +01:00
Maciej Suminski 0d190639f1 Extracted CMP_TREE_MODEL_ADAPTER_BASE class 2017-11-21 23:18:55 +01:00
Maciej Suminski 3288a5f8b8 Right-click context menus for COMPONENT_TREE widget 2017-11-21 23:18:55 +01:00
Maciej Suminski 42220579df Const modifiers 2017-11-21 23:18:55 +01:00
Maciej Suminski 3bdcdd808b Fix minor warnings 2017-11-21 23:18:55 +01:00
jean-pierre charras 353e91a6f8 Update demos 2017-11-21 21:26:06 +01:00
jean-pierre charras 945325d63a Eeschema: fix incorrect display of pin number in ERC messages and marquers. 2017-11-21 18:39:59 +01:00
jean-pierre charras 656d4d0dff dialog_edit_components_libid: shows orphan components (components with no symbol found in library) 2017-11-21 18:06:37 +01:00
Wayne Stambaugh 8de70f3dd0 Fix symbol library viewer crash.
Handle exception in best zoom method when a symbol could not be loaded
from the symbol library table.  This was triggered by an empty symbol
library table but could be triggered by any exception thrown while
loading the symbol.

Fixes lp:1733111

https://bugs.launchpad.net/kicad/+bug/1733111
2017-11-21 09:30:56 -05:00
Oliver f567d6aef8 Improved LIB_TABLE rendering
- Moved "Active" to first column
- Changed text attributes for disabled rows
2017-11-21 08:19:00 -05:00
Oliver e25a777c41 Add progress dialog when loading symbol libraries
- Provides UX feedback for user
2017-11-21 08:18:51 -05:00
Oliver 8b140186fe Only enumerate active libraries 2017-11-21 08:18:35 -05:00
Oliver f48e868a79 Load "disabled" for footprint libraries 2017-11-21 08:18:26 -05:00
Oliver f85ce87e44 Toggle LIB_TABLE_ROW enabled/disabled in grid editor
- Checkbox editor for enabled / disabled status
2017-11-21 08:18:17 -05:00
Oliver 7cdb78e852 Added "enabled" parameter for LIB_TABLE_ROW
- Read and write from lib-table working
2017-11-21 08:18:06 -05:00
jean-pierre charras f17f604072 Add warning message in dialog_edit_components_libid 2017-11-21 13:09:13 +01:00
jean-pierre charras 8507ea45fc Add a dialog to edit/change components LIB_ID inside a schematic.
This is useful for instance after moving a symbol from a lib to an other lib.
2017-11-21 11:52:40 +01:00
Oliver 3e71ed2421 Changed model offset in file to mm
- Written in mm
- Read as mm if newer than 20171114
- Read as inches if older than 20171114
- Added some documentation
2017-11-20 17:46:16 -05:00
Oliver b80449b069 Fixes for 3D model offset
- Display offset units in 3D preview window (inches or mm)
- Fix offset in 3D renderer
- Fix offset in Raytracing renderer
- Fix offset in STEP export
- Fix offset in VRML export
2017-11-20 17:46:03 -05:00
Maciej Suminski 422b7dd551 Removed declaration of non-existent method (SCH_SHEET::Load()) 2017-11-20 09:16:13 +01:00
Julius Schmidt 375a4e28d6 fix MANDATORY_FIELDS comparisons (need to exclude -1) 2017-11-20 08:48:01 +01:00
Wayne Stambaugh 8b2b1381c4 Fix symbol library table editor plugin type selection bug.
Remove the placeholders for the upcoming s-expression schematic and
symbol library file format plugin type.  The lack of a valid plugin
implementation was causing an undefined plugin type string in the
plugin type selection cell when new rows were added to the table.

Fixes lp:1733116

https://bugs.launchpad.net/kicad/+bug/1733116
2017-11-19 16:53:31 -05:00
Maciej Suminski 33cf082c41 Fixed library path resolution in Spice netlist exporter
SEARCH_STACK is a deprecated method for getting the list of paths where
one could look for a file. Instead it tries the project path and
environmental variables.
2017-11-19 11:38:57 +01:00
jean-pierre charras 31083a4060 Better menu item label and tool tip.
Modify incorrect menu label.

Fixes: lp:1733113
https://bugs.launchpad.net/kicad/+bug/1733113
2017-11-19 10:49:28 +01:00
jean-pierre charras 06d0e593ba dialog_sym_lib_table: gives an existing plugin type when creating a new entry in symbol library table
It avoids a strange (for an user) error message on creation.
2017-11-19 10:04:38 +01:00
Maciej Suminski 4c623daa1d Added 'Browse Library' button to Symbol Library Table dialog
NEW: File browser for the Symbol Library Table dialog
2017-11-18 20:05:54 +01:00
Maciej Suminski 759359f602 Moved path normalization functions to a separate file
Normalizing paths to environmental variables might be useful in
many places, therefore it is better to keep them accessible.
2017-11-18 20:05:08 +01:00
Wayne Stambaugh 753f24aaaa Fix Eagle project import bug on Linux.
There is a significant difference in the behavior of wxFileDialog
between Windows and Linux (GTK+).  On windows, wxFileDialog will
return the path chosen even if no file is selected.  On Linux,
wxFileDialog returns the default path when no file is selected.  This
caused the destination path to be the same path as the source which
was causing the issue.  Use wxDirDialog instead so the selected path
is returned.

Fixes lp:1732759

https://bugs.launchpad.net/kicad/+bug/1732759
2017-11-18 12:28:59 -05:00
Henner Zeller ff5ee05def Fix Python scripting bug when saving board to file. 2017-11-18 11:00:24 -05:00
Wayne Stambaugh a0473614b5 Remove all schematic object load and save code.
All of the schematic object load and save code is implemented in the
legacy schematic plugin so it is no longer required.

Remove unused file with old schematic file loader.

Doxygen comment cleaning.
2017-11-18 08:53:13 -05:00
Wayne Stambaugh e97ce6ee4f Use legacy schematic plugin for loading schematics in all code paths.
Use the legacy plugin schematic loader in the sheet edit and append
schematic code paths.

Check for fully qualified LIB_ID objects (must have library nickname)
when loading existing schematics when edit sheets.

Rewrite append schematic feature to handle import issues rather than
change the name and file name of all of the sheets in the imported
schematic.  This includes the following:
- Load the schematic into a temporary SCH_SHEET object.
- Make sure the imported schematic does not cause any hierarchy
  recursion issues.
- Verify the imported schematic uses fully qualified #LIB_ID objects
  (symbol library table).
- Check to see if any symbol libraries need to be added to the current
  project's symbol library table.  This includes:
- Check if the symbol library already exists in the project or global
  symbol library table.
- Convert symbol library URLS that use the ${KIPRJMOD} environment
  variable to absolute paths.  ${KIPRJMOD} will not be the same for
  this project.
- Check for duplicate symbol library nicknames and change the new symbol
  library nickname to prevent library name clashes.
- Update all schematic symbol LIB_ID object library nicknames when the
  library nickname was changed to prevent clashes.
- Check for duplicate sheet names which is illegal and automatically
  rename any duplicate sheets in the imported schematic.
- Clear all of the annotation in the imported schematic to prevent
  clashes.
- Append the objects from the temporary sheet to the current page.
- Replace any duplicate time stamps.
- Refresh the symbol library links.

Add support code to SCH_SCREEN object to assist with schematic import.

Doxygen comment cleaning.

Fixes lp:1731760

https://bugs.launchpad.net/kicad/+bug/1731760
2017-11-18 08:10:58 -05:00
Seth Hillbrand b6884d3423 Eeschema: Improve wire merging
CHANGED: wires now merge along the full length rather than just
endpoints.  Wires also merge at oblique angles when aligned.
2017-11-17 17:44:18 +01:00
jean-pierre charras 10de79260d Fix an assert when starting the 3D viewer in Debug mode (Linux only)
Fixes: lp:1731344
https://bugs.launchpad.net/kicad/+bug/1731344
2017-11-17 10:20:55 +01:00
Seth Hillbrand d24c88f254 Eeschema: Show abbreviated units
CHANGED: Edit Line Style shows "in" and "mm" instead of full word
2017-11-17 08:20:00 +01:00
jean-pierre charras a3c4b508f8 Fix a very minor issue in eeschema when plotting in SVG format. 2017-11-16 19:49:07 +01:00
jean-pierre charras 00bb00016b Fix a forgotten change. 2017-11-16 16:22:12 +01:00
jean-pierre charras bdc6a5950b rename plot_common.h to class_plotter.h, a better name, consistent with other class definitions. 2017-11-16 15:53:30 +01:00
jean-pierre charras 2ec3a46984 Add support of DRAWSEGMENT S_POLYGON shape to plot functions.
Fixes: lp:1732570
https://bugs.launchpad.net/kicad/+bug/1732570
2017-11-16 12:09:24 +01:00
jean-pierre charras 25f9c6e4f9 Incorrect default value (not saved in file) of DRAWSEGMENT width, for the S_POLYGON shape.
The value of the width is now always saved to avoid this kind of issue.

Also Fixes: lp:173257
2017-11-16 09:38:26 +01:00
Seth Hillbrand af8b71ac87 Eeschema: Fix bug in block selector
The block selector needs to add all connected items
to the block.  Lines marked skip should not affect
the next item tested.
2017-11-16 08:30:39 +01:00
Tomasz Włostowski 41f9c19b7d pcbnew: editing outlines now works in flipped view mode
Fixes: lp:1731978
* https://bugs.launchpad.net/kicad/+bug/1731978
2017-11-16 01:05:43 +01:00
Tomasz Włostowski b76a6210c5 pcbnew: fixed stuck cursor when ForceCursorPosition() is active and cursor is moved by keyboard arrows
Fixes: lp:1729301
* https://bugs.launchpad.net/kicad/+bug/1729301
2017-11-16 00:43:23 +01:00
jean-pierre charras df6d005fd3 A few cosmetic enhancements in dialog_edit_line_style 2017-11-15 20:28:44 +01:00
jean-pierre charras f68d829f54 very minor I18n fix 2017-11-15 20:28:44 +01:00
Tomasz Włostowski 00ad8f24a0 pcbnew: Minor changes in CONNECTIVITY_DATA interface:
- renamed connectivity.[h|cpp] to connectivity_data [.h|.cpp] so that the file name matches the main class name.
- GetNetItems() now returns a vector instead of a list
2017-11-15 18:34:08 +01:00
Wayne Stambaugh 41a9007b6d Fix assertion in symbol library remap dialog.
Do not attempt to normalize environment variables that are not valid
paths, paths that do not exist, or paths that the user does not have
read access to.

Fixes lp:1731655

https://bugs.launchpad.net/kicad/+bug/1731655
2017-11-15 12:24:51 -05:00
Baranovskiy Konstantin 370c3b068b Remove inappropriate tooltip from Remove button of Equ files dialog of CvPcb. 2017-11-15 09:50:31 -05:00
jean-pierre charras eaaa85c2c0 Make a few sentences more easy to translate. 2017-11-15 15:38:45 +01:00
jean-pierre charras 01871c5694 Update AUTHORS.txt list 2017-11-15 14:08:47 +01:00
jean-pierre charras 0517f78085 eeschema: store line style using a more readable format 2017-11-15 14:08:27 +01:00
Seth Hillbrand 634fc80916 Eeschema: Update line syle colorbox
Line style colorbox is updated to follow Kicad colorbox
convention.  The alpha channel is also forced to opaque.
2017-11-15 08:10:51 +01:00
Seth Hillbrand 13ef1a911f Eeschema: Adding dashed line support to DXF plot
NEW: Dashed, dotted and dash-dot line support to DXF plot
in eeschema.
2017-11-15 08:10:51 +01:00
Seth Hillbrand 7c0a7f9f7b Adds plot functionality to Eeschema line formats
Dotted, dashed and dash-dot lines are provided in
HPGL, PDF, PS and SVG plot outputs along with line
width and color formatting.

DXF format does not currently provide any dashed
line functionality

A bug in HPGL plotted is corrected.  Previous HPGL
dashed line commands were incorrect, plotting all
lines as solid.
2017-11-15 08:10:51 +01:00
Seth Hillbrand b576189a00 Eeschema: Adding line styling options
NEW: Adds support in eeschema for changing the default line style,
width and color on a case-by-case basis.

CHANGED: "Wire" lines now optionally include data on the line style,
width and color if they differ from the default.

Fixes: lp:594059
* https://bugs.launchpad.net/kicad/+bug/594059

Fixes: lp:1405026
* https://bugs.launchpad.net/kicad/+bug/1405026
2017-11-15 08:10:51 +01:00
jean-pierre charras a8e98ade49 Fix a very minor coding style issue 2017-11-15 08:10:48 +01:00
jean-pierre charras a6554861dd Update demos to use sym-lib-table and recent libraries 2017-11-14 21:27:18 +01:00
jean-pierre charras c1879b269f Update demos to use sym-lib-table and recent libraries 2017-11-14 19:46:21 +01:00
jean-pierre charras 419c6e198e Update interf_u demo to use latest libraries and the new sym-lib-table 2017-11-14 17:16:23 +01:00
Kevin Cozens d504a8bdd0 Fix for patches allowing value/reference text rotation in multiples of 90 deg.
The wrong version of the patches had been applied. This commit applies some
code changes that had gotten lost.

    See lp:613616 (https://bugs.launchpad.net/kicad/+bug/613616).
2017-11-14 08:44:26 -05:00
Wayne Stambaugh d98fc85a83 Improve assert message in symbol table remap dialog.
Fixes lp:1731655

https://bugs.launchpad.net/kicad/+bug/1731655
2017-11-13 14:17:49 -05:00
Maurice 5e5abc5241 Pcbnew: make placing a grid origin enable the save command.
Fixes lp:1730371

https://bugs.launchpad.net/kicad/+bug/1730371
2017-11-13 12:00:02 -05:00
jean-pierre charras f7c0562c8b Gerbview: refinements in D_Code display.
Remove duplicate code between legacy and Gal canvas to calculate D_Code id draw parameters.
2017-11-13 11:30:23 +01:00
jean-pierre charras e14a1656db Add comments. Gerbview: in legacy mode, do not display D_Code id text when it is too small to be readable. 2017-11-13 09:11:54 +01:00
Jon Evans cabc92bd48 Fix aperture macro and arc bounding boxes (Fixes lp:1730249) 2017-11-13 08:17:43 +01:00
jean-pierre charras 2337b83ba6 richio.h, class LINE_READER: prefix variable member names by "m_", like in other classes in Kicad. 2017-11-12 18:29:56 +01:00
Wayne Stambaugh 7e7d3004fb Fix UI string typo in rescue dialog error message. 2017-11-12 11:38:31 -05:00
Maciej Suminski 75d9a18fc0 VIEW_LIB_FRAME: catch exceptions for invalid libraries 2017-11-12 14:36:20 +01:00
Baranovskiy Konstantin a4b962e7d9 Fix wildcard for Eagle XML files. 2017-11-12 07:40:24 -05:00
Wayne Stambaugh 620251de69 Fix UI string typo. 2017-11-12 07:38:39 -05:00
Jon Evans a1acf705e8 Fix aperture macro hit testing (partial fix of lp:1730249)
Also update various things in class_aperture_macro.cpp to take a const
parent argument so that it is callable from within GERBER_DRAW_ITEM
2017-11-12 10:22:18 +01:00
Wayne Stambaugh f3908bd87c Revert premature commit of 17ab319b, "Fixes for 3D model offset".
This reverts commit 17ab319b99.
2017-11-11 20:04:46 -05:00
Wayne Stambaugh 652b969193 GTK+ file dialog wildcard improvements.
The GTK+ file dialog is case sensitive however it does support regular
expressions.  Most of the file dialog wildcards are lower case so only
files with the lower case extensions will show up in the file dialog.
This code adds a method to convert file extensions of any case to the
appropriate (sch -> [sS][cC][hH]) regular expression on GTK+ builds so
all file extension case combinations will show up in the file dialog.

A note to developers: make sure to add a file extension when setting
when setting the default file argument.  If you do don't set an
extension, the GTK+ file dialog will happily append the regular
expression as the file extension which is surely not what you want.

There are still a few known places (mostly gerbview) where there are
some complex wildcard code that has not been converted.

Fixes lp:1720542

https://bugs.launchpad.net/kicad/+bug/1720542
2017-11-11 19:32:26 -05:00
Maciej Suminski 61578f9da8 SYMBOL_LIB_TABLE: replaced wxASSERTs with wxCHECKs
The replaced wxASSERTs notify the developer that a variable is a
null pointer, but continue code execution and lead to a crash.
Instead, they are changed to wxCHECKs, that give the same type
of notification, but return from a function before the crash
happens.
2017-11-12 01:10:11 +01:00
Oliver 154ed5db68 Change default 3D model repository
- New location is kicad-packages3d
2017-11-11 15:23:57 -05:00
Oliver 17ab319b99 Fixes for 3D model offset
- Display offset units in 3D preview window (inches or mm)
- Fix offset in 3D renderer
- Fix offset in Raytracing renderer
- Fix offset in STEP export
- Fix offset in VRML export
2017-11-11 15:08:08 -05:00
Kevin Cozens d0a860ed8f Don't change angle when editing footprint value or reference text
Added 180 degrees to list of selection angles and entry of angles
from -180 to 180 in Footprint Text Properties dialog.

Fixes lp:613616

https://bugs.launchpad.net/kicad/+bug/613616
2017-11-11 14:38:05 -05:00
Kevin Cozens f71d3fe7b6 Allow value and reference text to be rotated by 90, 180, and 270 degrees. 2017-11-11 14:13:46 -05:00
Baranovskiy Konstantin 1412296398 Fix field align settings in dialogs of Eeschema. 2017-11-11 19:48:28 +01:00
Seth Hillbrand 0017c701c7 Eeschema: Draw junctions last
Places junctions on the schematic after all other items
to avoid visual clutter when a pin overlaps a junction.

Fixes lp:1582343

https://bugs.launchpad.net/kicad/+bug/1582343
2017-11-11 13:41:52 -05:00
Wayne Stambaugh 5181c0ac75 Minor symbol library table edit dialog fix.
A copy and paste error was causing to footprint library table file name
and path to be shown in the symbol library table edit dialog.  Factor
out code in PROJECT::FootprintLibTblName() to PROJECT::libTableName()
to handle both symbol and footprint library table names and create a
new PROJECT::SymbolLibTableName() method to fix the path and file name
in the symbol library table edit dialog.
2017-11-11 10:33:06 -05:00
jean-pierre charras 4af85239ba Internationalize dialog_symbol_remap_base 2017-11-11 11:35:06 +01:00
jean-pierre charras 661bab7220 Fix crash when appending a board in pcbnew.
Fixes: lp:1731539
https://bugs.launchpad.net/kicad/+bug/1731539
2017-11-11 09:09:24 +01:00
jean-pierre charras 9723b0d844 Fix a few minor coverity warnings (not initialized members) 2017-11-11 07:25:00 +01:00
Wayne Stambaugh 9f0b2e4bb0 Fix project symbol library table load bug in Eagle plugin.
Remove functional code inadvertently added to wxASSERT macro in symbol
library table loader.
2017-11-10 17:55:37 -05:00
Maciej Suminski c9b791ca2a GenCAD exporter: added origin settings
Added an option to the exporter dialog allowing the user to choose
either the absolute or the auxiliary origin. Also, the ORIGIN field in
the exported file can be set to contain the information about the origin
point or set to (0, 0) for compatibility with other CAD tools.
2017-11-10 15:18:59 +01:00
Baranovskiy Konstantin 0b34d09bc0 Fix double "choose to" in symbol remap dialog. 2017-11-10 07:31:27 -05:00
Wayne Stambaugh 610ff7485f Fix more bugs in the schematic symbol rescuer.
In the rare case when something goes wrong with the symbol library
table remapping, do not attempt to rescue symbols that are neither
in the cache nor in any of the libraries.

The legacy rescue library code overwrote the existing library so
previous rescues would get lost.  If the rescue library exists,
copy it's contents into the new rescue library before adding the
new rescued symbols so no previously rescued symbols are lost.

Fix a null pointer bug in the symbol library editor when no symbol
is loaded.

Set LIB_ID item name to name passed to LIB_PART ctor.

Copy LIB_ID in LIB_PART copy ctor.
2017-11-09 21:24:43 -05:00
Wayne Stambaugh 6d63873128 Fix a bug in the schematic symbol rescuer.
If a library disappears all together or a symbol name is changed, force
the rescuer to add it to the rescue library.  The current rescue code
only looked for differences if they existed between libraries.  This was
causing symbols to be unceremoniously dumped from the symbol library
table remapping.

Don't search for cache rescue candidates in the symbol library table
rescuer.
2017-11-09 18:50:23 -05:00
Wayne Stambaugh a2e7e7aed4 Clear symbol library list from project file after remapping.
The old symbol library list save/load code does not get called in the
schematic project file configuration code.  Use the LibNamesAndPaths
static function from the PART_LIBS object.

Bump schematic file version from 3 to 4 which represents the switch to
the library table symbol linking which is incompatible with all previous
versions.

Refresh the schematic after running remapping dialog manually.
2017-11-09 18:50:23 -05:00
Wayne Stambaugh 44d81e4005 Minor fixes broken by symbol library table changes.
Add missing CMP_TREE_NODE_LIB_ID type that was inadvertently deleted by
the symbol library table implementation that broke the preselected symbol
tree expansion and highlighting.

Changed CMP_TREE_NODE_LIB_ID type from ALIAS to LIBID for more accurate
description.

Use LIB_ID in COMPONENT_SELECTION object instead of strings of the
library and symbol names.
2017-11-09 18:50:22 -05:00
Wayne Stambaugh 168bf5e4b0 Symbol library archive bug fixes.
Move FindAlias() inside a try/catch block as is can throw an exception.

Don't abort adding symbols to library when a symbol cannot be found in
the symbol library table or the cache library.  Instead, queue up error
messages and display them after attempting to add all of the symbols.

Always save the library file even if some of the symbols could not be
archived.

Catch IO_ERRORs in SCH_COMPONENT resolve to prevent unhandled exceptions
further up the stack.
2017-11-09 18:50:22 -05:00
Wayne Stambaugh 56d73f837d Fix build error caused by rebasing against commit 5eb56dd8. 2017-11-09 18:50:21 -05:00
Wayne Stambaugh 8fd89c881d Final symbol library table changes before merge.
Remove all symbol libraries from the project file after remapping to
prevent symbols that should be loaded from the cache being loaded from
a library further up the search order.  Save the project file to clear
all of the libraries so they never get reloaded again.

Remove the symbol library management dialog and menu entries.

Rename the symbol library table dialog menu entry.

Remove all symbol libraries from default project file to prevent clashes
with the cache library.

Fix illegal symbol naming in Eagle plugin.
2017-11-09 18:50:21 -05:00
Wayne Stambaugh 8d995f48de Update Eagle plugin to use symbol library table. 2017-11-09 18:50:21 -05:00
Wayne Stambaugh c1f7c1778a Revise symbol rescuer to support symbol library table.
Refactor rescue objects so that they can support derivation.

Factor out legacy rescuer code to perform legacy project rescues.

Create new symbol library table rescuer for rescuing symbol library table
based projects.

Perform the correct rescue type on project load.

Add symbol library table remapping support to the tools menu for run on
demand as applicable.

Add flag to SCH_SCREENS::UpdateSymbolLinks() to allow forcing the symbol
link updates when the library modification hash has not changed.
2017-11-09 18:50:20 -05:00
Wayne Stambaugh 36f6d4a1f4 Convert symbol library editor over to use symbol library table.
Simplify some of the library editing code.  There have been a few minor
changes in the behavior of the editor.  If the current symbol is deleted
from the library, the next symbol in the library is not loaded.  The
deleted symbol is cleared and the current symbol is empty.

Change component to symbol to align with the preferred terminology
discussed on the developer's mailing list.

Add separate update UI event for save library as to enable the menu entry
whenever a library is selected.

Change the select symbol list dialog to a single column using the LIB_ID
format LIB_NICKNAME:LIB_ITEM_NAME so that the selection can be parsed by
LIB_ID.

Add method to expand URI to LIB_TABLE_BASE.

Override wxApp::OnExceptionInMainLoop() in debug builds to make debugging
easier when an unhandled exception occurs in a wxUpdateUIEvent handler.

Change SCH_SCREENS::HasNoFullyDefinedLibIds() to return false when the
schematic has no symbols to prevent the remapping dialog from being run.

Use SCH_COMPONENT part reference when creating netlist rather than looking
up the library symbol.
2017-11-09 18:50:20 -05:00
Wayne Stambaugh 329fc18732 Convert component chooser dialog over to use symbol library table.
Change all of the component tree helper objects to use LIB_IDs instead of
LIB_ALIAS pointers.  LIB_ALIAS pointers are dangerous to use because they
can be deleted in the symbol library editor while the component chooser
dialog has copies of them.  With LIB_IDs, the LIB_ALIAS pointer is found
on demand and can be guaranteed to be valid.

Update the chooser dialog to load the symbol library table instead of the
libraries defined in the project file and return a LIB_ID instead of a
LIB_ALIAS pointer.

Modify SCH_BASE_FRAME::SelectComponentFromLibrary() to handle the LIB_IDs
returned from the component chooser dialog.
2017-11-09 18:50:18 -05:00
Wayne Stambaugh 81e8d8fd89 Symbol library table remapping fixes.
Use GetPath() instead of GetFullPath() when initializing environment
variable table entries KICAD_SYMBOL_DIR and KICAD_PTEMPALTE due to
unexpected trailing path separator which was causing find libraries
by URI to fail.

Don't create a project symbol library table when there are no libraries
not found in the global symbol library table.

Don't add non-existent libraries to project symbol library table.

Clear symbol library table when loading a new schematic.

Minor remapping status message improvements.
2017-11-09 18:50:18 -05:00
Wayne Stambaugh 0cf2df51c6 Convert symbol library viewer over to symbol library table.
Remove all instances of PART_LIBS and replace them with SYMBOL_LIB_TABLE
except for the CMP_TREE_MODEL_ADAPTER which requires updating as well.

Return the selected symbol using the LIB_NICKNAME:SYMBOL_NAME format when
viewer is launched as modal.

Add code to SYMBOL_LIB_TABLE object to allow enumerating symbol library
power symbols only.

Add a non-const version of LIB_TABLE::findRow().

Remove redundant information from Doxygen comments.
2017-11-09 18:50:17 -05:00
Wayne Stambaugh 96c3d5ff21 Enable symbol library table remapping.
Check the if the schematic being loaded has been remapped (no symbol
library table nicknames defined) and remap accordingly.

Fix issues when resolving the library symbol links in the schematic
symbols.

Add cache library fallback when resolving symbols that cannot be
remapped.

Add remap complete message to remap dialog.

Add HasLibrary() helper to LIB_TABLE_BASE.

Fix issues when loading library symbols using symbol library table.

Add hashing function to symbol library table.

Improve the symbol panel message to warn user when cache library is
used to resolve symbol.
2017-11-09 18:50:17 -05:00
Maciej Suminski 636298b5dc Fixed 2 warnings in eeschema/sch_plugin.cpp
- removed an implicit conversion of NULL to boolean false
- removed an unused variant of not_implemented() function
2017-11-10 00:33:26 +01:00
Maciej Suminski d8f4e35c9a Minor cleanups and improvements
Just a set of small code cleanups to fix a bunch of warnings
and remove dead code.
Other than that the 'build:' commits avoid/remove/fix the
installation of certain files:
 - it doesn't make much sense to install the INSTALL.txt
 - *.bat scripts shouldn't be installed on UNIX systems
 - use CMAKE_INSTALL_* consistently to install files in the
   correct places
2017-11-10 00:19:14 +01:00
Marvin Schmidt 5e013e916b Use std::remove_pointer instead of own implementation (NFC) 2017-11-09 19:52:18 +01:00
Marvin Schmidt 273437641c Remove some else-after-return's 2017-11-09 19:52:18 +01:00
Marvin Schmidt c36d666dde Remove duplicate #include 2017-11-09 19:52:18 +01:00
Marvin Schmidt 69974b73db Remove some extra semicolons 2017-11-09 19:52:18 +01:00
Marvin Schmidt 20f3cdaaea Remove orphaned code files 2017-11-09 19:52:18 +01:00
Marvin Schmidt a155a5c780 Remove some dead code 2017-11-09 19:52:17 +01:00
Marvin Schmidt 7daaa3e9d9 Remove unused #define 2017-11-09 19:52:17 +01:00
Marvin Schmidt 2b78183bb4 Fix a typo 2017-11-09 19:52:17 +01:00
Marvin Schmidt c21a2a8a55 build: Don't install *.bat scripts on Unix 2017-11-09 19:52:17 +01:00
Marvin Schmidt 8a62aeb18d build: Remove dead code 2017-11-09 19:52:17 +01:00
Marvin Schmidt f9516cb48c build: Use CMAKE_INSTALL_DATADIR 2017-11-09 19:52:17 +01:00
Marvin Schmidt b6c3d4eb32 build: Don't install INSTALL.txt 2017-11-09 19:52:17 +01:00
jean-pierre charras 87d06e5269 Very minor fixes in some sentences (remove trailing space and add missing period). 2017-11-09 14:34:16 +01:00
Adam Wolf 558150c112 Added patch for wxwidgets for macOS High Sierra (10.13) 2017-11-09 07:58:05 -05:00
Maciej Suminski cd21218c34 Fixed a memleak in libedit undo buffer, minor code cleanup
In LIB_EDIT_FRAME::GetComponentFrom{Undo,Redo}List() methods, the
PICKED_ITEMS_LIST object which was retrieved from undo/redo list has not
been destroyed.

Rewritten SCH_SCREEN::ClearUndoORRedoList() to be easier to read.

Minor whitespace formatting.
2017-11-08 17:32:59 +01:00
jean-pierre charras e985fc18e0 Fix a corner case in richio.cpp that creates a memory allocation overrun (allocate more space).
Also allows more space in memory allocation to read strings.

Could fix this bug:
Fixes: lp:1730861
https://bugs.launchpad.net/kicad/+bug/1730861
2017-11-08 13:11:51 +01:00
Maciej Suminski 40129d2244 Fixed cursor freeze after canceling a tool with cursor over a drag point
Fixes: lp:1716702
* https://bugs.launchpad.net/kicad/+bug/1716702
2017-11-08 11:41:45 +01:00
jean-pierre charras 7d24a576e4 Avoid drawing into a non valid gl context when closing the DIALOG_PAD_PROPERTIES dialog
Fixes: lp:1729843
https://bugs.launchpad.net/kicad/+bug/
2017-11-07 18:33:53 +01:00
Oliver c932e4af1b Added IGES replacement option
- If no STEP substitute is found, look for IGES
2017-11-07 08:34:38 -05:00
jean-pierre charras aefa0bf3b4 Avoid 0 sized grid in dialog_pad_properties.cpp 2017-11-07 10:18:13 +01:00
jean-pierre charras 81ad3366f5 Avoid division by 0 in GAL::GetGridPoint( const VECTOR2D& aPoint ) 2017-11-07 09:45:03 +01:00
jean-pierre charras 1c356899ab Fix wxWidget warning in panel_prev_3d_base.cpp dialog 2017-11-07 09:43:27 +01:00
Oliver 30455092c8 Replace WRL files with STEP equivalent
- Use simple filename matching
- If a STEP file is found, use that instead
- Similar behaviour to the infamous StepUp tool

Fixes lp:1710796

https://bugs.launchpad.net/kicad/+bug/1710796
2017-11-06 18:41:40 -05:00
Eldar Khayrullin 9df4ae65ea pcad2kicadpcb: import solder mask for Mounting Holes
Fixes: lp:1730173
* https://bugs.launchpad.net/kicad/+bug/1730173
2017-11-06 10:23:23 +01:00
jean-pierre charras bf013f5b63 Fix minoe compil warnings (missing override) 2017-11-06 10:23:00 +01:00
Marvin Schmidt ad9916e2cc box2: Remove wrong use of typename keyword 2017-11-05 23:03:52 +01:00
Marvin Schmidt a6ca44d9f0 vector2d: Fix traits usage and use std::numeric_limits 2017-11-05 23:03:52 +01:00
Marvin Schmidt fc08c58059 vector2d: Remove duplicate #include 2017-11-05 23:03:52 +01:00
Tomasz Włostowski 1959af1ad1 refactoring: forgot to add VIEW/VIEW_CONTROLS initialization in gerber, causig a crash. Fixing. 2017-11-05 22:09:56 +01:00
jean-pierre charras 78fa31315c Better Dxf import dialog:
Better look.
Better management of user offset settings (used only in Legacy mode).
The default width of lines and circle can be set.
2017-11-05 15:20:34 +01:00
Wayne Stambaugh d5290bdfe0 Fix malformed symbol libraries when importing Eagle schematics.
KiCad library symbol text objects cannot contain carriage returns and/or
line feeds which isn't the case with Eagle symbol libraries.  Otherwise,
the library file will be corrupt when it is saved.  Fixing this in the
legacy plugin would break the current file format so just replace them
with underscores.  Ideally these text objects should be broken into
multiple text objects but the current plugin design doesn't support
this.
2017-11-04 21:36:47 -04:00
Tomasz Włostowski dcb75a9b24 qa/pcb_test_window: fix build with GITHUB_PLUGIN disabled 2017-11-05 01:18:50 +01:00
Maciej Suminski ecaf1789c7 Fix builds without Github plugin enabled 2017-11-05 00:13:24 +01:00
Tomasz Włostowski a67d24a34e revert link-time plugin registration causing plugins to be incorrectly enumerated 2017-11-04 21:00:42 +01:00
Maciej Suminski f5c561e281 Fix build error due to missing optional::value_or() 2017-11-04 11:29:55 +01:00
Maciej Suminski 6cc1f66dfd Added missing include directories to qa 2017-11-04 11:11:04 +01:00
Tomasz Włostowski 9932ff32ae refactoring: wrapped boost::optional in OPT<> class for the purpose of easier transition to C++17 in the future 2017-11-03 23:59:02 +01:00
Tomasz Włostowski 3292d622c1 qa: added simple GAL+Tool Framework test program 2017-11-03 20:02:06 +01:00
Tomasz Włostowski b945d2a708 cleanup: replace CLASS_MIRE with CLASS_PCB_TARGET for naming clarity 2017-11-03 20:02:06 +01:00
Tomasz Włostowski 3170eba801 refactoring: implemented SELECTION_TOOL's own GetCollectorsGuide() to avoid dependency on PCB_BASE_FRAME 2017-11-03 20:02:06 +01:00
Tomasz Włostowski c9817df9db refactoring: implemented BOARD-specific view Add()/Remove()/Update() methods in PCB_VIEW, moved to libpcbcommon 2017-11-03 20:02:06 +01:00
Tomasz Włostowski 0245912c34 refactoring: split BOARD_ITEM::SwapData to use polymorphic per-item methods 2017-11-03 20:02:06 +01:00
Tomasz Włostowski 26f862a9d0 refactoring: remove PNS router dependency on PCB_EDIT_FRAME 2017-11-03 20:02:06 +01:00
Tomasz Włostowski d0ef881a53 refactoring: make BOARD_COMMIT independent from pcbnew 2017-11-03 20:02:06 +01:00
Tomasz Włostowski ec61a00371 refactoring: remove link-time dependency between PCB_BASE_FRAME and EDA_3D_VIEWER 2017-11-03 20:02:06 +01:00
Tomasz Włostowski 781008bfa5 refactoring: allow to run TOOL_MANAGER and SELECTION_TOOL without a host wxFrame 2017-11-03 20:02:06 +01:00
Tomasz Włostowski 06f3b35255 refactoring: moved BOARD_COMMIT, PCB_GENERAL_SETTINGS and TransformShapeWithClearanceToPolygon() to libpcbcommon 2017-11-03 20:02:06 +01:00
Tomasz Włostowski 7a44ab914d refactoring: replaced manual plugin registration with link-time plugin binding 2017-11-03 20:02:06 +01:00
Tomasz Włostowski 8a09a1d329 refactoring: derive PCB-specific PCB_VIEW from VIEW with the intention of moving PCB_EDIT_FRAME entries used by the tools (e.g. GetActiveLayer) there 2017-11-03 20:02:06 +01:00
Tomasz Włostowski 81d1e17f02 refactoring: renamed pcbstruct.h to pcb_display_options.h, DISPLAY_OPTIONS->PCB_DISPLAY_OPTIONS 2017-11-03 20:02:06 +01:00
Tomasz Włostowski 90ab5860dc refactoring: removed dependency of libpcbcommon on 3d-viewer. 2017-11-03 20:01:42 +01:00
jean-pierre charras 08a9dc01c5 Fix minor coding style issues 2017-11-03 10:22:34 +01:00
jean-pierre charras 4e391ef21c Housekeeping: remove no more in use options. 2017-11-02 21:01:32 +01:00
jean-pierre charras c536364f05 Fix a few coverity warnings. very minor other changes. 2017-11-02 18:18:57 +01:00
Maciej Suminski e5c4cfc3b0 Eagle board importer: enable rectangle on drawing layers
Now the graphical polygons in footprints are properly handled by the
footprint editor, so there is no reason not to import them.

Coverity CID: 168709
2017-11-01 10:41:57 +01:00
Maciej Suminski 5eb56dd8b0 Coverity fixes
CIDs:
102571
168696
168701
168704
168706
168708
168710
168713
168716
168717
2017-11-01 10:24:26 +01:00
Wayne Stambaugh 83cf726cd6 Fix crash when no symbol libraries are found.
Remove adding the power symbol library when no libraries are specified
in the project file to prevent unexpected missing library dialog.

Only show progress dialog if there are actually libraries to load.

Do not call wxWindow::Destroy().  The dialog is created on the stack and
will be destroyed properly in the wxWindow dtor.

Fixes lp:1728648

https://bugs.launchpad.net/kicad/+bug/1728648
2017-10-31 18:37:44 -04:00
jean-pierre charras bd73a39a4b DSN export: export keepout zone polygons on each layer they are living 2017-10-31 19:53:52 +01:00
Maciej Suminski 05ab44f463 Fixed a memleak when no undo entry is requested in BOARD_COMMIT 2017-10-31 09:14:03 +01:00
Maciej Suminski 93e7d52633 Restore ecc83 demo 2017-10-31 09:01:19 +01:00
jean-pierre charras 6300041ce4 Fix a focus issue in GAL canvas:
Sometimes there is no window that has the focus (it happens when an other PCB_BASE_FRAME is opened and is iconized on Windows).
2017-10-30 15:12:41 +01:00
Maciej Suminski e8e10c9245 Fixed a memleak in PCB_EDIT_FRAME::LoadFootprints() 2017-10-30 14:19:42 +01:00
Maciej Suminski 3a8b4a2fb7 Fixed a memleak in GerbView
Changed m_painter PAINTER* to unique_ptr<PAINTER> to avoid confusion
regarding the objection destruction.
2017-10-30 09:36:34 +01:00
Baranovskiy Konstantin a4440395be Gerbview: fix zoom to selection tool duplication. 2017-10-30 09:05:35 +01:00
Maciej Suminski a6f84051e9 Fixed a memory leak in Spice probe 2017-10-29 00:54:22 +02:00
Maciej Suminski 4bf8bb79ce Removed a redundant comparison 2017-10-29 00:54:08 +02:00
jean-pierre charras 3ed106fb70 Make a translation more easy
Better title in dialog netlist option (Unconnected Tracks ->Tracks Connecting 2 Nets)
The previous title (Unconnected Tracks) is incorrect.
2017-10-28 15:27:45 +02:00
Maciej Suminski 2b052265b2 Added library contents preview to Spice model editor dialog 2017-10-27 17:10:37 +02:00
Maciej Suminski 162d445ce4 Spice Model Editor upgrades
- set a proper title for the dialog
- changed the library parser delimiters to all whitespaces
- sorts the model list in the alphabetical order
- one tab to select subcircuit and semiconductor models
- model type is automatically selected
2017-10-27 16:53:04 +02:00
Maciej Suminski acbe30af51 Improved Spice library parser
Now the parser filters out models placed inside .subckt sections.
2017-10-27 16:53:04 +02:00
Kristoffer Ödmark 65b615bc4b Removed extra space in header part, fixed coding style 2017-10-27 12:13:23 +02:00
Kristoffer Ödmark 2e4dbdaf4b Fixed nest level when saving to not get giant diffs with version control software such as git 2017-10-27 11:30:11 +02:00
jean-pierre charras fc5e8e5f52 ENV_VAR config dialog enhancements.
From an initial work of Oliver <oliver.henry.walters@gmail.com>
2017-10-26 11:47:57 +02:00
jean-pierre charras d2d1237506 minor enhancement in code 2017-10-26 10:55:01 +02:00
Simon Richter 48ed0dcda2 code enhancement (remove duplicate) 2017-10-26 10:19:15 +02:00
Jon Evans b18cd4cb19 Fix arc drawing algorithm in GerbView GAL (Fixes lp:1720384) 2017-10-26 08:18:09 +02:00
jean-pierre charras 1929727966 rename dialog_dxf_import.fbp to dialog_dxf_import_base.fbp, like other .fpb files 2017-10-25 10:10:03 +02:00
jean-pierre charras 78ec983632 DRAWSEGMENT fix crash when trying to copy a empty polygon.
SHAPE_POLY_SET: fix crash in VertexCount when it is a empty poly set, or when params are incorrect.

minor other fixes:
warning in degug mode in dialog_dxf_import_base.cpp
pcb_painter.cpp: remove a useless debug line.
2017-10-25 09:39:26 +02:00
José Ignacio Romero 73c88bd0fe Add more layers in default layers selection plot parameter. 2017-10-25 08:07:42 +02:00
jean-pierre charras aa5faa9520 Update logo to a recent Inkscape version. No actual change. 2017-10-25 08:07:39 +02:00
Maciej Suminski 43c00ead16 GenCAD exporter fixes
Fixes: lp:1461147
* https://bugs.launchpad.net/kicad/+bug/1461147
2017-10-24 23:13:02 +02:00
Maciej Suminski bbe947e0f8 GenCAD exporter: quote and escape strings 2017-10-24 23:10:40 +02:00
Maciej Suminski bb68dad77c GenCAD exporter: clear shape name maps when export is finished
Otherwise the maps could contain stale data leading to a crash
2017-10-24 23:10:40 +02:00
Maciej Suminski 125781c7e1 GenCAD exporter: two level map for shape names
Previously the component to shape map contained
a lot of duplicated strings. Now the map stores
the component shape hash used for getting the
name from another map.
2017-10-24 23:10:40 +02:00
Maciej Suminski 13fc4c3c99 GenCAD exporter: export options made static 2017-10-24 23:10:40 +02:00
Maciej Suminski b53b7e3bc4 GenCAD exporter: generate matching DEVICE names 2017-10-24 23:10:40 +02:00
Maciej Suminski 82759f9cd0 GenCAD exporter: simplify shape matching 2017-10-24 23:10:40 +02:00
Maciej Suminski 019dca38c4 GenCAD exporter: generate shapes per footprint and reuse them 2017-10-24 23:10:40 +02:00
Maciej Suminski 944c5481fe Hash functions for BOARD_ITEMs 2017-10-24 23:10:40 +02:00
Maciej Suminski 847bede635 GenCAD exporter: changed 'flip components' to 'flip pads'
Such option might be useful for older CAM350 versions, but it should be verified.
2017-10-24 23:10:40 +02:00
Maciej Suminski d5fa28efe4 GenCAD exporter: option to export bottom components using MIRRORX 2017-10-24 23:10:40 +02:00
Maciej Suminski 2fce0d1235 GenCAD exporter: custom shape pads 2017-10-24 23:10:40 +02:00
Maciej Suminski 9b5dd3e629 GenCAD exporter: support for trapezoidal pads 2017-10-24 23:10:40 +02:00
Maciej Suminski 6ba33c8489 GenCAD export: added a switch to generate unique pin names 2017-10-24 23:10:40 +02:00
Maciej Suminski c3c5205393 GenCAD exporter: settings dialog 2017-10-24 23:10:40 +02:00
Maciej Suminski a73fa0790c GenCAD exporter: emit bottom modules using 'MIRRORX' directive to flip 2017-10-24 23:07:12 +02:00
Maciej Suminski c5b2169104 GenCAD exporter: fixed arcs 2017-10-24 23:07:12 +02:00
Maciej Suminski a06aed5305 GenCAD exporter: support for rounded rectangular pads, fixed oval pads 2017-10-24 23:07:12 +02:00
Maciej Suminski 63ddb1dbbc GenCAD exporter: fixed pad stacks for vias 2017-10-24 23:07:12 +02:00
jean-pierre charras cffe1b51e2 Gerbview: avoid a crash with malformed Gerber files.
Fix also incorrect handling of %LN (Load Name) deprecated command
2017-10-24 18:09:33 +02:00
jean-pierre charras 302f234264 Eeschema: fix an issue: doc never displayed if a non English language is used due to a bad way to retrieve the DATASHEET field. 2017-10-24 09:47:23 +02:00
Kristoffer Ödmark a562525ec9 Use schematic symbol field to show documentation link.
This instead of using the library alias property. But to not break any
library. When adding new components to the schematic, copy the value
from the library into the Field variable only if the field variable would
otherwise be empty.

This way, the context menu for showing the docs is more understandable
for users, and is also changeable from the schematic without having to
modify the actual libraries.

Fixed: lp:1723104
2017-10-23 16:58:56 -04:00
jean-pierre charras 788972554b minor fix 2017-10-23 19:11:32 +02:00
jean-pierre charras eb2340bc23 Show/Hide icons in menus (according to Icons option) in GAL, like in Legacy mode.
Cosmetic enhancement in Gerbview context menu.
2017-10-23 18:48:03 +02:00
jean-pierre charras 3407c6cf27 Gerbview: add icons in a context menu.
gal: remove a forgotten debug line.
2017-10-23 16:53:42 +02:00
jean-pierre charras 2d6496c7f6 Replace UNIT by EAGLE_UNIT in Eagle plugin to avoid having a lot of useless hits when grep for "UNIT" 2017-10-23 15:37:24 +02:00
jean-pierre charras 7418deb454 Pcbnew: fix issues with 360 deg angle arcs.
Fixes: lp:1725943
https://bugs.launchpad.net/kicad/+bug/1725943
2017-10-23 15:35:03 +02:00
jean-pierre charras cdb577bbbc Gerbview: fix an issue in legacy mode (locate items was not working) 2017-10-23 11:32:05 +02:00
jean-pierre charras 9bd5522419 Add a gerber test file
remove a few minor coverity warnings
2017-10-23 09:20:10 +02:00
jean-pierre charras 0b1eb5695f Fix crash when converting selected EDGE_MODULE items to a custom pad. 2017-10-21 12:46:59 +02:00
jean-pierre charras 8ba11dbd68 Minor fixes and enhancements 2017-10-21 11:00:59 +02:00
Seth Hillbrand 93a0e9e3d2 pcbnew: suppress compile warning on boost::optional 2017-10-21 08:49:33 +02:00
jean-pierre charras 87821c1490 Explode pad to shapes command: Fix incorrect conversion of primitive to EDGE_MODULE (missing initialization) 2017-10-21 08:48:26 +02:00
jean-pierre charras 55bb35a582 Cosmetic enhancement: add icon to 2 context menus (explode pad to graphic shapes and create pad from graphic shapes) 2017-10-20 18:25:44 +02:00
jean-pierre charras 9b4eddb744 Update gerber job file to latest format 2017-10-20 13:55:42 +02:00
jean-pierre charras 772dc2f24a Fix compil warnings 2017-10-20 13:48:36 +02:00
Seth Hillbrand fdae9f0b75 pcbnew: Only remove one duplicate track -- not both
Fixes: lp:1724728
* https://bugs.launchpad.net/kicad/+bug/1724728
2017-10-20 10:25:18 +02:00
jean-pierre charras 107c895cfd Pad editor: add tests to avoid incorrect values:
clearance must be >= 0
solder mask clearance must be >= 0
solder paste clearance must be <= 0
2017-10-20 10:25:17 +02:00
Maciej Suminski b3cbfdb7ba Eeschema plugin to import Eagle XML schematics 2017-10-20 09:34:49 +02:00
Maciej Suminski 0f532c3e8d Eagle PCB import plugin: handle correctly non-consecutive layer numbers 2017-10-20 09:34:33 +02:00
Maciej Suminski 59394fedbf Eeschema Eagle Import: fixed global net label rotation 2017-10-20 09:34:33 +02:00
Maciej Suminski 0ed7483868 Eeschema Eagle Import: support UTF-8 for fields 2017-10-20 09:34:33 +02:00
Maciej Suminski b77ba486ec Eeschema Eagle Import: fixed name and reference fields placement 2017-10-20 09:34:33 +02:00
Maciej Suminski 62156b9b69 Eeschema Eagle Import: refactored common code for setting text attributes 2017-10-20 09:34:33 +02:00
Maciej Suminski 7d7303215b Eagle PCB import plugin: more descriptive warning messages 2017-10-20 09:34:33 +02:00
Maciej Suminski e466bf50ae Eagle PCB import plugin: fix dimensions import 2017-10-20 09:34:33 +02:00
Maciej Suminski ee8012a5cc Eagle import plugin: Code clean-up and formatting 2017-10-20 09:34:33 +02:00
Maciej Suminski 25b8111341 Modified Eagle import plugins to use nanometers as the internal unit 2017-10-20 09:34:33 +02:00
Maciej Suminski 7f697de432 Handle empty texts correctly 2017-10-20 09:34:33 +02:00
Maciej Suminski 87465002c3 Eeschema Eagle Import: changed fixNetName() to escapeName() 2017-10-20 09:34:33 +02:00
Russell Oliver b796b13a89 Eagle PCB import: Improve error messages for unsupported footprint elements. - Display lines and circles from copper layers on drawings layer - Generate error messages for rectangles and polygons. 2017-10-20 09:34:33 +02:00
Russell Oliver 82b1e3c790 Eagle Import: Handle muli-pad pins. Adds overlapping pins in the symbol definition to ensure that electrical connections are made to each pad on the footprint. 2017-10-20 09:34:33 +02:00
Maciej Suminski ce145373e4 Change the Eagle schematic import plugin license to GPLv3+ 2017-10-20 09:34:33 +02:00
Maciej Suminski 444811ccfe Added exception handler for SCH_EDIT_FRAME::ImportFile 2017-10-20 09:34:32 +02:00
Maciej Suminski d617021d98 Added 'Import Non-KiCad Schematic' 2017-10-20 09:34:32 +02:00
Maciej Suminski 6b44d12bd8 Revert modifications to SCH_EDIT_FRAME::OpenProjectFiles() 2017-10-20 09:34:32 +02:00
Maciej Suminski e75d76d1a8 Enable LOCALE_IO in Eagle schematic import plugin 2017-10-20 09:34:32 +02:00
Maciej Suminski ce11e9a264 Eeschema Eagle Import: Changed convertTextSize() to ETEXT::ConvertSize() 2017-10-20 09:34:32 +02:00
Russell Oliver 2a0a999350 Eeschema Eagle Import: Code clean-up and formatting 2017-10-20 09:34:32 +02:00
Maciej Suminski 630a883f80 Update Eagle schematic import plugin after long pin/pad name patch 2017-10-20 09:34:32 +02:00
Maciej Suminski 985aed36c7 Moved FMT_UI & FMT_ANGLE macros to a separate header 2017-10-20 09:34:32 +02:00
Russell Oliver 3b0855d204 Eagle Project Import: Code cleanup and documentation.
- Also makes the project and file import functions filetype dependent.
- The change from IO_MGR::KICAD to IO_MGR::KICAD_SEXP removes a conflict from a compile definition for KICAD when compiling kicad/import_project.cpp
2017-10-20 08:58:40 +02:00
Russell Oliver c3b0fca922 Eeschema Eagle Import: Fix graphics on multi-unit symbols -- sets correct gate for arcs and polylines from eagle symbol wires. 2017-10-20 08:58:40 +02:00
Russell Oliver 230e8978f5 Eagle Parser: Fix overwritten changes 2017-10-20 08:58:40 +02:00
Russell Oliver b9973a1c67 PcbNew Eagle Import: Archives footprints in pretty library automatically on eagle project import. 2017-10-20 08:58:40 +02:00
Russell Oliver 869743d573 Kicad Eagle Project Import Improvements. -- schematic and board files are both visible in file selection dialog. -- Allows for the selection of either the board or schematic file. -- silently fails on not detecting the corrosponding board or schematic file. -- all new kicad files are generated in new project directory -- Silently read netlist without generating annotation warnings which synchronises timestamps and paths based on given eagle references, otherwise renumbering schematic references will break links accross schematic and pcbnew. 2017-10-20 08:58:40 +02:00
Russell Oliver 3145829b77 Fix compiler redefined warnings for FMT_IU 2017-10-20 08:58:40 +02:00
Russell Oliver a8fa64f158 Eeschema Eagle Import: Shift convertTextSize to common eagle parser. 2017-10-20 08:38:42 +02:00
Russell Oliver 433aa653fe Kicad: Add Project import function. -- add menu entry -- add ImportFile kiway function -- expose functions for creating/reading netlist -- add example eagle boad file as well 2017-10-20 08:38:42 +02:00
Russell Oliver d260609e69 Eeschema Eagle Import: Fix package assigment by combining eagle libraries of the same name. 2017-10-20 08:38:42 +02:00
Russell Oliver e63e916279 Eeschema Eagle Import: Parse eagle symbol name prefix and fix reference values. 2017-10-20 08:38:42 +02:00
Russell Oliver cdb5a01091 Eeschema Eagle Import: Set visibility of fields based on attribute display value. 2017-10-20 08:38:42 +02:00
Russell Oliver 00d1368099 Eeschema Eagle Import: Add a better test file to qa 2017-10-20 08:38:42 +02:00
Russell Oliver d9396ac43b Eeschema Eagle Import: Hide reference and values based component smashed status and attribute. 2017-10-20 08:38:42 +02:00
Russell Oliver cec76c4de2 Eeschema Eagle: Created convertTextSize function. 2017-10-20 08:38:42 +02:00
Russell Oliver 857f9f3216 Eeschema Eagle Import: arc fix 2017-10-20 08:38:42 +02:00
Russell Oliver afaa2499dc Eeschema Eagle Import: Set Pinshape. - modifies lin_pin.cpp function InternalPinDecoSize to default back to number text size if pin name text is set to zero. 2017-10-20 08:38:42 +02:00
Maciej Suminski 08907d4fe8 Eeschema Eagle Import: generate unique timestamps for multiunit parts 2017-10-20 08:38:42 +02:00
Maciej Suminski a8e800f571 Eeschema Eagle Import: Moved net name correction to a function 2017-10-20 08:38:42 +02:00
Russell Oliver b11c876e48 Eeschema Eagle Import: Move any labels while inserting bus entry symbols. 2017-10-20 08:38:42 +02:00
Russell Oliver fa6d777ee0 Eeschema Eagle Import: More rigorous file header check 2017-10-20 08:38:39 +02:00
Russell Oliver 41f1f2cc48 Eeschema Eagle Import: WIP Handle bus entry symbols for any direction. 2017-10-20 08:38:39 +02:00
Russell Oliver 3f738b661e Eeschema Eagle Import: Set subsheet name based on original Eagle schematic file name. 2017-10-20 08:38:39 +02:00
Russell Oliver 4a4954dd82 Eeschema Eagle Import: Renable label generation for unlabeled nets. 2017-10-20 08:38:39 +02:00
Russell Oliver aeb43b055c Eeschema Eagle Import: Fix power symbol import. - Set pins to power in to match current power supply symbols. - Change IsPowerConnection() to match POWER_IN pins from power symbols as well. 2017-10-20 08:38:39 +02:00
Maciej Suminski d4201ef51f Eeschema Eagle Import: memory leak fixes 2017-10-20 08:38:39 +02:00
Maciej Suminski 37445042ed Eeschema Eagle Import: corrected arc radius size 2017-10-20 08:38:39 +02:00
Russell Oliver 2a96f26b7e Eeschema Eagle Import: Arc importation fix 2017-10-20 08:38:39 +02:00
Russell Oliver 956ef0fa61 Eeschema Eagle Import: WIP trying to fix indirect memory leaks 2017-10-20 08:38:39 +02:00
Russell Oliver 1fdb13daa6 Eeschema Eagle Import: Parse all pin directions 2017-10-20 08:38:39 +02:00
Maciej Suminski 8b8a9ea705 Eeschema Eagle Import: enumerate units starting with 1 2017-10-20 08:38:39 +02:00
Russell Oliver 9f4c7af6fb Eeschema Eagle Import: Set symbol as a power symbol for single supply pin eagle symbols. 2017-10-20 08:38:39 +02:00
Maciej Suminski ff86c8eeb1 Eeschema Eagle Import: check rotation property before accessing it 2017-10-20 08:38:39 +02:00
Russell Oliver 64f4eaddff Eeschema Eagle Import: Improve arc parsing to replicate eagle filled arcs. 2017-10-20 08:38:39 +02:00
Russell Oliver e379329ee6 Eeschema Eagle Import: Better conversion between ! and ~ in text and pin names 2017-10-20 08:38:39 +02:00
Russell Oliver a6f7cdc949 Eeschema Eagle Import: Update text alignment parsing 2017-10-20 08:38:39 +02:00
Russell Oliver 8f66e73749 Eeschema Eagle Import: Fill rectangles in symbols 2017-10-20 08:38:39 +02:00
Russell Oliver bc23c55cec Eeschema Eagle Import: Update layer handling 2017-10-20 08:38:39 +02:00
Maciej Suminski 2adc3d48b4 Eeschema Eagle Import: Assign timestamps for modules 2017-10-20 08:38:39 +02:00
Maciej Suminski f5e7c2ee48 Eeschema Eagle Import: Check if alignment is defined before parsing 2017-10-20 08:38:39 +02:00
Russell Oliver 7af2a21891 Eeschema Eagle Import: Parse polyline symbol elements. 2017-10-20 08:38:39 +02:00
Russell Oliver 7f8ac1cf02 Eeschema Eagle Import: Parse plain wires as lines on the notes layer. 2017-10-20 08:38:39 +02:00
Russell Oliver d41fe9d567 Eeschema Eagle Import: Disable label creation for unlabeled nets, may have to be renabled for edge cases where a multi segment net is unlabled in Eagle but which would not be connected in Kicad. 2017-10-20 08:38:38 +02:00
Russell Oliver 9932d18b77 Eeschema Eagle Import: Set value and reference component field visibilities based on presence of text in symbol definition. 2017-10-20 08:38:38 +02:00
Russell Oliver 05e9ec94f1 Eeschema Eagle Import: Set pin and pad name visibilities using text size. 2017-10-20 08:38:38 +02:00
Russell Oliver bb754b33d0 Eeschema Eagle Import: Parse instance attributes for value and refererence positions and alignment. 2017-10-20 08:38:38 +02:00
Russell Oliver ef880f57a2 Eeschema Eagle Import: Field checks and library insertion fix. 2017-10-20 08:38:38 +02:00
Russell Oliver c0c75d4732 Eeschema Eagle Import: Convert overbar prefix on pins. 2017-10-20 08:38:38 +02:00
Russell Oliver afa5ef0ca6 Eeschema Eagle Import: Load labels as global or local depending on if the net is shared accross multiple eagle sheets. Test created kicad labels to check if they are on a wire, otherwise movethem to the nearest wire start, midpoint or end. 2017-10-20 08:38:38 +02:00
Russell Oliver dcdc66b79e Eeschema Eagle Import: Add wire to bus entry symbols. 2017-10-20 08:38:38 +02:00
Russell Oliver 3919b79777 Eeschema Eagle Import: Use bounding box for sheet position and size. 2017-10-20 08:38:38 +02:00
Russell Oliver 13abec84ef Eeschema Eagle Import: Symbol field positioning fixes. 2017-10-20 08:38:38 +02:00
Russell Oliver 23dc8fdf32 Eeschema Eagle Import: During recentering of items the sheet, round translation to 100 mils to keep items on the grid. 2017-10-20 08:38:38 +02:00
Russell Oliver 2db2319156 Eeschema Eagle Import: Fix label rotation. 2017-10-20 08:38:38 +02:00
Russell Oliver 03739a4d37 Eeschema Eagle Import: Import pins even if Eagle even if pin to pad mapping (connects) to found. Fixes missing pins in supply symbols. 2017-10-20 08:38:38 +02:00
Russell Oliver 246e1fcd9c Eeschema Eagle Import: Save imported library to disk. 2017-10-20 08:38:38 +02:00
Russell Oliver e7377c0a26 Eeschema Eagle Import: dynamically size sheet based on positions of wires and junctions within the sheet. 2017-10-20 08:38:38 +02:00
Russell Oliver 512b574132 Eeschema Eagle Import: Import Busses. 2017-10-20 08:38:38 +02:00
Russell Oliver b8f98eaffe Eeschema Eagle Plugin: Code Cleanup 2017-10-20 08:38:38 +02:00
Russell Oliver 3741793f77 Eeschema Eagle Plugin: Set Component Orientation 2017-10-20 08:38:38 +02:00
Russell Oliver 2523c6b5d7 Eeeschema Eagle Plugin: Set footprint field using Eagle device package value. 2017-10-20 08:38:38 +02:00
Russell Oliver 812cae5409 Eeschema: Eagle Import: Add schematic text. Parse eagle vector text ratio to determine if text is bold. 2017-10-20 08:38:38 +02:00
Maciej Suminski 0d76b2947f Store imported Eagle symbols in a library 2017-10-20 08:38:38 +02:00
Maciej Suminski 3298387f7b Assert for non-standard rotation during Eagle schematics import 2017-10-20 08:38:38 +02:00
Maciej Suminski deaa1d1477 Fixed crashes when importing an Eagle schematic
If release() is called on a unique_ptr, one needs to be sure
that is not dereferenced anymore.
2017-10-20 08:38:38 +02:00
Maciej Suminski d6383893a2 eeschema: Iterate through plugins when determining file format. 2017-10-20 08:38:38 +02:00
Russell Oliver c274a21548 WIP: Symbols are imported and displayed, and save to cache file on schematic save. 2017-10-20 08:38:38 +02:00
Russell Oliver b9edfe4fe4 WIP: Refactor symbol importation to account for multiple gates and device connect pin maps. 2017-10-20 08:38:38 +02:00
Russell Oliver f9845bfa12 Add Eagle plugin implementation notes. 2017-10-20 08:38:38 +02:00
Russell Oliver 55d6f4e0fc WIP: Eagle symbol importation 2017-10-20 08:38:38 +02:00
Russell Oliver 82cc0c7e2e Common: Eagle parser add EPART, EINSTANCE, EGATE, ECONNECT, EDEVICE 2017-10-20 08:38:38 +02:00
Russell Oliver 96317fb7c3 Common: Reorder some functions in eagle_parser.* 2017-10-20 08:38:38 +02:00
Russell Oliver 4e69acbb49 Eeschema: Add CheckHeader function to SCH_PLUGIN and cycle through plugins when loading files. 2017-10-20 08:38:38 +02:00
Maciej Suminski e03bc32e49 Eagle plugin: Code formatting 2017-10-20 08:38:38 +02:00
Maciej Suminski f049b01a59 Eagle plugin: Added 'static' and 'const T&' as applicable 2017-10-20 08:38:38 +02:00
Maciej Suminski c72b2155a6 Eagle plugin: changed #define to constexpr 2017-10-20 08:38:38 +02:00
Maciej Suminski 7d2320b5ad Eagle plugin: check before dereferencing optional attributes 2017-10-20 08:38:38 +02:00
Russell Oliver 7ea33f76b4 Eeschema: Determine file plugin to use from first line of file. 2017-10-20 08:38:38 +02:00
Russell Oliver 75d9185e4a Eeschema: Eagle Plugin: Add loadSymboltext, and position default symbol texts. 2017-10-20 08:38:38 +02:00
Russell Oliver 04c7fbebdc Eeschema: Eagle Plugin: Handle pin rotation. 2017-10-20 08:38:38 +02:00
Russell Oliver 739754cfd6 Eeschema: Eagle plugin: Save symbols to schematic library cache file. Remove unneeded variable. Fix add extension to filename 2017-10-20 08:38:38 +02:00
Russell Oliver ea8f7ed02d Eeschema: Eagle plugin> work on schematic and symbol elements 2017-10-20 08:38:37 +02:00
Russell Oliver e92c8c1d6c Eeschema: Handle multiple sheets in Eagle plugin. 2017-10-20 08:38:37 +02:00
Maciej Suminski c727423979 Work in progress
- !! Eeschema uses Eagle plugin for loading schematics (i.e. it does not
use KiCad format anymore)
- Fixed build errors
- Fixed a few crashes
- Code formatting
2017-10-20 08:38:37 +02:00
Maciej Suminski f5b2a2ea57 Code formatting and cleanup 2017-10-20 08:38:37 +02:00
Alejandro García Montoro 404457f455 Eeschema Eagle plugin 2017-10-20 08:38:37 +02:00
Alejandro García Montoro df708f8ada Starts the loading layout 2017-10-20 08:38:37 +02:00
Alejandro García Montoro 75b0549f6f Testing the structure 2017-10-20 08:38:37 +02:00
Alejandro García Montoro 2403f2b558 Adds necessary structure to implement and test Eagle schematich plugin 2017-10-20 08:38:37 +02:00
Tomasz Włostowski 22063dc5a5 pcbnew: clear selection reference point when moving footprint by name
Fixes: lp:1722870
* https://bugs.launchpad.net/kicad/+bug/1722870
2017-10-19 23:57:42 +02:00
Tomasz Włostowski ac095b6724 pcbnew: tools for converting between custom-shaped pads and graphical shapes 2017-10-19 23:35:18 +02:00
Tomasz Włostowski bcde2a77e2 common/single_top: allow to launch footprint editor from the command line (--frame switch) 2017-10-19 23:15:48 +02:00
Tomasz Włostowski dc7b743782 common: VECTOR2I-based RotatePoint() 2017-10-19 23:15:13 +02:00
Tomasz Włostowski d2c9a5d81a geometry: Area() method in SHAPE_LINE_CHAIN 2017-10-19 23:14:36 +02:00
Tomasz Włostowski d9bfbb4fec pcbnew: added graphical polygon drawing & editing tools 2017-10-19 23:14:01 +02:00
Jean-Samuel Reynaud 46edf6519c Fix crash with clearance is "too" negative. Same bug as #1663173
Fixes: lp:1663173
* https://bugs.launchpad.net/kicad/+bug/1663173
2017-10-19 08:41:15 -04:00
jean-pierre charras 56d42c776a Replace assert() by wxASSERT to make debug more easy. 2017-10-19 09:49:09 +02:00
jean-pierre charras 72d4889a6d Remove duplicate code (pcbnew saves twice 'general' and 'layers' keys in 'kicad_pcb' file)
Fixes: lp:1724522
https://bugs.launchpad.net/kicad/+bug/1724522
2017-10-18 18:01:34 +02:00
jean-pierre charras 537804b5e8 Fix incorrect format on Windows 32 bits (in a message only in Debug) 2017-10-17 09:55:32 +02:00
jean-pierre charras 1e35d45948 Replace a assert by a wxASSERT to make debug more easy. 2017-10-16 20:26:37 +02:00
Ingo Kletti df15e63d41 Fix Unit naming typo in eeschema spice model config 2017-10-16 20:07:26 +02:00
jean-pierre charras 1ec7fef4a2 fix a wxASSERT in dialog_keepout_area_properties.cpp 2017-10-16 13:58:36 +02:00
Maciej Suminski 609da9b61d Add missing sentinels for KICAD_T[] in SCH_EDIT_FRAME::OnLeftClick() 2017-10-15 18:11:31 +02:00
jean-pierre charras e0b9a21417 Modify a few messages to make translations more easy. 2017-10-12 10:39:32 +02:00
jean-pierre charras afd2d4f016 fix a segfault in library editor when importing symbols.
Fixes: lp:1722869
https://bugs.launchpad.net/kicad/+bug/1722869
2017-10-12 10:38:48 +02:00
Seth Hillbrand f685cfaf3d Eeschema: Add collision-based selection code to circles and text 2017-10-10 20:54:31 +02:00
jean-pierre charras 47f37efdec Fix a compil issue on Linux 2017-10-10 08:37:50 +02:00
jean-pierre charras e626136e29 Eeschema: boom generator: ugly fix on Windows to allow xsltproc.exe working from the command line created from bom dialog.
(On windows, xsltproc.exe does not accept '\' in output filename, only '/' like on Unix, so this separator is converted when possible)
Minor code cleanup
2017-10-09 20:57:41 +02:00
jean-pierre charras 835c19f1e2 Fix dcm files not working with lib file in version 2.4
Fixes: lp:1722107
https://bugs.launchpad.net/kicad/+bug/1722107
2017-10-09 13:10:29 +02:00
jean-pierre charras b5f23befeb Fix incorrect initialization of default colors for some items.
Fix incorrect detection of key handled in footprint_wizard_frame.cpp
2017-10-09 10:35:53 +02:00
jean-pierre charras cb3d28f11b define SetPadName() and GetPadName() (old name of D_PAD::SetName() and GetName()) for compatibility with existing python scripts 2017-10-09 09:58:15 +02:00
jean-pierre charras 246f8cae24 Fix missing initialization of colors settings of a board, when created by a python script.
A pointer was not initialized, therefore plots from a python script sometimes crash.

Fixes: lp:1721166
https://bugs.launchpad.net/kicad/+bug/1721166
2017-10-08 16:21:27 +02:00
Oliver d6c0d320db Consolidated line icon
- Line / polygon icon in pcbnew now matches that in modedit
2017-10-06 11:10:46 -04:00
jean-pierre charras 4905bbe500 hotkey management: enhancements in code to know if a hotkey was handled by an event or not.
No actual change in key management: in legacy it was partially existing, and not yet used in GAL mode.
2017-10-06 09:23:13 +02:00
jean-pierre charras 1164eaab72 Make the "No Net" mark color editable (mark for pads having no net name)
Note: this mark is currently drawn only in legacy canvas.
2017-10-05 20:11:55 +02:00
jean-pierre charras acccb10ca5 Minor fix: Fix a incorrect min size of COLOR4D_PICKER_DLG on Linux+KDE 2017-10-04 16:35:57 +02:00
jean-pierre charras 3d15690817 remove a printf certainly used in debug tests during development. 2017-10-03 13:10:25 +02:00
jean-pierre charras 06a59022e4 minor fixes (compil warning and a very minor fix) 2017-10-02 20:39:09 +02:00
Maciej Suminski 569d909045 Component fields updater for eeschema 2017-10-02 15:57:30 +02:00
Maciej Suminski 85faa0e101 Added a dialog to select fields to be updated 2017-10-02 15:57:23 +02:00
Maciej Suminski e29d77c891 'Update Field Values' tool for eeschema 2017-10-02 15:57:23 +02:00
Maciej Suminski 78c285b83a 'Update Fields' icon for eeschema 2017-10-02 15:57:23 +02:00
Maciej Suminski d90ac8299d Added 'Update Fields' button in schematic component properties 2017-10-02 15:57:23 +02:00
jean-pierre charras 4a2647b771 very minor fixes in strings in dialog. 2017-10-02 15:40:36 +02:00
Maciej Suminski f3184ebadb Fixup for ed480bbb 2017-10-02 10:04:45 +02:00
jean-pierre charras 4b010ca129 Fix useless trailing and leading spaces in a few messages. Fix also capitalization in a few menus. 2017-10-02 09:25:48 +02:00
Cirilo Bernardo 949b4754e5 DXF: ensure "C" language environment. 2017-10-02 09:16:29 +02:00
Cirilo Bernardo a3dfd2c0dd DXF: fix import of Polyline with bulge 2017-10-02 09:16:29 +02:00
Maciej Suminski ed480bbbd4 Fixed a sizer assert in pad properties dialog 2017-10-02 09:03:26 +02:00
Baranovskiy Konstantin c34955aaed Pcbnew: small fix for pad properties dialog. 2017-10-02 08:56:55 +02:00
Maciej Suminski e2ba6da886 Fixed an empty msgid warning (gettext) 2017-10-02 08:49:33 +02:00
Kristoffer Ödmark 4a5d400ec2 pcbnew: copy/paste code cleanup & formatting 2017-09-30 14:28:54 +02:00
Tomasz Włostowski c6a0ad895b pcbnew: code formatting, removed previous module editor copy/paste functions 2017-09-30 14:28:54 +02:00
Tomasz Włostowski adcda4a3e8 pcbnew: prompt for reference point in the message panel, add cut/copy/paste entries in the Edit menu 2017-09-30 14:28:54 +02:00
Tomasz Włostowski 5731000135 pcbnew/copy&paste: multiple improvements:
- fixed netcode propagation bug
- factored out EDIT_TOOL::m_offset, now selection offset is stored in SELECTION class
- added VECTOR2I-based Move/Flip/Rotate methods in BOARD_ITEM
2017-09-30 14:28:54 +02:00
Tomasz Włostowski f573a2e685 wip 2017-09-30 14:28:54 +02:00
Tomasz Włostowski 3fb926a8f2 Fix snapping to anchors in PICKER_TOOL & highlighting of pasted items 2017-09-30 14:28:54 +02:00
Tomasz Włostowski 931a1ccaff Improved copy/paste functionality by Kristoffer:
- added selection of reference point
- added snapping when pasting
- some minor code refactoring
- disabled pasting between footprint and pcb editors due to model incompatibility
2017-09-30 14:28:54 +02:00
Kristoffer Ödmark 279ccd4fe2 Fix bug found by Tomasz, added constant modifier in loops where board items should not be modified 2017-09-30 14:28:54 +02:00
Kristoffer Ödmark 79d81ae9ff forward the event 2017-09-30 14:28:53 +02:00
Kristoffer Ödmark 4ce38abce2 renamed copypasta functions, fixed a paste_module error 2017-09-30 14:28:53 +02:00
Kristoffer Ödmark e19882577a fixed a comment, copies now retain their path if any 2017-09-30 14:28:53 +02:00
Kristoffer Ödmark b4879d061c Fixed menu items, moved the copy and cut to the EDIT_TOOL, Fixed rendering when copying a module 2017-09-30 14:28:53 +02:00
Kristoffer Ödmark 7ff096fbac updating patch to master 2017-09-30 14:28:53 +02:00
Kristoffer Ödmark bd8980596f Some code cleanup to follow kicad style better 2017-09-30 14:28:53 +02:00
Kristoffer Ödmark 6a02ee6c4b fixed crash on copying texte modules 2017-09-30 14:28:53 +02:00
Kristoffer Ödmark 84b803042c Improvements to copy-paste
-Can paste items from board to module-editor (only module parts)
-Can paste entire modules just as copy
-Can copy items inside module-editor

Known limitations:

-Will crash if trying to paste a module containing module_text inside
the module editor ( dont know why, problem existed before )
-If copying things with strange layer names, the layer names will be
changed.
2017-09-30 14:28:53 +02:00
Kristoffer Ödmark 05d8f1071e Made the formatHeader into multiple small functions 2017-09-30 14:28:53 +02:00
Kristoffer Ödmark c0981b8444 Added a new plugin that can save and load to clipboard, using ctrl+shift+c/v for copy pasting
Added the needed kicad_clipboard files and made copy pasted modules have no path
2017-09-30 14:28:53 +02:00
Seth Hillbrand 6573a43f3a pcbnew: multiple keepout zone bug fixes
- Fixes segfault in ZONE_CONTAINER::SetLayerSet
- Copies layerset when using assignment and new()
2017-09-30 13:56:25 +02:00
jean-pierre charras d00fc993f3 Fix job file extension. 2017-09-30 09:18:47 +02:00
Maciej Suminski 4bd51b7049 Fixed EDA_BASE_FRAME::removePaneBorder() for classes not using AUI
Fixes: lp:1720386
* https://bugs.launchpad.net/kicad/+bug/1720386

Fixes: lp:1720388
* https://bugs.launchpad.net/kicad/+bug/1720388

Fixes: lp:1720389
* https://bugs.launchpad.net/kicad/+bug/1720389
2017-09-29 17:08:32 +02:00
Baranovskiy Konstantin 4612a52b50 3D Viewer: fixed entry labels in popup menu. 2017-09-29 15:31:36 +02:00
jean-pierre charras 5aeb6129ca Fix a bug in KIGFX::COLOR4D ctor: . The alpha channel (opacity) was set to 0. this is a mistake. It is now set to 1.0
Fixes lp:1718389
2017-09-29 14:52:51 +02:00
Simon Schubert b6d54acf3b Corrected the default net class assignment 2017-09-29 08:47:40 +02:00
jean-pierre charras 5731acc97c Fix typo and and comment 2017-09-29 07:58:15 +02:00
Seth Hillbrand 5b2248fad8 gerbview: Corrects handling of %FSD statement 2017-09-29 07:40:58 +02:00
Oliver Walters 948dfe88ce Added option to not test other pins when setting pin parameters
- On loading from file, other pins are not LINKED and thus can be ignored
- 90% reduction in library load time when launching eeschema
2017-09-28 13:10:08 -04:00
Wayne Stambaugh ded4ad9b17 Pcbnew: delete objects from removed layers.
This fixes potential DRC false positive bugs that occur when inner layers
are removed from the board but the actual objects on contained on those
layers remain in the board.

Since Pcbnew does not handle odd number layers, this is not a perfect fix.
When the user chooses the front or back layer only options from the layer
setup dialog, objects on the copper layers will not be removed.  This will
not cause the false positive issue described above.

Get rid of dialog OK and cancel button event handlers and use the proper
TranferData(To/From)Window for handling control data.

Add PCB_LAYER_COLLECTOR for collecting board objects by layer.  Factor out
redundant [] operators into base PCB_COLLECTOR object.

Fixes lp:893950

https://bugs.launchpad.net/kicad/+bug/893950
2017-09-28 13:01:09 -04:00
jean-pierre charras 517921e2e1 update doc and remove a outdated file
Update or fix a few strings in menus and tool tips
2017-09-28 18:56:36 +02:00
Maciej Suminski 6006b54dd9 Fixed a crash when editing a pad of a bottom layer module
Fixes: lp:1720007
* https://bugs.launchpad.net/kicad/+bug/1720007
2017-09-28 09:58:34 +02:00
jean-pierre charras 54d34c341b Cleanup code 2017-09-28 08:38:36 +02:00
Maciej Suminski 068a29952c Changed AUI toolbars background from gradient to solid
Based on patches from Windsor Schmidt <windsor.schmidt@gmail.com>
2017-09-27 23:23:06 +02:00
jean-pierre charras df830dab4c Add comments and a comment asking to fix a call to a GUI inside a io plugin, that is not allowed 2017-09-27 18:59:17 +02:00
jean-pierre charras b4a59eb96d Fix minor issues in DIALOG_KEEPOUT_AREA_PROPERTIES.
Fix keepout zone creation in legacy canvas.
Add a comment in lset.cpp
2017-09-27 16:54:28 +02:00
Oliver Walters 42be6bb966 Improved keepout zone properties dialog
- Checkboxes next to layers
- OK button is disabled if no layers are selected
2017-09-27 10:35:00 +02:00
Oliver Walters c977c88a10 Zone keepout exclusion now works on multiple layers!
Bug fixes for keepout layers

- Changed LSET::size() -> LSET::count()
- Save/load functions no longer depend on zone being a keepout
2017-09-27 10:35:00 +02:00
Oliver Walters 363fc598c0 Fixed bug in FlipLayerMask
- Offset for internal copper layers was incorrect
- Incorrect mask was used
2017-09-27 10:35:00 +02:00
Oliver Walters 7e0fa329d0 DRC checks for keepout zones work on all layers 2017-09-27 10:35:00 +02:00
Oliver Walters 2895030cfa Add multi-layer zone rendering for GAL
Enable multi-layer selection for keepout zones in GAL
2017-09-27 10:34:59 +02:00
Oliver Walters 0f6ec7632b Enable multi-layer for keepout zones
- Load / save from PCB file correctly
- Doesn't display properly yet
- Keepout only actually applies to one layer (for now)
2017-09-27 10:34:59 +02:00
Baranovskiy Konstantin 28997e7f37 Footprint viewer: fix zooming from toolbar or menu in GAL. 2017-09-26 16:24:54 +02:00
Wayne Stambaugh 9ca3f632a2 Pcbnew: fix update schematic from PCB file name bug.
Use ctor wxFileName( path, name, extension) to create full schematic file
name in update PCB from schematic code path.  This prevents file names with
dots '.' from being interpreted as the extension when using the wxFileName
assignment operator.
2017-09-26 10:13:21 -04:00
Kevin Zheng 6487ec5c21 Reword hotkey reset menu items
Fixes lp:1717637
2017-09-26 09:21:48 -04:00
Wayne Stambaugh 39b27e39a9 Eeschema: silently save project file after schematic plot setting changes.
Don't prompt the user to save the project file after the schematic plot
settings change.  It is not done this way anywhere else in KiCad.

Fixes lp:1478131

https://bugs.launchpad.net/kicad/+bug/1478131
2017-09-26 08:32:04 -04:00
Jon Evans 4341c0eb2b Change LOD cutoff for D-Codes 2017-09-26 10:58:03 +02:00
Maciej Suminski 6e440ffc2d GerbView GALification 2017-09-25 14:04:06 +02:00
Jon Evans 9383987b1c Skip calling RTREE::Remove() when adding items to a VIEW 2017-09-25 13:39:38 +02:00
Jon Evans e5df4304a6 Minor tweaks to GerbView for performance 2017-09-25 13:39:38 +02:00
Jon Evans 1994cc3ae2 Use unordered_map instead of map for GROUPS_MAP 2017-09-25 13:39:37 +02:00
Jon Evans 256f52f27e Use VIEW_GROUP for candidate highlighting; enable in PcbNew also 2017-09-25 13:39:37 +02:00
Maciej Suminski 05a120f09f Unified {Load,Save]CanvasTypeSetting in EDA_DRAW_FRAME 2017-09-25 13:39:32 +02:00
Maciej Suminski 88cab885af Code formatting 2017-09-25 13:35:02 +02:00
Jon Evans d87c9f7ed7 Highlight selection candidates instead of using BRIGHT_BOX 2017-09-25 13:35:01 +02:00
Jon Evans b90d86aa2d Properly update toolbar buttons on application start 2017-09-25 13:35:01 +02:00
Jon Evans cc5c5010f0 Fix some layer visibility behavior 2017-09-25 13:35:01 +02:00
Jon Evans 050489d719 GerbView GAL support part 2: New files for GAL
- New draw panel
- New painter
- GerbView-specific tools
2017-09-25 13:35:01 +02:00
Jon Evans 915e51e1f0 GerbView GAL support part 1: changes to existing files
- New GAL draw layers for GerbView
- Improved bounding boxes for Gerber shapes
- Switched to use of SHAPE_POLY_SET for polygons
- Add GAL methods to support selection and rendering
- Add GUI support of editing GAL options
- Rename get/setActiveLayer to Get/SetActiveLayer to match convention
2017-09-25 13:35:01 +02:00
Jon Evans 460b1e8540 Move forceColorsToLegacy() to EDA_DRAW_FRAME as virtual method 2017-09-25 13:35:01 +02:00
Jon Evans 77bf22359e Move zoom_tool.h to include 2017-09-25 13:35:01 +02:00
Jon Evans 0b9b8d3e93 Add support for reversed draw order and Cairo negative draw mode 2017-09-25 13:35:01 +02:00
Seppe Stas e46fdb0115 Implement OnLayerRightClick for Gerber layer widget 2017-09-22 17:41:42 +02:00
Seppe Stas d7b143f6f0 Right click option to change layer and render color 2017-09-22 17:41:42 +02:00
Maciej Suminski df472e6426 Added mouse position refresh event WX_VIEW_CONTROLS::WarpCursor() 2017-09-22 11:13:45 +02:00
Michael Geselbracht da037027fb Do not warp viewport when dragging FPs
Fixes: lp:1714611
* https://bugs.launchpad.net/kicad/+bug/1714611
2017-09-22 11:13:40 +02:00
Wayne Stambaugh 427e5ec461 Eeschema: fix crash when undo called during item edit.
Add EDA_DRAW_FRAME::isBusy() method to test if the current item is being
edited or a block operation is in progress.

Ignore undo and redo commands when editor is busy.

Fixes lp:1718656

https://bugs.launchpad.net/kicad/+bug/1718656
2017-09-21 12:37:52 -04:00
Wayne Stambaugh cb764d73c5 Minor trace logging improvements.
Make all trace environment variable strings upper case and prefix with
KICAD_TRACE_ for consistency.

Add Doxygen group for the trace environment variable strings.
2017-09-21 08:58:41 -04:00
Jon Evans 8722fd9c6c Set modified flag when changing layer visibility (lp:793420) 2017-09-21 11:09:08 +02:00
jean-pierre charras b18601dfc6 Send wxEVENT_CHAR to GUI (if the key is not a special key that scrolls the draw panel) both on Linux and Windows
fix lp:1718488
2017-09-20 20:21:54 +02:00
Wayne Stambaugh 90c3d41f67 Fix duplicate accelerator key in board editor view main menu.
Both "&Fit on Screen" and "&Flip Board View" in the "View" main menu were
mapped to the 'F' accelerator key.  Changed "Flip &Board View" to use the
'B' accelerator key.

Fixes lp:1717924

https://bugs.launchpad.net/kicad/+bug/1717924
2017-09-20 12:58:39 -04:00
jean-pierre charras 4e8ad8516a Update gerber job file format and job file extension.
Gerber job file extension is now .gbrjob, according to latest changes in Gerber job file spec.
2017-09-20 18:14:20 +02:00
jean-pierre charras 8d1d37beb0 Refinements in pad properties dialog 2017-09-20 16:14:23 +02:00
jean-pierre charras 7c1ac6fbcc Refinements in pad properties dialog 2017-09-20 15:37:37 +02:00
Wayne Stambaugh 6816b0dc99 Schematic hierarchy selection dialog fixes.
Derive the dialog from DIALOG_SHIM and show dialog quasi-modally to prevent
other KiCad main frame window events from being blocked.

Remove redundant storing of parent window pointer.

Verify parent window pointer is actually a SCH_EDIT_FRAME since the dialog
directly accesses parent object methods.

Replace static event table with dynamic event handling.

Fixes lp:1718241

https://bugs.launchpad.net/kicad/+bug/1718241
2017-09-20 08:45:30 -04:00
jean-pierre charras a43f3ab1fe replace "BasicShape" by "Primitive" in code, a better name 2017-09-20 12:51:10 +02:00
jean-pierre charras 4122aa1c01 Fix translation (I18n) problems 2017-09-20 09:32:37 +02:00
jean-pierre charras 963efd248d Fix compil warning 2017-09-20 09:31:48 +02:00
Simon Richter 40ffb364df Avoid converting fixed string to UTF-8
This fixes a build error on MSVC. The code may actually be legal, but a
proof of that would require a lengthy dissertation on argument promotion
rules for the ternary operator, and the simplest rule of promoting both
cases to a wxString rvalue is not likely to be what is intended here.

Fortunately, this expression can be simplified.
2017-09-20 08:57:35 +02:00
Maciej Suminski 1edaa8090d Turned LIB_ITEMS_CONTAINER into a template 2017-09-20 08:39:14 +02:00
Maciej Suminski 55bc8da726 LIB_ITEMS_CONTAINER code formatting 2017-09-20 08:39:14 +02:00
Bernhard Stegmaier 0be357ec3e LIB_ITEMS_CONTAINER reimplemented using C-style array of boost::ptr_vector
Fixes: lp:1714974
* https://bugs.launchpad.net/kicad/+bug/1714974
2017-09-20 08:39:14 +02:00
jean-pierre charras b00174c5a4 add comment 2017-09-19 19:00:22 +02:00
jean-pierre charras d8ade988ce workaround for a minor and strange issue: size of chars '-' and '_' are incorrect in msdf_atlasgen fonte. the size of 'x' char is used instead. 2017-09-19 18:56:33 +02:00
jean-pierre charras e1fbe1cb3a update a python demo that wws not working with current pcbnew version. 2017-09-19 18:50:43 +02:00
Maciej Suminski 76d1365360 Support long names for pins and pads 2017-09-19 18:34:28 +02:00
Maciej Suminski cca63801bf Renamed D_PAD::{Set,Get}PadName() to D_PAD::{Set,Get}Name() 2017-09-19 18:23:50 +02:00
Maciej Suminski d6f3961804 pcbnew & eeschema file format version bump 2017-09-19 18:22:56 +02:00
Maciej Suminski 85be485c34 Enable long names for pin numbers and pads
- pad names are stored as wxString instead of a char[4] & integer union
- removed pad name to string conversion functions
- fixed pad & pin properties dialog restrictions regarding the name
length
2017-09-19 18:19:49 +02:00
jean-pierre charras dddaa7e69c use custom pad shape in a microwave footprint 2017-09-19 15:51:47 +02:00
jean-pierre charras e504746fa3 Rename muonde.cpp to microwave.cpp 2017-09-19 15:51:45 +02:00
Fabrizio Tappero d2d665e540 library option reviewed and renamed, minor menu text changes 2017-09-19 08:11:24 -04:00
Maciej Suminski 0083ce1bdc Disable enforced slash as the path separator in NETLIST_EXPORTER
It causes issues with files that are stored on network resources and
pointed to using the Windows UNC format.
2017-09-19 12:08:10 +02:00
jean-pierre charras e2d3fcec02 Add support for custom pad shape. Full support in DRC and PnS.
add option to use shape or convex hull as clearance area in zones.
simplify code to handle clearance area
2017-09-19 09:02:53 +02:00
Wayne Stambaugh 3d1bebe9f8 Fix tooltip in the edit library symbol properties dialog. 2017-09-18 13:18:49 -04:00
Seppe Stas 3b7fbad1b9 Improve template selector for macOS
Fixes: lp:1492577 (and probably also lp:1672116).
*https://bugs.launchpad.net/kicad/+bug/1492577
*https://bugs.launchpad.net/kicad/+bug/1672116

- Fixes a race condition causing the wrong page to be selected in
  `OnPageChange`
- Allows the validate path and browse button to refresh the
  template page even when the path was not changed. This is needed
  since on OSX the page needs to be active for the templates to be
  rendered.
2017-09-18 16:40:50 +02:00
jean-pierre charras 48393c605e Try to fix special keys (ARROWS, PAGE UP/DOWN) issues both on Linux and Windows in GAL mode
Fixes: lp:1717270
https://bugs.launchpad.net/kicad/+bug/1717270
2017-09-18 16:04:31 +02:00
Maciej Suminski 54cffb7bf7 More aggressive sheet-selection 2017-09-18 13:51:25 +02:00
Maciej Suminski 25abe30c72 Code formatting 2017-09-18 11:25:32 +02:00
Kristoffer Ödmark 5e70810161 Disabled the automatic schematic-cross probing due to performance reasons. Added sheet-context menu entry for the cross-probing instead. 2017-09-18 11:16:18 +02:00
Kristoffer Ödmark aaa1e35b6a Heirarchical sheet selection includes more.
Now the heirarchical sheet selection feature includes tracks that belong
to a net spanning multiple sheets, but only by doing a logical connection
from the pads of the modules. This is to be able to select connections
between components on the same sheet. For example if the sheet contains a
star power connection or something similar, then most of the sheet local
connections will now also be included.
2017-09-18 11:16:13 +02:00
Mathias Grimmberger 2c23c4c3a9 Dropdown list in via properties dialog to select predefined via size 2017-09-18 10:28:08 +02:00
jean-pierre charras e2505cb2fd better fix than commit c0bc2f1 that tried to fix an overzealous event propagation:
The fix is now only for Windows, because it creates issues and does not fix the special keys issues on Linux.
This is due to the serious differences in event management between platforms.
2017-09-15 16:29:26 +02:00
Jon Evans d9396616ef Add support for panning with left and right mouse buttons 2017-09-15 13:35:52 +02:00
jean-pierre charras c0bc2f1bee Try to fix an overzealous event propagation that creates some key events (arrows, page up page down and some others) and mouse events called twice.
the first call is the right call, the last call being the default handler.
2017-09-15 11:29:50 +02:00
jean-pierre charras cf178fd20a add a wxASSERT just in case. 2017-09-15 11:29:49 +02:00
Jon Evans 93de82f0b2 Fix scrollbars in macOS GAL canvases 2017-09-15 11:29:49 +02:00
Jon Evans 5364cd9681 Improved zoom behavior on MacOS 2017-09-15 11:27:35 +02:00
jean-pierre charras 66b654f006 Very minor fix: cleanup a few svg icons and set icon size to 26x26, like other icons. Remove unused icon. 2017-09-14 17:13:36 +02:00
Maciej Suminski fa8aaf9d27 Consistent grid options map and GRID_STYLE values 2017-09-14 16:53:21 +02:00
Oliver Walters f299266107 Added button logos to DIALOG_EDIT_COMPONENT_IN_SCHEMATIC dialog 2017-09-14 08:49:55 -04:00
Oliver Walters f529e3100c Altered text buttons to image buttons
- Used same tooltip messages
- Added "MoveFieldDown" button / function
2017-09-14 08:47:43 -04:00
Oliver Walters 04adacdea6 Added build steps for previously unused bitmaps
- plus
- minus
- go_up
- go_down
2017-09-14 08:44:34 -04:00
Michael Kavanagh b6029cd8ac Minor UI improvements 2017-09-14 07:38:56 -04:00
Jon Evans 49a3e7ec2d Support scrollbar controls in GAL canvas 2017-09-14 07:34:29 +02:00
Wayne Stambaugh 33cc7b3f99 Fix broken default icons in menus setting for OSX. 2017-09-13 12:59:42 -04:00
Jean-Samuel Reynaud 50c9d8f77d Fix duplicated pin in case of multipart symbol creation.
Fixes lp:1509936

https://bugs.launchpad.net/kicad/+bug/1509936
2017-09-13 11:41:31 -04:00
Jon Evans 8182369c64 Make RULER_ITEM generic and ensure text mirroring is disabled 2017-09-12 12:49:43 +02:00
Jon Evans b6298a0a41 Don't force grid color to LAYER_GRID in EDA_DRAW_PANEL_GAL 2017-09-12 12:49:17 +02:00
jean-pierre charras e15acbb00d Fp editor and board editor have now a separate color setup.
fp viewer uses the default colors, because it has no color setup dialog.
class_colors_design_settings: remove not used members.
Fix issue in modedit: the color config was never read.
2017-09-11 18:51:48 +02:00
Maciej Suminski 8c7175b00d Upload correct amount of vertex data in CACHED_CONTAINER_RAM
Previous implementation uploaded only vertices with indices less
or equal to the number of stored vertices, which is invalid when
the container become fragmented.

Fixes: lp:1712887
* https://bugs.launchpad.net/kicad/+bug/1712887
2017-09-09 21:07:32 +02:00
Maciej Suminski 342bb2bf78 Code formatting
Renamed VERTEX related constants to follow UPPER_CASE naming.
2017-09-09 21:07:32 +02:00
jean-pierre charras 19ad350c1c Fix a bug in DRAWSEGMENT::GetParentModule() that expected a non null parent to return a null parent! 2017-09-08 20:19:14 +02:00
Maciej Suminski 4a6777e0d1 Validate LIB_ITEMS::ITERATOR after erase operation 2017-09-08 08:52:01 +02:00
Maciej Suminski 4cd319b0c7 Make LIB_ITEMS::ITERATOR operator++ and end() coherent
Previous operator++() could move LIB_ITEMS::ITERATOR past the iterator
returned by LIB_ITEMS::ITERATOR::end(), potentially leading to a
segfault.
2017-09-08 08:51:59 +02:00
Maciej Suminski 90668f9efb Do not destroy the footprint cache in EAGLE_PLUGIN init
EAGLE_PLUGIN::init() is called every time the footprints are enumerated,
so it is incorrect to destroy the cache there.
2017-09-07 13:01:14 +02:00
Seth Hillbrand 3b086360b8 Fixed a condition in LIB_ITEMS_LIST::operator[]
Fixes: lp:1714110
* https://bugs.launchpad.net/kicad/+bug/1714110
2017-09-07 00:44:40 +02:00
jean-pierre charras 8c70681b31 Remove useless includes and more fixes to avoid including curl.h in files, when not mandatory. 2017-09-05 08:07:31 +02:00
jean-pierre charras 6ea6c7219a Avoid including curl.h in dialog about (including curl.h creates constraints with wxWidgets especially on Windows)
and remove duplicate code.
2017-09-04 12:53:50 +02:00
Seth Hillbrand 1fe91e6252 Eeschema: handle disambiguation cancel in library editor right-click
Fixes: lp:1714608
* https://bugs.launchpad.net/kicad/+bug/1714608
2017-09-02 14:52:18 -04:00
Wayne Stambaugh 8d14751352 Fix missing project file when creating a new project.
Fixes lp:1714522

https://bugs.launchpad.net/kicad/+bug/1714522
2017-09-01 15:31:03 -04:00
Wayne Stambaugh d190aa423f Minor version information improvements.
Include GTK+ version when appropriate so developers don't have to try to
figure out which version of GTK+ wxWidgets was built against.

Add KICAD_SPICE option status.
2017-09-01 08:19:17 -04:00
jean-pierre charras b0b3fde598 fix in Gerber job file creation. 2017-09-01 13:37:28 +02:00
jean-pierre charras b33b79d654 fix a minor compil warning 2017-09-01 13:36:55 +02:00
metacollin a490144183 fix missing parenthesis in a "#if defined (__WXMAC__)" block 2017-09-01 11:15:51 +02:00
Seth Hillbrand 1c617b9f56 Prevent duplicate objects during block copy in symbol library editor.
Fixes lp:1714109

https://bugs.launchpad.net/kicad/+bug/1714109
2017-08-31 12:26:39 -04:00
Maciej Suminski 450f006d7d Keep the default net class object per board, not static
Fixes: lp:1711491
* https://bugs.launchpad.net/kicad/+bug/1711491
2017-08-31 17:46:17 +02:00
Wayne Stambaugh bd64b70f0b Prevent KiCad from creating an empty project file history entry. 2017-08-31 11:33:39 -04:00
Wayne Stambaugh 525e04ce75 Prevent KiCad from overwriting existing files with template files.
Add tests to check for existing files before copying template files.

Split load project, create new project, create new project from template,
and load project from history command events into simple methods that
perform the correct actions before loading the project.  This greatly
simplifies the code.

Create a load project method that can be called from the event handlers
above.  This simplified a lot of duplicate code that existed in many of
these event handlers.

Remove the dummy "noname.pro" file creation which created required some
ugly code to prevent this file from being created unexpectedly.  Now
KiCad launches without setting a project file name when appropriate.

Fixes lp:1713951

https://bugs.launchpad.net/kicad/+bug/1713951
2017-08-31 11:15:20 -04:00
Jon Evans eec1366ead Move ZOOM_TOOL to common; add RMB-drag to zoom out 2017-08-31 10:04:00 +02:00
Jean-Samuel Reynaud 21c104fcc7 Fix incorrect (missing) initialisation of m_cur_grid in symbols libraries table dialog box 2017-08-31 09:49:28 +02:00
jean-pierre charras 3ac87f6969 Fix an issue on MacOS. 2017-08-30 18:32:41 +02:00
jean-pierre charras 50164e9968 Add Gerber job file writer in Pcbnew, and a basic reader in Gerbview. Currently disabled
Fix also very minor issues in Gerbview
2017-08-30 11:04:33 +02:00
Tomasz Włostowski 2e4c22f718 router: fix corruption of board data when the inline drag is activated while the router tool is running
Fixes: lp:1712838
* https://bugs.launchpad.net/kicad/+bug/1712838
2017-08-30 01:16:06 +02:00
Wayne Stambaugh 3bcc3dc4f9 Add delete block hotkey to schematic editor. 2017-08-29 15:16:56 -04:00
Tomasz Włostowski 20b9ed4897 router: fixed possible use-after-free condition during segment dragging
ratsnest: fixed occasionally disappearing airwires
2017-08-29 18:49:05 +02:00
Michael Kavanagh 82ce90ecdc PL Editor UI Improvements: Menubar, toolbar and hotkeys 2017-08-29 11:52:34 -04:00
Wayne Stambaugh 55ce984f05 Minor design rule editor dialog layout improvements.
Fix the alignment of the unit static text control for uVia diameter and
drill size to match the rest of the units static text controls on the
global design rules tab.
2017-08-29 11:15:16 -04:00
Bastian Neumann 9b900ea834 Micro via input fields are enabled when design is loaded
Loading a design with micro vias enabled did check the box for enabling
micro vias in pcbnew. The value input fields for diameter and drill
size were not enabled.

This patch moves the functionality into an new function and calls that
from the onclick event of the checkbox and the init function of the
dialog.
2017-08-29 09:28:25 -04:00
jean-pierre charras 758445e33e Fix a compil warning and a wxASSERT in COLOR4D_PICKER_DLG_BASE 2017-08-28 17:40:26 +02:00
jean-pierre charras e3c64f1f06 Slightly modify keywords used to store color config of Eeschema and Pcbnew, to avoid this config destroyed each time a stable version is run. 2017-08-27 09:06:26 +02:00
jean-pierre charras a557838c61 Fix incorrect refresh of User Interface after running an action plugin, and add comments 2017-08-27 08:13:35 +02:00
jean-pierre charras db3491f382 Ensure filled zones have the minimal clearance given by the netclasses, between 2 copper items.
It also fixes a corner case, when 2 zone with zone clearance = 0 are overlapping with different priorities
(previously, they were shortened)

Fixes: lp:1713028
https://bugs.launchpad.net/kicad/+bug/1713028
2017-08-26 08:55:32 +02:00
Maciej Suminski dd37d05958 Remove Dwgs_User from the always-on-top layer set
Fixes: lp:1713053
* https://bugs.launchpad.net/kicad/+bug/1713053
2017-08-25 17:25:40 +02:00
Maciej Suminski da88ed02e5 Fix bom2grouped_scv BOM template
For empty or undefined fields the quotation mark was not closed.
2017-08-25 17:06:32 +02:00
Mathias Grimmberger ffeba9de93 Change track width setting to dropbox 2017-08-25 16:46:49 +02:00
Wayne Stambaugh ee43728b18 Fix bug when adding symbol library with $ as first character of path name.
Test the result of wxFileName::MakeRelativeTo() before testing to see if
the resulting relative path starts with '.'.  When a library with relative
path that contains a path name with $ as the first character,
MakeRelativeTo() calls Normalize() which attempts to do an environment
variable substitution that concatenates consecutive paths i.e. the path
/foo/$bar ends up being foo$bar which is obviously incorrect.  This fix
is only a fix for absolute paths and files that contain path names that
begin with $.  This still does not resolve the issue when adding a
library file relative to one of the search paths that contains a path
name that begins with a $.  Fixing this would potentially break paths
that are expecting environment variable substitution.

Fixes lp:1712361

https://bugs.launchpad.net/kicad/+bug/1712361
2017-08-24 11:37:10 -04:00
Maciej Suminski 7ce86e0da5 Fix crash when duplicating an item in FP editor
Fixes: lp:1712828
* https://bugs.launchpad.net/kicad/+bug/1712828
2017-08-24 16:31:31 +02:00
Wayne Stambaugh 17b8342dc0 Disable drawing schematic sheet bounding box. 2017-08-24 08:22:03 -04:00
Wayne Stambaugh 33048e709a Better fix for schematic sheet re-sizing bug.
Use sheet pin direction to calculate sheet minimum height and width.

Remove sheet pin offsetting as the new sheet height and width calculation
prevents invalid minimums.
2017-08-23 18:33:27 -04:00
Wayne Stambaugh e176fc181d Fix schematic sheet resizing bug.
Calculate the proper minimum height when resizing sheets to prevent resized
sheet height from always increasing.

Prevent the sheet pins from being drawn in the corners of the sheet when
updating the edge constraints on resize.  This ensures that the sheet pin
is always drawn within the bounds of the sheet.  Please note that this fix
may not be 100% accurate as is assumes the default grid size of 50 mils.
This may not be what the user expected but it guarantees that wires will
connect to the pin properly.

Fixes lp:1699796

https://bugs.launchpad.net/kicad/+bug/1699796
2017-08-23 13:19:31 -04:00
Maciej Suminski 57619956e8 One more fix for LIB_BEZIER::Save() 2017-08-23 16:04:23 +02:00
Tomasz Włostowski aeac415599 router: hopefully a proper fix for the dragging issue 2017-08-22 19:33:38 +02:00
Tomasz Włostowski 60fdc6229d router: fixed inline dragging & settings dialogs inconsistency 2017-08-22 16:44:58 +02:00
Maciej Suminski 31ef52a365 Fix fine-grid cursor movement using arrow keys
Fixes: lp:1497976
* https://bugs.launchpad.net/kicad/+bug/1497976
2017-08-22 15:14:33 +02:00
Maciej Suminski d4fddf1929 Fix eeschema crash when saving LIB_BEZIER objects 2017-08-22 13:29:53 +02:00
jean-pierre charras 93e8433412 Fix a incorrect initialization of a zone parameter (had no consequence with the current code) 2017-08-22 12:02:07 +02:00
Maciej Suminski 55c7d9816e Traverse 3D viewer plugin subdirectories in debug build directory
Before the change, the plugins had to be installed to one of the default
search paths, but it should not be necessary for developers working on
3D viewer plugins.
2017-08-21 14:17:01 +02:00
Maciej Suminski 91ed3e2bae VERTEX_CONTAINER documentation update 2017-08-21 13:30:35 +02:00
Maciej Suminski b5db6a7d5d Map/unmap vertices once per layer order update
Multiple memory map/unmap operations cause a significant delay on
GPUs that fetch vertices from RAM.

Fixes: lp:1701936
* https://bugs.launchpad.net/kicad/+bug/1701936
2017-08-21 13:28:09 +02:00
Chris Pavlina a20cce0753 Show component history at the top and preselect it
This was the behavior before the factoring out of COMPONENT_TREE. Moving
the history at the top just required inserting it at the right point;
fixing preselect involved wxEVT_INIT_DIALOG not propagating to the
panel. Simple solution was to move the parts of that event handler to
the constructor as they didn't have to be in an event handler anyway.

Fixes: lp:1707538
* https://bugs.launchpad.net/kicad/+bug/1707538
2017-08-19 00:41:21 -06:00
jean-pierre charras 6be2f2934e Exchange footprint dialog uses now the reporter widget for a better report of actions and errors.
Fixes: lp:1711379
https://bugs.launchpad.net/kicad/+bug/1711379
2017-08-18 20:26:45 +02:00
jean-pierre charras 28c04cbbf5 Fix filename in a include 2017-08-18 16:56:49 +02:00
jean-pierre charras d8a59307e3 remove unused .svg file 2017-08-18 16:16:50 +02:00
jean-pierre charras 4c9d0b9c0a Refactor About dialog:
Code refactor
Fix coding style issues
Add a button to display the build version info, and add a tooltip to the copy button.
2017-08-18 16:16:48 +02:00
Maciej Suminski 6ff065fa63 Fixed recognition of GPUs not handling glMapBuffer() efficiently
Fixes: lp:1685335
* https://bugs.launchpad.net/kicad/+bug/1685335

Fixes: lp:1683041
* https://bugs.launchpad.net/kicad/+bug/1683041
2017-08-18 15:02:46 +02:00
Maciej Suminski 077fb3c294 Clearer message for exchange footprint failure 2017-08-18 09:08:07 +02:00
Chris Pavlina d25fdfdb89 Fix wx assertion for excess "|" in wildcard list 2017-08-17 22:48:05 -06:00
Tomasz Włostowski 667d32c4ab router: fixed snapping to end items 2017-08-17 22:54:55 +02:00
jean-pierre charras 4d0c1577d2 Fix Pcbnew Python: LoadBoard does not rebuild connectivity database, and later, SaveBoard does not save net class memberships
Fixes: lp:1711268
https://bugs.launchpad.net/kicad/+bug/1711268
2017-08-17 18:00:34 +02:00
Maciej Suminski 352919658d Refactored LIB_PART data storage
Instead of keeping all items in a boost::ptr_vector(), LIB_ITEMs are now
stored in an integer (KICAD_T) to LIB_ITEMS map.

The map allows to quickly access a subset of items of given type.
As the items are stored per type, there is no need to call
LIB_ITEMS::sort() to assure the correct drawing order. As a result,
libraries load faster.

To retain the old interface, there is a LIB_ITEMS_LIST wrapper for
the map, allowing the developers to access the items as if it was a flat
list-like structure.
2017-08-16 16:05:22 +02:00
Seth Hillbrand 90873a101b router: update status message on meander spacing/amplitude hotkeys
Fixes: lp:1710266
* https://bugs.launchpad.net/kicad/+bug/1710266
2017-08-16 14:16:20 +02:00
Tomasz Włostowski 53f6228ef4 ignore precompiled headers & other temporary file in .gitignore 2017-08-16 14:11:27 +02:00
Tomasz Włostowski d5bdcd3032 router: fixed no-snapping issue 2017-08-16 14:11:07 +02:00
Fabrizio Tappero f12b19dd89 delete library upgrade icon and make two new icons for the archive footprint menu in pcbnew 2017-08-15 19:48:52 +02:00
jean-pierre charras 4465c175a0 Pcb_calculator: Minor enhancement in transline page 2017-08-15 19:46:37 +02:00
jean-pierre charras 0999b5cb77 Make texts search-able in PDF files (using invisible texts behind stroked texts) 2017-08-15 15:53:00 +02:00
Maciej Suminski 9447181a08 Handle block selection removal of libraries in FP_LIB_TABLE dialog 2017-08-15 11:56:05 +02:00
Wayne Stambaugh 0e41632105 Fix build error.
Bind() and Unbind() require class specification when passing a pointer to a
class member.
2017-08-12 12:10:47 -04:00
Wayne Stambaugh f781691049 Eeschema: add symbol library table editor dialog.
Create a new dialog to edit global and project specific symbol library
tables.

Add menu entries for new symbol library table editor in schematic editor
and symbol library editor main frame menus.

Add command event handler for symbol library table editor dialog to
SCH_BASE_FRAME so it is accessible from derived frames.

Fix bug in default environment variables initialization.  A test for
existing user defined environment variables was preventing any new
default environment variables added to the list from being initialized.
2017-08-12 08:10:34 -04:00
jean-pierre charras 84f1c8e0c6 color4Dpickerdlg.cpp: avoid selecting accidentally a new color when the mouse cursor is inside a color map when opening the dialog 2017-08-12 07:52:15 +02:00
jean-pierre charras 356f607cd6 fix compil warnings and replace assert by wxASSERT in dialog_track_via_properties.cpp 2017-08-11 11:38:06 +02:00
jean-pierre charras b0bfbd4f41 Gerbview: remove analysis of fully outdated (and never used) gerber commands 2017-08-11 11:21:33 +02:00
jean-pierre charras 6bdc9cd25e fix a minor issue in dialog netlist, and add comments in code. 2017-08-11 09:44:06 +02:00
jean-pierre charras 9485a4d381 Pcbnew, dialog export STEP: fox not working export in countries using the comma as floating point separator.
Add origin at board center and serious cleaning code.
2017-08-10 14:25:31 +02:00
jean-pierre charras 81a4182319 Fix a not easy to translate message 2017-08-10 09:48:17 +02:00
Fabrizio Tappero b45af7f428 minor icons fix 2017-08-09 15:44:16 -04:00
Wayne Stambaugh 15478bda41 Fix various STEP export dialog issues.
The file filter wild card was defined incorrectly causing the file picker
to not display *.stp and *.step file extensions.  Change the wildcard per
wxFileDialog documentation.

Prevent the file extension from being forced to .stp even when the user
defined a different extension in the file picker.

Override TransferDataFromWindow to test for file existence and warn user
only once if a file overwrite can occur.

Minor STEP export dialog string and layout improvements.

Make kicad2step honor user's file extension rather than always setting it
to .stp.

Fixes lp:1709636

https://bugs.launchpad.net/kicad/+bug/1709636
2017-08-09 13:41:07 -04:00
jean-pierre charras 8a1a3ed36c Better fix for compil problems in utils.cpp 2017-08-09 15:30:01 +02:00
jean-pierre charras 7ab6368869 Fix compil problems in utils.cpp, to be compatible with msys2/windows and linux. 2017-08-09 14:05:10 +02:00
Maciej Suminski 6701095855 Fixed a method returning reference to a local variable 2017-08-09 14:03:27 +02:00
jean-pierre charras 0f219dc40c Fix a compil warning when compiling pcbnew_wrap.cxx 2017-08-09 11:55:12 +02:00
jean-pierre charras 9bb43a89ba Pcbnew: keep layer manager synchronized with board items visibility after switching to a new canvas. 2017-08-09 09:48:56 +02:00
jean-pierre charras 068f96f2ce Fix untranslatable empty string 2017-08-09 08:29:30 +02:00
Maciej Suminski 6d5282cd60 Removed unnecessary dots in pcbnew menu entries 2017-08-08 17:34:46 +02:00
Maciej Suminski 53204e097a Reenable pad enumeration by clicking
Fixes: lp:1708231
* https://bugs.launchpad.net/kicad/+bug/1708231
2017-08-08 16:47:07 +02:00
Maciej Suminski c18d148589 Moved VERTEX_CONTAINERs intialization to the constructors 2017-08-08 15:33:57 +02:00
Maciej Suminski 4ae29aa693 Fixed a shadowing variable warning 2017-08-08 15:31:45 +02:00
Maciej Suminski 2697a21a7a Yet another try for correct function signature type cast 2017-08-08 15:26:50 +02:00
Maciej Suminski ef6910faa9 Take two for satisyfing picky compilers (casting nullptr to void*) 2017-08-08 14:53:34 +02:00
Maciej Suminski e91ce300fb Cast nullptr to const void* to satisfy picky compilers 2017-08-08 14:47:27 +02:00
Maciej Suminski 262fcc91af Fixes for video cards unable to use gl{Un,}MapBuffer correctly
Fixes: lp:1685335
* https://bugs.launchpad.net/kicad/+bug/1685335

Fixes: lp:1683041
* https://bugs.launchpad.net/kicad/+bug/1683041
2017-08-08 14:26:05 +02:00
Maciej Suminski 46b5575c51 OpenGL driver debug routines 2017-08-08 09:31:57 +02:00
Tomasz Włostowski 2d9ab80b4e Few improvements to the GAL router:
- missing 'break track' functionality
- 'drag 45 degree' and 'drag free angle' context menu shorcuts, both in the router tool and in the default context menu
- bugfix: length tuner tool can now be used again

Fixes: lp:1708386
* https://bugs.launchpad.net/kicad/+bug/1708386

Fixes: lp:1708402
* https://bugs.launchpad.net/kicad/+bug/1708402
2017-08-07 14:28:46 +02:00
Maciej Suminski 9aaea050b9 Do not stop dragging after a rotation command
Fixes: lp:1708876
* https://bugs.launchpad.net/kicad/+bug/1708876
2017-08-07 10:02:10 +02:00
Maciej Suminski ef22c2589d Store forced cursor position in VC_SETTINGS 2017-08-07 08:59:32 +02:00
Maciej Suminski e8345dce51 Display GRID_HELPER auxiliary axes and snap points 2017-08-07 08:59:32 +02:00
jean-pierre charras b8c621a991 fix a few Coverity warnings. 2017-08-06 14:23:03 +02:00
jean-pierre charras 4e96f9990d Use the new color4Dpicker to choose a color in Eeschema.
However, the opacity is not modifiable because the wxDC used in Eeschema does not know the alpha channel.
2017-08-06 10:42:11 +02:00
jean-pierre charras 2e96a5bc9f Pcbnew: fix a crash when editing footprint properties and trying to open the footprint 3D properties.
This was due to a missing initialization of the dummy board color settings (used to draw the footprint in the 3D view).

Fixes: lp:1708712
https://bugs.launchpad.net/kicad/+bug/1708712
2017-08-05 16:37:51 +02:00
Wayne Stambaugh 7bf9f8e1c7 Eeschema: add global symbol library configuration dialog.
Create a dialog to give the user options to configure the global symbol
library table the first time Eeschema is run when no global symbol library
table exists.
2017-08-04 15:51:53 -04:00
jean-pierre charras 8dacd0582a Make a few internal error strings not translatable 2017-08-04 20:43:31 +02:00
jean-pierre charras aa3a1267ea Fix compil warnings 2017-08-04 17:46:18 +02:00
Tomasz Włostowski 32185ddcd3 Multiple improvements concerning colors, configuration handling and legacy features in pcbnew:
- support for background color setting
    - removed several global config settings (such as g_Drc_On)
    - wrapped most of global config settings in PCB_GENERAL_SETTINGS class
    - reorganized PCB general options dialog to clearly mark which options concern only the legacy canvas
    - new GAL feature for legacy users: double-click (or E) to change track width available as an option.

Fixes: lp:1530543
* https://bugs.launchpad.net/kicad/+bug/1530543

Fixes: lp:1707145
* https://bugs.launchpad.net/kicad/+bug/1707145
2017-08-04 16:06:57 +02:00
jean-pierre charras 33e05ae557 Avoid to change the alpha channel color value initially set in GAL mode when modifying a color in legacy mode. 2017-08-04 09:48:08 +02:00
Maciej Suminski 3570154ef0 Fixes to speed select/deselect commit (161045f1)
Deselecting items require full refresh, as otherwise e.g.
umbilical lines for modules stays.
2017-08-03 16:14:46 +02:00
Maciej Suminski 71c33d3dcd Fixes for canceling selection after invoking menu on an unselected item (9cbcb322) 2017-08-03 14:28:07 +02:00
Maciej Suminski 3629fcbf4a Code formatting 2017-08-03 14:28:07 +02:00
Wayne Stambaugh 9760937494 Pcbnew: add missing file and directory overwrite prompts.
Fix the Specttra, VRML, and IDF export dialogs to prompt the user when they
are about to overwrite and existing file and/or folders.

Fixes lp:1706235

https://bugs.launchpad.net/kicad/+bug/1706235
2017-08-02 13:31:29 -04:00
Kristoffer Ödmark 42b70b86f2 added more layer selector features 2017-08-02 10:53:08 -04:00
Wayne Stambaugh 34abef3f5a Fix build error caused in previous commit. 2017-08-01 17:21:03 -04:00
Wayne Stambaugh 863db59a3d Eeschema: improve schematic symbol message panel information.
Add information when dummy symbol is used for library symbols that could
not be found to give the user some useful information to help track down
the broken link rather than display an empty message panel.
2017-08-01 15:34:59 -04:00
Maciej Suminski 30ad7e4f99 Improved the algorithm for guessing the selection candidates
Now it filters out items that are bigger than the current viewport
2017-08-01 18:00:30 +02:00
Maciej Suminski efdf0c6b84 Parameter tuning for hiding dynamic ratsnest 2017-08-01 17:57:18 +02:00
Maciej Suminski 9cbcb3224c Cancel selection if an item has been selected by right click 2017-08-01 15:23:08 +02:00
Maciej Suminski f303bf2999 Hide temporarily ratsnest when it is too complex for real-time calculation 2017-08-01 15:22:24 +02:00
Maciej Suminski 1ac34b44bf Removed explicit calls to update ratsnest from EDIT_TOOL 2017-08-01 15:22:23 +02:00
jean-pierre charras 1f6854f2b8 Make internal errors messages not translatable 2017-08-01 13:12:59 +02:00
jean-pierre charras 816307e500 Pcbnew plot: fix a few minor issues:
- SVG export: fix color of PCB texts.
- Avoid marking board as modified after plotting layers, when options not saved in board are modified.
2017-07-31 20:05:32 +02:00
jean-pierre charras 557e69f72a Fix many minor issues in dialog plot and plot DXF options. 2017-07-31 20:05:32 +02:00
jean-pierre charras abe2a46ae7 Pcbnew: Fix plot PDF, broken by commit f3457794cf
Also disable option to use native font in PDF and PS plotter format, because this option has never worked.

Fixes: lp:1707412
https://bugs.launchpad.net/kicad/+bug/1707412
2017-07-31 20:05:30 +02:00
Maciej Suminski 67ae5935d6 Perform tool reset twice when reloading a board
The first one is to remove any references to the removed items, the
second one is to setup the new model.

Fixes: lp:1692257
* https://bugs.launchpad.net/kicad/+bug/1692257
2017-07-31 15:09:19 +02:00
Maciej Suminski 76bd05a69b Prevent creating too many transitions by TOOL_MANAGER
- added TOOL_INTERACTIVE::resetTransitions()
- made protected and moved TOOL_BASE::setTransitions() to TOOL_INTERACTIVE
- TOOL_MANAGER calls TOOL_INTERACTIVE::resetTransitions() instead of
setTransitions()
2017-07-31 15:09:19 +02:00
Maciej Suminski 9e385872a0 Remove an excessive VIEW::Update() call 2017-07-31 15:09:19 +02:00
jean-pierre charras e10f0c729b Fix minor compil warnings 2017-07-30 14:24:21 +02:00
Maciej Suminski 75cda5021d Assure that NETINFO_ITEMs have a NETCLASS object assigned
Fixes: lp:1705896
* https://bugs.launchpad.net/kicad/+bug/1705896
2017-07-28 16:03:53 +02:00
Michael 2206d51b82 libcontext FreeBSD compatibility fix
Fixes: lp:1671083
* https://bugs.launchpad.net/kicad/+bug/1671083
2017-07-28 14:25:55 +02:00
Simon Richter d41af7db7d Legacy handling for Via tool
This tool isn't available in the Legacy canvas, but we still need to handle
the selection event and show an appropriate error message if the tool is
used.
2017-07-28 11:31:28 +02:00
Simon Richter d2860ee0ad Update FindGLEW.cmake 2017-07-28 11:30:22 +02:00
Maciej Suminski 2652cfeafd Restore the cursor position after the context menu is closed
Fixes: lp:1696328
* https://bugs.launchpad.net/kicad/+bug/1696328
2017-07-28 10:55:38 +02:00
Maciej Suminski 7399759b3b Fixed polygon DRAWSEGMENT rendering in OpenGL GAL
Fixes: lp:1704542
* https://bugs.launchpad.net/kicad/+bug/1704542
2017-07-28 10:34:47 +02:00
Maciej Suminski acbfea48f2 Fixed a bug allowing to drag locked footprints without approval
Fixes: lp:1576655
* https://bugs.launchpad.net/kicad/+bug/1576655
2017-07-27 17:13:22 +02:00
Tomasz Włostowski 50bb9ce665 pcbnew: catch exceptions for missing modules during netlist update to avoid silent failure on first missing footprint 2017-07-27 16:21:54 +02:00
Tomasz Włostowski b682882807 pcbnew: add keyboard shortcuts [1..9] to the selection disambiguation menu 2017-07-27 16:21:54 +02:00
Tomasz Włostowski b964569db7 pcbnew: enable net selection combobox in Track/Via properties dialog 2017-07-27 16:21:54 +02:00
Maciej Suminski 7b88dac4b7 Consistent track removal for PNS and selection tool
Fixes: lp:1705676
* https://bugs.launchpad.net/kicad/+bug/1705676
2017-07-27 16:20:19 +02:00
Maciej Suminski 950d87a920 Removed boost::adaptor from ACTION_MANAGER 2017-07-27 16:06:30 +02:00
Maciej Suminski 3ee2f80188 Drag footprints by pads only if one is under the cursor 2017-07-27 11:13:25 +02:00
Maciej Suminski 545a80839b Removed an excessive selection request from EDIT_TOOL 2017-07-27 10:56:26 +02:00
Maciej Suminski 75f68061a4 Save the drag origin only on the first click 2017-07-27 10:54:08 +02:00
jean-pierre charras 58c32367ee filter useless autosave tests, and optimization of autosave test in Eechema 2017-07-26 18:06:04 +02:00
jean-pierre charras f9abb112af Fix possible crash after reading a netlist
Fixes: lp:1705912
https://bugs.launchpad.net/kicad/+bug/1705912
2017-07-26 18:06:03 +02:00
jean-pierre charras 9044b5eeac Pcbnew VRML export: typing in filename textbox steals focus, making filename change very hard.
Fixes: lp:1706228
https://bugs.launchpad.net/kicad/+bug/1706228
2017-07-26 18:06:01 +02:00
Dick Hollenbeck a5f57d8b0b Add CMakeLists.txt build support for tools/utf8_tests.cpp 2017-07-26 10:11:40 -04:00
Dick Hollenbeck 19e6bde09a Rewrite class UTF8 to contain rather than extend std::string storage.
This forces the compiler class specific features rather than borrowing
from the base class's std::string.  In some cases prior to this,
wxString( std::string ) was being called rather than UTF8::operator
wxString() leading to garbled wxStrings.

Added function UTF8::wx_str() which is of great convenience also.

Implicit conversions still work as before, and hopefully more reliably.
2017-07-26 08:30:12 -04:00
Dick Hollenbeck 0aedaffed9 add utf8_test.cpp to project 2017-07-26 08:29:36 -04:00
Dick Hollenbeck 4e7de8a761 Reverse commit 4011ed4e31.
This commit was too broad and not cognizant of the purpose of the class
UTF8.

Add MAYBE_VERIFY_UTF8() macro, which can trap non-UTF8 encoded strings in
debug builds.

Use that macro conditionally in class UTF8 to trap non-UTF8 encoded strings
being put into UTF8 instances.
2017-07-26 08:26:56 -04:00
Oliver Walters 161045f17d Speed improvement for select / deselect in GAL
- No longer invalidates the item layers
- For multiple items, this results in a drastic speed improvement
2017-07-25 16:34:03 +02:00
Oliver Walters c27f5b725d Improved various error messages
- Moved developer "jargon" to details pane
- Changed error messages to "WHAT" rather than "WHY" or "WHERE"
2017-07-25 07:37:14 -04:00
Oliver Walters a0a3ca6646 Added extra information to error and info messages
Optional extra information string which is displayed in a drop-down "details" box
2017-07-25 07:37:13 -04:00
jean-pierre charras 6d52987928 Gerber files creation: fix an incorrect structured comment ('*' was missing at the end of line) 2017-07-25 11:50:24 +02:00
jean-pierre charras 2d5607a11d Fix issues in plot functions, when used from python scripts. 2017-07-25 11:49:16 +02:00
jean-pierre charras 622ba4f11b kicad: create zip archive: test for write file error 2017-07-24 09:20:44 +02:00
jean-pierre charras cb2f3d6304 fix minor typo 2017-07-22 13:46:18 +02:00
jean-pierre charras f042fcddd0 Change the way power symbols are annotated before creating a netlist or running ERC.
Now only not annotated symbols (or duplicate references) are modified.
2017-07-21 18:41:04 +02:00
Fabrizio Tappero f453cec938 Changed all Rotate 90 deg CW with Rotate Clockwise. Changed all Rotate 90 deg CCW with Rotate Counterclockwise 2017-07-21 10:28:44 -04:00
Fabrizio Tappero 77837bb281 better via icon and move relative icon
Signed-off-by: Fabrizio Tappero <fabrizio.tappero@gmail.com>
2017-07-21 10:28:43 -04:00
Fabrizio Tappero deeeed38a1 deleted several redundant icons in right-click menu. The objective is to get to a more uniforme right click menu look
Signed-off-by: Fabrizio Tappero <fabrizio.tappero@gmail.com>
2017-07-21 10:28:42 -04:00
Fabrizio Tappero cef616fcd8 fixed text titles that should have only the first word capitilized 2017-07-21 10:19:29 -04:00
Fabrizio Tappero 269238a7ee fixes label text, now only first word is capitilized 2017-07-21 10:19:29 -04:00
Fabrizio Tappero 7be14f774d fixed plot menu labels 2017-07-21 10:19:29 -04:00
Maciej Suminski 6f8f6f18f6 Additional checks for item validity in CONNECTIVITY
Fixes: lp:1705455
* https://bugs.launchpad.net/kicad/+bug/1705455
2017-07-21 11:40:37 +02:00
jean-pierre charras c290e8a33b disable zone dump (this dump is enabled only for zone fill debug) 2017-07-21 08:40:58 +02:00
Chris Pavlina c78a2ba4f8 Render symbols correctly with convert=0 in chooser
Fixes: lp:1705315
* https://bugs.launchpad.net/kicad/+bug/1705315
2017-07-19 11:43:39 -06:00
Chris Pavlina 04d299ae0e libedit: add correct unit/convert from component chooser
Fixes: lp:1705073
* https://bugs.launchpad.net/kicad/+bug/1705073
2017-07-19 11:35:11 -06:00
Chris Pavlina e34f1222fa Fix LIB_VIEW_FRAME only returning Unit A
Due to library list repopulation on refresh, the unit was being
overwritten with 1. Now, we track whether the unit needs to be
overwritten.

Fixes: lp:1677736
* https://bugs.launchpad.net/kicad/+bug/1677736
2017-07-19 11:12:14 -06:00
Wayne Stambaugh be109575ce Pcbnew: minor menu string capitalization fix. 2017-07-19 12:33:48 -04:00
jean-pierre charras 242c47ffd4 Pcbnew: Fix incorrect initialization of a variable in MODULE_EDITOR_TOOLS::EnumeratePads().
This issue is due to an unexpected behavior of evt->IsClick( BUT_LEFT ) used in this method,
which detect a mouse release button and not a mouse click down.

Fixes: lp:1700197
https://bugs.launchpad.net/kicad/+bug/1700197
2017-07-19 16:00:25 +02:00
Maciej Suminski fe89fdfb24 Removed incorrectly defined assert 2017-07-19 13:05:30 +02:00
Maciej Suminski f942e3e31f Fixed a crash when items are unselected when dragging
Fixes: lp:1702355
* https://bugs.launchpad.net/kicad/+bug/1702355
2017-07-19 13:00:51 +02:00
Maciej Suminski 64f00f447f pcbnew - refactor move exactly tool (3/2)
* code formatting
* turned EDIT_TOOL::getAnchorPoint() to static getAnchorPoint()
* removed unnecessary include directives
2017-07-19 11:36:35 +02:00
Robbert Lagerweij b7f2525c5d pcbnew - refactor move exactly tool (2/2)
This patch does the following:
* extracts a method to determine the anchor point of the move
* improves the logic of the anchor point determination for selections of multiple objects which do not contain footprints
2017-07-19 11:36:35 +02:00
Robbert Lagerweij bf832dd941 pcbnew - refactor move exactly tool (1/2)
This patch does the following:
* move the determination of the origin coordinates to the dialog (reduces code duplication)
2017-07-19 11:36:35 +02:00
jean-pierre charras cb75b72978 Refinements if new color 4D selector 2017-07-19 11:26:28 +02:00
Oliver Walters 8debf32079 Added partial selection for VIA class 2017-07-19 11:04:32 +02:00
Maciej Suminski a8e63924de Fixed a memleak in BOARD_NETLIST_UPDATER 2017-07-19 10:55:57 +02:00
Maciej Suminski 984ac70106 Added COMMIT::GetStatus() and minor refactor
Moved duplicated code to a new function and added
an assert to warn against possible memory leak.
2017-07-19 10:46:10 +02:00
jean-pierre charras 5f4599fb56 Add a new color selector, to adjust color selection for GAL mode, with support of opacity (alpha channel)
Pcbnew: save opacity value in color config, and keep it when switching between legacy and gal mode.
2017-07-18 19:07:47 +02:00
Oliver Walters f509ccc7cf Search component footprint text
- Added footprint text to search string for each component.
2017-07-18 08:58:03 -04:00
Chris Pavlina 94b9524f6d Fix documentation error in DIALOG_CHOOSE_COMPONENT 2017-07-17 15:00:13 -06:00
Chris Pavlina 5755582c53 Minor FOOTPRINT_FILTER fix 2017-07-17 15:00:13 -06:00
Maciej Suminski 10c5297f2e Code clean-up and formatting 2017-07-17 10:21:39 +02:00
Maciej Suminski 8dd36b4d2b Added type filtering for CONNECTIVITY_DATA::GetNetItems() 2017-07-17 10:21:39 +02:00
Kristoffer Ödmark 4c94d02c42 Fixed sheet-selection code
Fixes: lp:1704644
* https://bugs.launchpad.net/kicad/+bug/1704644
2017-07-17 10:21:39 +02:00
jean-pierre charras ed66496242 Fix an issue (created by commit 16cb6a6ca0) when converting a color4D to a legacy color
Fixes: lp:1704724
https://bugs.launchpad.net/kicad/+bug/1704724
2017-07-17 09:59:34 +02:00
jean-pierre charras e797af3315 fix compil warning 2017-07-16 20:01:35 +02:00
jean-pierre charras 16cb6a6ca0 color4d: fix incorrect conversion from rgb to HSV when r = g = b. 2017-07-16 17:10:24 +02:00
jean-pierre charras d3b382c281 GAL mode: the grid don't fill the full screen when moving the grid origin to negative values.
Fixes: lp:1703330
https://bugs.launchpad.net/kicad/+bug/1703330
2017-07-14 20:18:37 +02:00
jean-pierre charras 22e95aab8b WIZARD_3DSHAPE_LIBS_DOWNLOADER: make it compatible with last url packages3D changes in kicad github repo 2017-07-14 13:34:42 +02:00
Wayne Stambaugh 0633d90ae4 Remove leading/trailing white space error message from field validator.
The illegal white space testing for reference and value (library editor
only) fields are adequate to ensure the user cannot enter invalid white
space characters.  Leading and/or trailing white space should not be an
issue for field storage in the schematic file as they are quoted.  Rather
than silently removing the leading and/or trailing white space which is
frowned upon, let the user fix it.

Fixes lp:1659526

https://bugs.launchpad.net/kicad/+bug/1659526
2017-07-13 13:45:25 -04:00
Wayne Stambaugh e01eb29758 Symbol and footprint library table parser fixes.
Fix potential memory leak in both footprint and symbol library table
parsers when a duplicate library nickname entry exists.

Parse entire symbol library table before raising duplicate nickname
exception.

Improve the duplicate library table nickname error message to make
life easier for users to fix broken tables.
2017-07-13 10:09:38 -04:00
Maciej Suminski d5095252a0 eeschema: Fixed use-after-free on exit when paste operation is aborted 2017-07-13 13:33:13 +02:00
jean-pierre charras c93ab4d5da Fix possible crash and issues when a incorrect fp lib table is loaded:
correct lines are loaded, and pcbnew / eeschema is no more aborted.
Fixes: lp:1701627
https://bugs.launchpad.net/kicad/+bug/1701627
2017-07-12 20:24:35 +02:00
jean-pierre charras 459fd9e584 Better fix for bugs 1703258 and 1702707: better detection of cache lib modifications, not always detected previously.
The component to symbol links were previously not always updated after a library change,
if the change is made outside the library editor.
2017-07-12 16:07:08 +02:00
Maciej Suminski 08c4a0bc7b Fixed SELECTION_TOOL::selectCursor()
In the previous version the method did not work correctly
when an action was invoked from context menu. In such case,
the cursor position was obtained in the moment of selecting
the action, instead of using the right click location.
2017-07-12 09:34:20 +02:00
jean-pierre charras 2a301d5883 Fix bug: pcbnew: in Plot dialog, layer list gets duplicate after calling the drill dialog.
Fixes: lp:1703355
https://bugs.launchpad.net/kicad/+bug/1703355
2017-07-10 15:16:57 +02:00
Maciej Suminski a3fc0ef658 Fixed a memleak in Eagle board import plugin 2017-07-10 11:44:56 +02:00
jean-pierre charras d7a4fb7d8b Fix a crash in Eeschema when creating a netlist just after saving the project.
This is more a workaround than a fix.
The crash was due to the fact the library cache is modified on the disk with the saving process.

Fixes: lp:1702707
https://bugs.launchpad.net/kicad/+bug/1702707
2017-07-09 20:17:18 +02:00
jean-pierre charras 83b4e45eb4 Fix a memory leak, if an error occurs. 2017-07-09 10:16:00 +02:00
jean-pierre charras f4ecc417ac Fix a few doxygen warnings 2017-07-08 21:13:32 +02:00
jean-pierre charras 895c0bb716 Fix a compil warning and a wxASSERT in netlist dialog and component_tree.cpp 2017-07-08 15:58:22 +02:00
Jean-Samuel Reynaud 885a4c1bc5 Avoid an infinite loop in PNS
Fixes: lp:1702485
* https://bugs.launchpad.net/kicad/+bug/1702485
2017-07-06 16:44:33 +02:00
jean-pierre charras 1724f902a1 Fix incorrect use of iterators.
Iterators always create problems when using them on a list that is modified during iteration.
2017-07-04 12:47:13 +02:00
jean-pierre charras 969209c2cc Fix a few doxygen warnings and add a few comments. 2017-07-04 11:08:27 +02:00
Maciej Suminski 098814e205 Fixed a memory leak in BLOCK_SELECTOR 2017-07-04 10:14:58 +02:00
Maciej Suminski e18475f220 Renamed remaining constants to match the action (see ab44e7cc) 2017-07-04 10:08:33 +02:00
Tomasz Włostowski 2767096cb7 Refresh ratsnest after updating netlist
Fixes: lp:1702175
* https://bugs.launchpad.net/kicad/+bug/1702175
2017-07-04 07:01:16 +02:00
Maciej Suminski 2300697f02 Added 'Cut Block' to right-click menu in eeschema 2017-07-03 18:03:34 +02:00
Maciej Suminski e981eedf64 Renamed cut_button icon to cut, removed delete_text icon 2017-07-03 18:03:34 +02:00
Maciej Suminski ab44e7cc72 Renamed constants to match actions in eeschema 2017-07-03 17:39:07 +02:00
Fabrizio Tappero 0c8200aaeb Rename actions in eeschema: copy->duplicate, save->copy 2017-07-03 17:22:00 +02:00
Fabrizio Tappero 50f6d28e25 Replaced a few icons with generic variants in eeschema 2017-07-03 17:13:13 +02:00
Kristoffer Ödmark 4fb2f80dd4 Eeschema copy/cut/paste to ctrl+c/x/v cut is now undoable Highlight net is now at ctrl+b by default 2017-07-03 16:41:47 +02:00
jean-pierre charras 65fea1b92b Fix crash: pcbnew segfault when show local ratsnest for module is ON if clicking on an empty area.
Fixes: lp:1702021
https://bugs.launchpad.net/kicad/+bug/1702021
2017-07-03 11:06:44 +02:00
jean-pierre charras 43084daa40 Fix a few doxygen warnings 2017-07-03 10:45:56 +02:00
Tomasz Włostowski c01c25b258 Improved ratsnest updates performance during routing 2017-07-02 23:05:23 +02:00
Tomasz Włostowski eea41dbc6f Fixed OSX build error 2017-07-02 22:13:53 +02:00
jean-pierre charras f074b57094 Pcbnew: fix minor issue in %TO.C advanced attribute, and avoid creating an unused D10 tool in Gerber files. 2017-07-02 16:41:31 +02:00
jean-pierre charras 9a2322cfcd New fix for bug 1700331 (Filenames with Double Period Invalid).
The previous fix was building the full name incorrectly, when this name contains a path not relative to the project.

Fixes: lp:1700331
https://bugs.launchpad.net/kicad/+bug/1700331
2017-07-02 10:30:21 +02:00
Tomasz Włostowski c229063d9e Fixed crash when redrawing ratsnest after swapping pad net assignments 2017-07-02 02:05:42 +02:00
Tomasz Włostowski 0f5ab1bc87 Reverted commit 4130083445. 2017-07-02 00:34:41 +02:00
Tomasz Włostowski 1936b45a0f Multiple connectivity algo crash fixes:
- ratsnest crash on single-pad nets
- connectivity crash on adding new net codes
2017-07-01 23:55:51 +02:00
jean-pierre charras 1c5ace4b7a Eagle plugin: avoid hanging if an unexpected keyword is found.
Fixes: lp:1701672
https://bugs.launchpad.net/kicad/+bug/1701672
2017-07-01 16:59:07 +02:00
jean-pierre charras c311e63f0d fix minor issues, and change ZONE_CONTAINER::GetDefaultHatchPitchMils() to ZONE_CONTAINER::GetDefaultHatchPitch()
as using mil in a value has no meaning now in pcbnew
2017-07-01 15:17:30 +02:00
jean-pierre charras 917bda1c64 fix minor compil warnings 2017-07-01 15:17:29 +02:00
Maciej Suminski 3afef4e19d Display an error when pcbnew.kiface is not available for FP selector
DIALOG_COMPONENT_CHOOSE displays footprint preview when pcbnew kiface
is available, but it crashed when it was not in the same directory
as the executable. Now it displays an error message that allows the
user to quickly identify the problem.

Fixes: lp:1695005
* https://bugs.launchpad.net/kicad/+bug/1695005
2017-06-30 23:01:21 +02:00
jean-pierre charras 5d252639fa Refinement in Gerber drill file: add %TF.FilePolarity,Positive*% in header. 2017-06-30 18:36:26 +02:00
jean-pierre charras e3d69b619f Pcbnew: fix issue in dialog_fp_lib_table: when the only changes were the plugin name, changes were not taken in account.
Because the FP_LIB_TABLE::operator == was incorrect
2017-06-30 16:03:17 +02:00
jean-pierre charras 22a8df69c4 Fix a few doxygen warnings 2017-06-30 16:03:17 +02:00
Maciej Suminski 805bfb048b pcbnew: Configurable hotkeys for PNS
- routing options
- custom track/via size
- differential pair dimensions
- increase/decrease via size
2017-06-30 15:46:27 +02:00
hauptmech 4e908da057 pcbnew: Add hotkeys for Select Trivial Connection and Select Copper Connection 2017-06-30 14:30:10 +02:00
Maciej Suminski da051379de pcbnew: Fixed crash on updating net list
As CONNECTIVITY_DATA was not updated during the process,
it contained stale pointers leading to crash. Now the connectivity
is updated as the changes occur.

Another issue was the single pad net removal algorithm
relied on sorting pads by net name. The algorithm has been rewritten
to take advantage of the new algorithm.

Fixes: lp:1700269
* https://bugs.launchpad.net/kicad/+bug/1700269
2017-06-30 14:13:56 +02:00
Maciej Suminski adf4f83cb0 Code formatting and clean-up 2017-06-30 14:10:18 +02:00
hauptmech 20b4226a25 Router recognizes busses of differential pairs
Fixes: lp:1443330
* https://bugs.launchpad.net/kicad/+bug/1443330
2017-06-30 11:16:24 +02:00
Tomasz Włostowski d6820bc925 Fixed segfault in connectivity algo for boards with orphaned nets
Fixes: lp:1701347
* https://bugs.launchpad.net/kicad/+bug/1701347
2017-06-30 00:46:24 +02:00
jean-pierre charras bafb8c3688 Add old python method FootprintEnumerate which did not word after changes in C++ code 2017-06-29 20:43:39 +02:00
Seth Hillbrand 8201e2cbff Footprint editor crashes when deleting pads and undoing this command.
Fixes: lp:1701092
https://bugs.launchpad.net/kicad/+bug/1701092
2017-06-29 20:43:38 +02:00
Wayne Stambaugh 4130083445 Eeschema: fix loading symbol libraries with dot in file name.
Initializing wxFileName objects by using string assignment or the single
string argument ctor will cause wxFileName to parse everything to the
right of the first dot as the file extension.  Therefore, file names such
as foo.1.lib and bar.baz.lib will fail.  This is probably not the only
place in the KiCad source where this can occur.

Fixes lp:1700331

https://bugs.launchpad.net/kicad/+bug/1700331
2017-06-29 10:36:12 -04:00
jean-pierre charras 2237de0153 Gerbview "Always hide all layers but active" context menu selection doesn't work with keyboard
Fixes: lp:1701008
https://bugs.launchpad.net/kicad/+bug/1701008
2017-06-28 18:32:04 +02:00
Wayne Stambaugh 81fcc852b1 Fix Pcbnew plugin developer's document table of contents. 2017-06-28 11:38:44 -04:00
Wayne Stambaugh 0f20dc747f Minor Pcbnew plugin developer's document fixes.
Reformat line width to prevent line wrapping.

Add table of contents and header links.
2017-06-28 11:08:23 -04:00
Simon Kueppers bbef4fee17 Added documentation about pcbnew plugin development 2017-06-28 10:48:41 -04:00
Simon Kueppers d6aad9c6e7 Corrected Typo in documentation of GetClearance function 2017-06-27 16:50:47 -04:00
Wayne Stambaugh 85a0a371b1 Add support to resolve schematic symbol links using symbol library table.
Add Resolve() and ResolveAll() methods the SCH_COMPONENT object to use the
symbol library table to obtain links to the library symbols.

Add LoadAlias() method to SYMBOL_LIB_TABLE to find an alias by it's LIB_ID.

Clean up Doxygen comments to match coding policy changes.
2017-06-27 11:22:58 -04:00
Maciej Suminski 1e87ae6c50 Fixed a memleak in raytracer 2017-06-27 10:58:43 +02:00
Maciej Suminski 37f8c83c5b Fix the BOARD & MODULE classes SWIG interface 2017-06-26 18:28:23 +02:00
jean-pierre charras 3c3ee9b8c3 Fix a few doxygen warnings 2017-06-26 18:12:57 +02:00
Maciej Suminski 5774fd284e pcbnew: Do not sove 'no_connects' and 'area' in .kicad_pcb
These data are redundant as they are calculated by pcbnew.
2017-06-26 08:59:20 +02:00
Maciej Suminski 544e944647 pcbnew: Do not save 'links' information
It is not parsed anyway and the new connectivity algorithm
does not calculate it.
2017-06-26 08:40:50 +02:00
Maciej Suminski ac688e688a Fixed selecting components with Enter (DIALOG_CHOOSE_COMPONENT)
Added dedicated event types: COMPONENT_SELECTED, COMPONENT_PRESELECTED.
2017-06-25 23:13:39 +02:00
jean-pierre charras 6a3c1720b2 Fix a few doxygen warnings 2017-06-25 11:26:04 +02:00
jean-pierre charras 1e770f56a6 Fix a non ASCII7 string in a message. Only ASCII7 chars can be used in sources.
Non ASCII7 symbols are not allowed because the encoding is OS dependent.
2017-06-24 20:05:11 +02:00
jean-pierre charras 0719b99ad8 Minor enhancement in color selection on Windows 2017-06-24 10:45:26 +02:00
jean-pierre charras 5d8dd7c20f Loading python plugins: make subdir import more tolerant to broken python scripts,
and compatible to subdirs that contains other scripts (like .xsl scripts)
2017-06-24 10:15:51 +02:00
Jean-Samuel Reynaud e40de096bc Fix broken directory names building for python plugins 2017-06-24 07:55:27 +02:00
Maciej Suminski 72eff0941e Code formatting and warning fixes 2017-06-23 19:22:44 +02:00
Maciej Suminski 3aaf26da2e Fixes for pcbnew_scripting_helpers.cpp 2017-06-23 19:22:27 +02:00
Maciej Suminski f1d650d5be Use node & unconnected count from CONNECTIVITY object 2017-06-23 18:51:00 +02:00
Maciej Suminski 7b9330129c Update ratsnest lines on zone fill removal 2017-06-23 18:51:00 +02:00
Maciej Suminski 79b2d60666 Reenabled pad number increment on placement (module editor) 2017-06-23 18:51:00 +02:00
Maciej Suminski 7330a85554 Moved INTRUSIVE_LIST to a separate header 2017-06-23 18:51:00 +02:00
Maciej Suminski 450ad5eab9 CONNECTIVITY_DATA::GetNodeCount() implementation 2017-06-23 18:51:00 +02:00
Maciej Suminski 74ef3ecb1d Moved one-liners to header files 2017-06-23 18:51:00 +02:00
Maciej Suminski 3dd4429ef6 Dead code removal 2017-06-23 18:50:31 +02:00
Maciej Suminski f3fbce9560 Code formatting and clean-up 2017-06-23 15:43:13 +02:00
Tomasz Włostowski 113163257d Fixed compilation warnings 2017-06-23 11:36:05 +02:00
Tomasz Włostowski 5c0edbabab Fixes for the connectivity & board cleanup algorithms 2017-06-23 11:12:38 +02:00
Simon Richter f324c7b16d Switch another loop to D_PAD iterator 2017-06-23 11:12:38 +02:00
Tomasz Włostowski a7759efc59 Multiple fixes:
- ratsnest is updated now when undoing in legacy view
- select whole net regression
- local ratsnest in the GAL regression
- pick correct zone net for stitching vias
- mark nets as dirty on net propagation to force ratsnest update

Todo:
- cleanup board algorithm is still broken
2017-06-23 11:12:37 +02:00
Tomasz Włostowski 81dbd930ae Display zone filling progress window in GAL 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 586710c6f5 eagle_plugin: correct via size import 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 655d851d48 Fixed point-in-polygon test bugs. Connectivity now correctly recognizes zone outlines that have non-zero width 2017-06-23 11:12:37 +02:00
Tomasz Włostowski d8018ded0b fix build with Python 2017-06-23 11:12:37 +02:00
Tomasz Włostowski de7f4d7aa4 fixed unresolved symbols while running cvpcb 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 56928647ef fixed performance regression in DRC clearance test 2017-06-23 11:12:37 +02:00
Maciej Suminski 2c68786fa8 Display via net labels on top 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 3b16d3cffe further DLIST/Iterators cleanup, some code formatting 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 63f4ab697b post-rebase fixes 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 3b7b0603b6 pcbnew: via placement tool, initial version 2017-06-23 11:12:37 +02:00
Tomasz Włostowski bd960f0e5c pcbnew/dialogs: more options in track/via properties window 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 706db2a486 pcbnew: draw net labels on vias [wip] 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 96865d45e3 icons for via placement tool 2017-06-23 11:12:37 +02:00
Tomasz Włostowski bfdd1191ab pcbnew: rename PLACEMENT_TOOL to ALIGN_DISTRIBUTE_TOOL, some fixes in the connectivity algo 2017-06-23 11:12:37 +02:00
Tomasz Włostowski c4c329e393 Connectivity: local ratsnest for both legacy & GAL. Further removal of legacy code 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 07b7600ae5 TRACKS_CLEANER: fixes after changing the connectivity algorithm 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 6008abaad9 DRC connectivity check 2017-06-23 11:12:37 +02:00
Tomasz Włostowski edf1aac357 Fixed some compilation warnings. Missing features so far: single-module ratsnest & DRC unconnected report 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 3cba1007eb Removed legacy connectivity/ratsnest algorithm, replaced with the new one. No legacy autorouting for the moment 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 9ad886344b New connectivity algorithm. 2017-06-23 11:12:36 +02:00
Tomasz Włostowski eaba60b89a profile.h: added PROF_COUNTER C++ class 2017-06-23 11:12:36 +02:00
Tomasz Włostowski 94a80acb36 DLIST_ITERATOR improvements 2017-06-23 11:12:36 +02:00
Tomasz Włostowski 08314082db Hide DLISTs behind iterators, first step towards refactoring the storage model 2017-06-23 11:12:36 +02:00
jean-pierre charras 4bdac4de70 Create zones not working in legacy mode, bug created when fixing an other bug in commit 6a63d4
Fixes: lp:1699704
https://bugs.launchpad.net/kicad/+bug/1699704
2017-06-22 12:10:48 +02:00
jean-pierre charras 2c21c70f46 Fix a few doxygen warnings 2017-06-22 09:09:52 +02:00
Wayne Stambaugh 375ec9fec6 Eeschema: remove hierarchy navigation tool from right vertical toolbar.
The hierarchy navigation tool did not seem to be used frequently and was
deemed redundant.
2017-06-21 16:44:46 -04:00
jean-pierre charras 54670d6785 Pcbnew: minor fixes in DIALOG_GLOBAL_MODULES_FIELDS_EDITION.
Better code: use TransferDataFromWindow and remove wxID_OK and wxID_CANCEL custom called events.
2017-06-21 13:13:09 +02:00
jean-pierre charras e5137f4eb4 Fix a few doxygen warnings 2017-06-21 10:01:39 +02:00
jean-pierre charras 70226ecdeb Fix a few doxygen warnings 2017-06-20 10:47:30 +02:00
Maciej Suminski 6733101c6f Flags to select additional widgets for COMPONENT_TREE 2017-06-19 14:48:54 +02:00
Maciej Suminski f667f54c52 Moved component tree widget to a separate class 2017-06-19 14:48:53 +02:00
jean-pierre charras 6a63d4fbff pcbnew crash while opening old .brd file
Fixes: lp:1698697
https://bugs.launchpad.net/kicad/+bug/1698697

The incorrect method ZONE_CONTAINER::AppendCorner() is also fixed:
It was expecting the corner must be added to the main outline, but this is a false expectation:
it can be added to a hole inside the zone outline.
2017-06-19 13:29:57 +02:00
jean-pierre charras d6a56e5d3d fix a compil issue in a auto-generated file. 2017-06-18 22:31:26 +02:00
jean-pierre charras 8305aec8a7 Remove useless leading or trailing spaces is some translatable strings.
rename dialog_move_exact.fpb to dialog_move_exact_base.fpb (to be consistent with other .fpb file names)
2017-06-18 22:26:29 +02:00
jean-pierre charras dfc49da29b Fix issues in strings that need to be translated (non ASCII7 strings, trailing spaces...) 2017-06-18 21:35:37 +02:00
jean-pierre charras 1466d0cee6 Fix a few doxygen warnings 2017-06-18 09:18:41 +02:00
jean-pierre charras fa66a5a8f3 Pcbnew: make hotkeys { and } used to control the layer transparency (alpha channel) in GAL visible (and editable) in hotkey list. 2017-06-17 18:11:40 +02:00
jean-pierre charras cf5bae7fbf Fix a few doxygen warnings 2017-06-17 10:40:38 +02:00
Maciej Suminski 2018d48946 Fixed removal order in SIM_PLOT_PANEL::DeleteTrace() 2017-06-16 23:17:34 +02:00
Wayne Stambaugh dab73e172b Doxygen warning fixes and coding policy comment changes. 2017-06-16 10:08:28 -04:00
jean-pierre charras 996bcdf458 Fix a few doxygen warnings 2017-06-16 09:18:31 +02:00
jean-pierre charras a544a5b593 Fix a few doxygen warnings 2017-06-15 20:49:30 +02:00
jean-pierre charras 36e59065ff Minor fix: replace assert by wxASSERT in dialog (better to keep trace of an assert inside a wx application) 2017-06-15 13:13:25 +02:00
jean-pierre charras 2476e88c9d Fix a few doxygen warnings 2017-06-15 13:13:24 +02:00
jean-pierre charras cf083a20c4 Fix typo 2017-06-14 08:15:28 +02:00
Wayne Stambaugh 66e97fa905 Doxygen comment improvements.
Fix lots of Doxygen warnings.

Fix Doxygen comment for IO_MGR::FootprintEnumerate() which was recently
changed.
2017-06-13 19:47:46 -04:00
jean-pierre charras e97f49e009 Gerber X2 format: add the new TF.SameCoordinates attribute to Gerber files 2017-06-13 11:31:14 +02:00
jean-pierre charras 1fab667cf7 2 Minor fixes in GAL mode: when switching from legacy to gal, use now the latest display options.
Use hotkey defined by user to reset local coordinates in GAL (instead of the hard coded space key)
2017-06-13 11:25:05 +02:00
jean-pierre charras 1ada4863fc Pcbnew: fix incorrect UI behavior of "Zoom to selection" tool in GAL canvas. 2017-06-13 09:24:21 +02:00
jean-pierre charras a1a9440091 Pcbnew fix incorrect UI behavior of Zoom to selection in legacy canvas. UI behavior in GAL canvas is still incorrect. 2017-06-13 09:24:21 +02:00
Kristoffer Ödmark 19d5cc7548 Removed all exception specifiers since deprecated.
Exception specifiers are deprecated in cpp11, so went through them all
and removed them from the code.
2017-06-12 13:54:55 -04:00
Kristoffer Ödmark 8590a22995 Cpp11 compability steps.
-Changed coding style to not have exception specifications.
-Changed autogenerated Lexer code to not have exception specifications.
2017-06-12 11:47:20 -04:00
Maciej Suminski b304dafc5b Fixed headers in Position Relative tool 2017-06-12 16:58:47 +02:00
Maciej Suminski fc58bd3848 Position Relative Move tool fixes
- corrected copyright headers
- code formatting
- made dialog pointer private, added UpdateAnchor() and modified click
handler routine accordingly
- renamed .fbp file to match other dialogs pattern
2017-06-12 16:24:52 +02:00
Russell Oliver aeb23188f1 Add Position Relative tool 2017-06-12 16:24:52 +02:00
Maciej Suminski f0c8391a46 Use mouse (rather than cursor) position when selecting an item. 2017-06-12 16:24:52 +02:00
Maciej Suminski dcc803ecb1 VIEW_CONTROLS::GetMousePosition() returns the mouse position in world coordinates. 2017-06-12 16:24:52 +02:00
jean-pierre charras ad48cd435d Replace SetToolID( ID_NO_TOOL_SELECTED, ...) by SetNoToolSelected() in code 2017-06-12 16:17:48 +02:00
jean-pierre charras 6ed4f9b208 Make EDA_DRAW_FRAME::SetToolID and mouse cursor shape setting working in GAL canvases, and uses same mouse cursor shapes in legacy and gal canvases.
Starting fixing incorrect UI behavior of Zoom to selection in Pcbnew.
2017-06-12 15:16:09 +02:00
Oliver Walters 18488342a5 Improved speed of Duplicate action
- Removed repetitive tool calls
2017-06-12 11:16:30 +02:00
Simon Richter d5e85726ea Doxygen improvements 2017-06-11 18:09:14 -04:00
Simon Richter a9ca1e9930 Remove unreferenced local variables 2017-06-11 17:52:49 -04:00
Wayne Stambaugh 3cec63e9b9 Pcbnew: plugin improvements.
Allow partial library reads in libraries that support footprint per file.
This includes the KiCad and GEDA footprint libraries.

Allow for partially cached libraries rather than ignoring all valid files
when an error occurs.
2017-06-11 16:21:19 -04:00
jean-pierre charras 44b118f8cc Cvpcb: minor fixes in menubar (fix a comment and a few accelerator keys) 2017-06-11 10:44:36 +02:00
jean-pierre charras 1f1438947f Cvpcb: auto-selection of footprints: better algo to find a candidate. 2017-06-10 19:02:00 +02:00
jean-pierre charras ee5565ae33 Cvpcb: EQU file association associates to all components
Fixes: lp:1697150
https://bugs.launchpad.net/kicad/+bug/1697150
2017-06-10 14:05:30 +02:00
jean-pierre charras eadfff8ac4 Better management of the "Zoom to selection" tool in page layout editor.
- the useless "arrow tool" is removed.
- the "Zoom to selection" tool enable or disable the Zoom to selection (this is a on/off tool)
- When enabled, it can be disabled by the popup context menu, like in others applications.
2017-06-10 10:07:11 +02:00
jean-pierre charras 526b5e2cd3 Fix broken behavior of the "Zoom to selection" tool in Gerbview and Eeschema. 2017-06-10 09:07:17 +02:00
Wayne Stambaugh d37a33723a Pcbnew: GEDA plugin fixes and improvements.
Fix a bug in library cache modification check.  The Pcbnew footprint
file extension (.kicad_mod) was used instead of the GEDA footprint file
extension (.fp) which always caused the cache to reload on every library
call.

Allow for partially cached libraries rather.

Remove #ifdefed out exception throw in FootprintEnumerate().  Exceptions
should not be disabled in plugins.
2017-06-09 09:03:27 -04:00
jean-pierre charras 33e0758636 Fixes: lp:1696204 3D STEP export doesn't handle B.Cu rename
https://bugs.launchpad.net/kicad/+bug/1696204
2017-06-08 08:33:14 +02:00
jean-pierre charras 51bed4bae9 Fix incorrect handling of wxID_CANCEL and Close events in DIALOG_BOM_EDITOR. 2017-06-07 18:43:53 +02:00
jean-pierre charras 9d524fe2e3 Remove incorrect leading spaces in some strings. 2017-06-07 18:43:53 +02:00
Fabrizio Tappero 1a30b4fb05 Launch correct default system PDF viewer on Linux.
The is a bug in the wxMimeTypeManager object that sets the wrong default
PDF viewer on Linux.  Using wxLaunchDefaultApplication resolves the issue.

Remove angle brackets <> from error message as this causes issues with
controls that interpret HTML text.

Remove GetChars() from string formatting functions since it is not
required with wxWidgets 3 or greater.
2017-06-07 12:41:04 -04:00
jean-pierre charras 32abc273d0 3D shapes downloader: add .step and .stp files to the list of files to download 2017-06-07 11:17:27 +02:00
danngreen a18d72b5d6 Made BOM editor dialog quasi modal 2017-06-06 13:43:08 -04:00
Bernhard Stegmaier 0e71686bfd Reunion of zoom toolbar buttons.
The zoom window toolbar button is on the right toolbar separated from the
other zoom buttons on the top toolbar.  Move the zoom window button to the
top toolbar beside the other zoom buttons.
2017-06-06 09:35:20 -04:00
Cheng Sheng 521e18ddbd "Show Datasheet" button: Resolve env-vars (like ${KIPRJMOD}) if appears.
This way, the datasheets can be stored within the project dir, and referred as ${KIPRJMOD}/relative/path/to/datasheet.
2017-06-06 08:30:35 -04:00
jean-pierre charras 79823d573a fix incorrect comment 2017-06-05 18:16:08 +02:00
jean-pierre charras bea4664311 Fixes: lp:1695751 (EEschema: "Not-connected" flag not movable)
https://bugs.launchpad.net/kicad/+bug/1695751
2017-06-05 18:16:08 +02:00
jean-pierre charras 0d2634fe2d Fix incorrect declaration of a translatable string. 2017-06-05 18:16:08 +02:00
Oliver Walters 29557e4d9e Fixed button sizing for launcher panel
- Increased expansion so bitmaps are fully visible
2017-06-05 09:29:45 -04:00
Fabrizio Tappero ac9a64a173 general UI fix. Fixed a lot of icons and a lot of menu.
Also a few no longer used .cpp icon files are removed.
2017-06-02 11:51:11 +02:00
Andrey Fedorushkov ddec8036c1 Eeschema: fix an other erroneous "unit value out of range" test. 2017-05-31 15:43:28 +02:00
jean-pierre charras c0bb8a30c2 Fixes: lp:1694456
https://bugs.launchpad.net/kicad/+bug/1694456

EEschema load: report "unit value out of range" in sub-sheet, although it is not the case.
2017-05-31 10:20:49 +02:00
Oliver Walters e6baaa6164 Improved button layout on splash screen
- Simplified code
- Button bar expands to fill entire screen width
2017-05-30 08:13:32 -04:00
jean-pierre charras b8183a1aa5 Fix Coverity warnings 2017-05-30 09:07:18 +02:00
jean-pierre charras e9577a1025 Fixes: lp:1692706 (eeschema cache lib not rebuilt when saving schematic, and existing symbols already in cache are not updated)
https://bugs.launchpad.net/kicad/+bug/1692706
2017-05-29 18:22:36 +02:00
jean-pierre charras 5045ac1b54 Update pspice demo 2017-05-29 18:11:17 +02:00
Cirilo Bernardo 453e220fd8 Fix default line widths for non-mm units in DXF import 2017-05-29 09:48:22 +02:00
jean-pierre charras 200df95f00 fix bug (incorrect validation, on Windows only) in S3D_FILENAME_RESOLVER::ValidateFileName(). 2017-05-28 18:56:49 +02:00
jean-pierre charras 1fda668f24 3D viewer: cosmetic enhancements: fix an incorrect icon, and add shortcut keys in right popup menu.
Also fix an incorrect legend in hotkey list.
2017-05-26 13:28:51 +02:00
jean-pierre charras 1951ee924c Very minor change in some sources: replace in comments CHANGE_LOG.TXT AUTHORS.txt 2017-05-25 09:05:35 +02:00
jean-pierre charras 38c8470cdc add comments in pcbnew_scripting_helpers.h 2017-05-24 21:34:56 +02:00
jean-pierre charras 2100c29a1a Fixes: lp:1692436 (reset to defaults in Eeschema, edit component properties, puts fields in the wrong position)
https://bugs.launchpad.net/kicad/+bug/1692436
2017-05-24 21:19:26 +02:00
jean-pierre charras 9c7b0c2ee5 Fix a compil issue created by may commit 413a3d828a
.
2017-05-24 21:14:24 +02:00
Baranovskiy Konstantin de28e58350 Better icons, by Konstantin Baranovskiy and Fabrizio Tappero 2017-05-24 20:02:12 +02:00
jean-pierre charras 413a3d828a remove dead code in swig 2017-05-24 18:08:15 +02:00
jean-pierre charras 1a33efa133 Fix an issue when reading a gpcb footprint library when a .fp file has a problem.
Now the full library loading is not aborted (and the other libraries in list are also loaded).
Only the bad .fp file(s) is not loaded.
Mainly, a .fp file load error does not throw a library load error, and this is a temporary fix.
But throwing a library error when a .fp file cannot be loaded is worst (you even cannot import a good .fp file).
2017-05-24 14:38:08 +02:00
Oliver Walters ea855c1abf Fixed duplicate field names
- Now works correctly even if users overload default field names
2017-05-22 15:29:33 -04:00
Oliver 2a3a699d98 Component table is left aligned 2017-05-18 08:37:08 -04:00
Bernhard Stegmaier df2ff50aa2 Fix OSX bundling issue.
Bundle kicad-ogltest as a console tool into the main KiCad bundle where
the other tools reside.
2017-05-17 08:14:18 -04:00
Maciej Suminski e79f97860c Bezier2Poly refactor
Before the refactor library browser display Bezier curves correctly only
once, at other times they were just straight lines or crashed the
application.
2017-05-16 17:58:09 +02:00
jean-pierre charras f77db7b4b9 Fixes: lp:1690840 (Pcbnew crashes when creating a drill file)
https://bugs.launchpad.net/kicad/+bug/1690840
2017-05-16 13:00:54 +02:00
Maciej Suminski 499eabceb4 More data validity checks in POINT_EDITOR
Fixes: lp:1690658
* https://bugs.launchpad.net/kicad/+bug/1690658
2017-05-16 11:47:00 +02:00
Maciej Suminski 4336db3a7c Clear selection before 'Global Deletion' action
Fixes: lp:1690783
* https://bugs.launchpad.net/kicad/+bug/1690783
2017-05-16 09:16:12 +02:00
Eldar Khayrullin 14bb238b30 Fix typo (NTPH instead of NPTH) in DIALOG_GENDRILL_BASE. 2017-05-14 19:32:03 +02:00
jean-pierre charras c5b09696ab Eeschema bom scripts: move python scripts to eeschema/plugins/python_scripts and xsl scripts to subdir xsl_scripts.
Python scripts are now installed (previously: were ignored by the make install command)
2017-05-13 16:52:56 +02:00
jean-pierre charras c3698dabb1 Bom scripts: Update comments in scripts (no code change) 2017-05-13 08:18:06 +02:00
jean-pierre charras 305a166e95 Pcbnew: update immediately the 3D viewer opened from the footprint editor/viewer/wizard after a change. 2017-05-13 08:17:06 +02:00
Maciej Suminski b823d0b784 Use separate GAL_DISPLAY_OPTIONS instance in pad properties dialog
DIALOG_PAD_PROPERTIES disables the axis display which propagates
back to the parent frame when they share the same GAL_DISPLAY_OPTIONS
instance.

Fixes: lp:1687014
* https://bugs.launchpad.net/kicad/+bug/1687014
2017-05-12 01:01:38 +02:00
Wayne Stambaugh 747583606b Eeschema: fix regression when sheet files are not in project path.
Fixes lp:1683921

https://bugs.launchpad.net/kicad/+bug/1683921
2017-05-10 16:05:06 -04:00
jean-pierre charras 5ad1a13096 Fix a compil issue on Windows (W7 32bits). Could be an obscure conflict in var/keyword names. 2017-05-10 14:32:36 +02:00
Maciej Suminski b71fc5564a Code formatting fixes 2017-05-10 11:40:49 +02:00
Oliver Walters cd738297b0 SELECTION_AREA color now indicates selection mode
BLUE = Normal
GREEN = Addition
RED = Subtraction

Line color indicates "window" or "crossing" selection mode
2017-05-10 10:57:29 +02:00
Oliver Walters 2ae47d31cc Fix for Arc HitTest
compureArcBBox does not account for line width
2017-05-10 10:57:29 +02:00
Oliver Walters a2fda9bd39 Fixed selection filtering
- Fixed "double selection" of pads and pad parents in PCBNEW
- Disabled selection of entire module in MODEDIT
2017-05-10 10:57:29 +02:00
Oliver Walters 1f1143743e HitTest improvement for EDA_TEXT 2017-05-10 10:57:29 +02:00
Oliver Walters b53ba56ac2 Use CTRL modifier to deselect items 2017-05-10 10:57:29 +02:00
Oliver Walters 8b49c6e5ed Alter selection area colours based on selection mode
- Left to Right is slightly blue (as current)
- Right to left is slightly green
2017-05-10 10:57:29 +02:00
Oliver Walters c8fe9ffa79 Adjusted selection for ZONE 2017-05-10 10:57:28 +02:00
Oliver Walters 9c80d63b5c Fixed HitTest for text and modules 2017-05-10 10:57:28 +02:00
Oliver Walters d9308fcab1 Fixed HitTest for ZONE_CONTAINER 2017-05-10 10:57:28 +02:00
Oliver Walters 6aadc703f0 Updated HitTest for PCB_TEXT and TEXT_MOD 2017-05-10 10:57:28 +02:00
Oliver Walters e29abd6204 HitTest for trapezoid pad 2017-05-10 10:57:28 +02:00
Oliver Walters 7cfc882448 HitTest for RoundRect pad 2017-05-10 10:57:28 +02:00
Oliver Walters 8caef05ad6 HitTest for Oval pads
HitTest for Oval pads

Required fix for GetBoundingBox method for Oval Pad shape
2017-05-10 10:57:28 +02:00
Oliver Walters f338d46476 HitTest for Rectangular pads
HitTest for Rectangular pads

- Works at any rotation, even with Shape Offset
- Fixed bugs in D_PAD BoundingBox calculation
2017-05-10 10:57:28 +02:00
Oliver Walters a0afcd5a62 HitTest for pads
- Circular pads
2017-05-10 10:57:28 +02:00
Oliver Walters 2b4c2efc85 Fixed HitTest for Arc segment 2017-05-10 10:57:28 +02:00
Oliver Walters f8734bd057 Fixed ::HitTest for Circle shape
- Testing against rectangle intersection now works correctly
- Previously tested against BoundingBox() not circle outline
2017-05-10 10:57:28 +02:00
Oliver Walters ef25ffbab7 Alter selection mode based on drag direction
LEFT > RIGHT = Enclosed selection
RIGHT > LEFT = Touching selection
2017-05-10 10:57:28 +02:00
Oliver Walters d4e41c4f97 Component table improvements 2017-05-08 12:43:20 +02:00
Maciej Suminski 6cefb68c7d Fixed a crash on Eagle PCB import with dimensions on unsupported layers 2017-05-08 11:04:10 +02:00
Maciej Suminski 2ac8ab2a8f Eagle layers as enums 2017-05-08 10:26:48 +02:00
Maciej Suminski 99f65f4dbf Added const T& to Eagle PCB import plugin methods 2017-05-04 15:44:14 +02:00
Alejandro García Montoro 9cf934ef17 Moves Eagle XML parser to common, replacing boost with wx.
All E'STRUCTS' are moved to common except for ERULES (which is
specific to pcbnew and needs its internal units), still in
pcbnew/eagle_plugin.{h,cpp}

In order to get rid of another boost dependency, this also changes
the parsing of the XML from Boost.PropertyTree to wxXml.

To replace boost::optional, an OPTIONAL_XML_ATTRIBUTE class has
been implemented. This could be replaced with std::optional when
C++17 is ready.
2017-05-04 15:29:45 +02:00
jean-pierre charras 4f2ed1b05f Plot gerber: fix a minor issue: an aperture attribute was incorrectly set on non copper layers when drawing some pads. 2017-05-04 08:55:17 +02:00
jean-pierre charras d1dfa5aba3 Code cleaning: add comments, better names for a function, simplify code. No actual code change. 2017-05-04 08:54:30 +02:00
Wayne Stambaugh c70adcdf31 Don't apply last line width to text thickness in symbol library editor.
The symbol library header was setting the text thickness using the
last line thickness setting which is incorrect so use the default
thickness when creating new text objects.

Fixes lp:1635344

https://bugs.launchpad.net/kicad/+bug/1635344
2017-05-03 16:20:46 -04:00
Wayne Stambaugh 096d9fbbf9 Pcbnew: continue loading footprints after first failure.
The footprint library cache handler would throw an exception on the
first error it encountered preventing all subsequent footprint files
from being parsed even if there was nothing wrong with them.  This
commit queues errors until all of the footprint files in the folder
have been parsed.

Fixes lp:1416736

https://bugs.launchpad.net/kicad/+bug/1416736
2017-05-03 15:27:07 -04:00
jean-pierre charras 342f28f106 dilaog bom editor: fix min sizes. 2017-05-03 08:56:32 +02:00
Oliver Walters 5fe13c01c7 Improvements for component table 2017-05-03 08:56:31 +02:00
Marco Ciampa b50d3966b5 Pcbnew: make ruler tool warning translatable. 2017-05-02 16:30:24 -04:00
Eldar Khayrullin f3457794cf Pcbnew: add option to plot DXF editable text
Add option to plot DXF oneline ASCII text as editable text (in non-outline mode)

Fixes: lp:1423515
* https://bugs.launchpad.net/kicad/+bug/1423515
2017-05-02 15:07:19 -04:00
jean-pierre charras e4d2924ee2 Make a sentence translatable in dialog_bom_editor. 2017-05-02 19:51:02 +02:00
Oliver Walters 29e3e55ad3 Removed BOM functionality
- Removed ability to generate BOM to file
- Removed Save/Cancel window when closing table
- No longer updates table <after> table is closed
- Bugfix for field names (previously comparison was case insensitive)
2017-05-02 09:40:02 -04:00
Oliver Walters 48893ab2b1 Fixed UNDO behaviour
- Undo actions are pushed to the appropriate sheet(s)
- Each sheet's actions are grouped together
2017-05-02 09:39:56 -04:00
Oliver Walters 47ee2773d2 Reworked field association
- Allow duplicate components to access same field data
2017-05-02 09:39:51 -04:00
Oliver Walters d792e36151 Reworked UI
- Buttons are enabled/disabled within wxUpdateUI events
- Save/Cancel dialog used to close window and apply (or reject) changes
2017-05-02 09:39:40 -04:00
Oliver Walters 59470c3b5e Fixed display of references for duplicate sheets
Display part reference rather than REFERENCE field value
2017-05-02 09:39:34 -04:00
Oliver Walters 8dd4aca73b Mark schematic as dirty
Notify schematic of changes when window is closed
2017-05-02 09:39:24 -04:00
Oliver Walters 5126332c57 Fixed wxString::Format assert 2017-05-02 09:39:08 -04:00
Oliver a39856485c Added component table dialog
- Allows grouping of matched components
- Bulk edit of components in a spreadsheet window
- User can choose to save / undo changes
- All changes are pushed to the undo stack in a single operation
- Export table to HTML / CSV output
2017-05-02 09:39:01 -04:00
Mathias Grimmberger 097f89dcbc Use wxSetAssertHandler() instead of changing wxTheAssertHandler 2017-05-02 11:16:48 +02:00
jean-pierre charras 000ee22e39 Drill dialog: creates the directory, when the path entered in dialog does not exist. 2017-05-01 20:42:18 +02:00
jean-pierre charras c8706e9c15 Fix compil issue in Python support. 2017-05-01 14:19:38 +02:00
jean-pierre charras afe92c7bfc Pcbnew: Add creation of Drill Files in Gerber X2 format.
Gerbview: add support of drill files in Gerber format.
Fix also an issue in drill dialog: Axis choice is now common to plot a drill files.
2017-05-01 12:43:40 +02:00
jean-pierre charras a92ea8c75b Fixes: lp:1687014 Footpring editor disappearing axes crosshair
https://bugs.launchpad.net/kicad/+bug/1687014
2017-04-29 11:43:02 +02:00
Lubomir Rintel 862711b71a Add AppStream metadata
This will ensure KiCad will be easily installable from the app stores such
as GNOME Software.

The screenshots probably need a better home. Not that it would matter
too much -- the Linux distributions do cache them with their feeds, so
the app store applications don't access them from this source directly.

Screenshots from the web [1] can't be used since they are too large for
use in the app store application. :(

[1] http://kicad-pcb.org/discover/screenshots/

Fixes lp:1323789

https://bugs.launchpad.net/kicad/+bug/1323789
2017-04-27 19:00:38 -04:00
Jan Mrázek ade263f30d Check required libraries in FindwxWidgets.cmake
Both official one and KiCad one version of FindwxWidgets.cmake do not check if
all the required components are part of the wxWidgets build. This couses trouble
on Ubuntu when user misses libwxgtk3.0-dev package - CMake succeeds, build does
not.

This fix was accepted also to the CMake 3.9 upstream
(https://gitlab.kitware.com/cmake/cmake/merge_requests/704).

Fixes: lp:1630020
* https://bugs.launchpad.net/kicad/+bug/1630020
2017-04-26 20:43:29 -04:00
Cirilo Bernardo 5013ea2e8e Added comments on skipped patterns in VRML2 parser 2017-04-25 20:24:44 -04:00
Robbert Lagerweij e57c962336 Pcbnew: add option to select origin & anchor in move exactly tool
This patch adds a radiobox to allow the user to select a reference point for
the move. The additional options are: User Origin (set with <space>),
Grid Origin and Sheet Origin (effectively making it an absolute coordinate).

A checkbox is added (where it makes sense) to allow overriding which point
within the component is put on top of the designated coordinate.

Fixes: lp:1460460
* https://bugs.launchpad.net/kicad/+bug/1460460
2017-04-25 11:32:49 -04:00
Eldar Khayrullin 0af5695e51 Pcbnew: add option to plot DXF lines in outline mode.
Add option to plot dialog to plot DXF layers *.Cu, *.Adhes, *.Paste, and
*.Mask in outline mode or line mode.

Fixes lp:1643330

https://bugs.launchpad.net/kicad/+bug/1643330
2017-04-25 08:24:55 -04:00
Dick Hollenbeck 50716c9015 Fix BOM generation bug for components with multiple units.
Sadly, each unit of a component can have its own unique fields. This
change finds the last non blank field and records it. Last guy wins
and the order of units occuring in a schematic hierarchy is variable.
Therefore user is best off setting fields into only one unit. But this
scavenger algorithm will find any non blank fields in all units and use
the last non-blank field for each unique field name.

Fixes lp:1471417

https://bugs.launchpad.net/kicad/+bug/1471417
2017-04-24 10:16:32 -04:00
Maciej Suminski 4b5482eb5a Preserve FPU registers on context switch
Fixes: lp:1660546
* https://bugs.launchpad.net/kicad/+bug/1660546
2017-04-24 00:04:43 +02:00
Maciej Suminski 6507dbf3ad Fixed code formatting & comments typos 2017-04-24 00:02:07 +02:00
jean-pierre charras b385413458 Fix tooltip errors 2017-04-22 10:26:22 +02:00
jean-pierre charras 9e321a4722 Pcbnew: Apply a fix made in stable branch, in AppendBoard, to avoid potential crash. 2017-04-22 09:23:02 +02:00
jean-pierre charras 0e6723bb10 Fix color management in DXF files, broken since a long time. 2017-04-21 16:44:15 +02:00
jean-pierre charras 873e57e63e remove useless or incorrect wxASSERTs 2017-04-21 14:32:06 +02:00
Maciej Suminski e53c3afc29 Fixed a bug with invisible vias
If there was a board with no copper layers checked as visible, the
initial GAL cache contained an empty entry for them. In such case,
toggling layers visibility have not changed anything.

The visibility condition check has been moved to ViewGetLOD() method
which serves better the purpose of dynamic visibility checks.

Fixes: lp:1639974
* https://bugs.launchpad.net/kicad/+bug/1639974
2017-04-20 18:22:27 +02:00
Maciej Suminski 217593f6bc Fixed selected items drift on rotation/flip 2017-04-20 16:38:19 +02:00
Maciej Suminski 0e14cdf6da Code formatting 2017-04-20 16:37:36 +02:00
Maciej Suminski 481fd233d4 Enable cursor snapping by default
Fixes: lp:1671869
* https://bugs.launchpad.net/kicad/+bug/1671869
2017-04-20 15:04:05 +02:00
Maciej Suminski d452a5a30c Moved ratsnest update from EDIT_TOOL to PCB_EDITOR_CONTROL 2017-04-20 14:43:42 +02:00
Maciej Suminski bc8668b039 Renamed PCB_ACTIONS::editModifiedSelection to selectionModified 2017-04-20 14:11:59 +02:00
Maciej Suminski bb999f1bbf Fixed items disappearing after a rotation/flip
Fixes: lp:1683831
* https://bugs.launchpad.net/kicad/+bug/1683831
2017-04-20 14:11:59 +02:00
Maciej Suminski e2b95cf97a Removed a redundant update/refresh calls
BOARD_COMMIT handles all necessary updates
2017-04-20 14:11:35 +02:00
Maciej Suminski 74847bf8ff Code formatting and clean-up 2017-04-20 14:01:38 +02:00
jean-pierre charras 13b2cb4d16 Demos: update full footprint names and net zones, to avoid warnings when updating a netlist 2017-04-19 14:17:50 +02:00
jean-pierre charras a35a46804e Pcbnew fix: "create array" extremely slow in GAL mode, due to a useless call of a time consuming method for each new item created. 2017-04-19 14:15:11 +02:00
jean-pierre charras 01f5a129a3 Fixes: lp:1683147 (Board append command *extremely* slow)
https://bugs.launchpad.net/kicad/+bug/1683147
2017-04-18 20:10:34 +02:00
Wayne Stambaugh 9e3e28ab77 Prevent unnecessary compilation due to changes in plot_common.h.
The header plot_common.h was included in basic_gal.h which was not
required for compilation.  Remove the plot_common.h include to prevent
large swaths of KiCad from being recompiled when the plot_common.h is
changed.
2017-04-18 11:14:59 -04:00
Cirilo Bernardo 68a7a5235e Fix 3D plugins mutiarch support.
Use CMAKE_INSTALL_LIBDIR instead of wxStandardPaths::GetPluginsDir() to
determine plugin directory.

Fixes lp:1682812

https://bugs.launchpad.net/kicad/+bug/1682812
2017-04-18 09:11:53 -04:00
Alejandro García Montoro 1a75d9979f Modify comments in shape_line_chain.h that described the old reference-wise behaviour of SEG class 2017-04-17 11:17:13 +02:00
jean-pierre charras cf87536322 Fix a focus issue in dialog_edit_module_for_BoardEditor.cpp (Linux only) when creating the dialog.
It prevents ESC or ENTER keys to dismiss the dialog, until the focus is set by clicking on a widgets in the dialog.
2017-04-16 21:48:22 +02:00
jean-pierre charras 4b916b42ed dialog_edit_module_for_BoardEditor.*: fix questionable code. 2017-04-16 20:52:41 +02:00
jean-pierre charras e97c91b025 Fixes: lp:1683128 (pcbnew: the cairo canvas ignore arc width)
https://bugs.launchpad.net/kicad/+bug/1683128
2017-04-16 19:21:31 +02:00
jean-pierre charras 88105f891f Fixes Pcbnew bug: Drag Zone Outlines no longer working in legacy view 2017-04-16 18:32:47 +02:00
jean-pierre charras 50fd7a27cf Fix a few coding issues in dialog_edit_module_for_Modedit.
(Mainly, remove OnOkClick and OnCancelClick to use default handlers, and use TransferDataFromWindow to update fields)
Fix also a minor issue in lib_id
2017-04-16 15:09:05 +02:00
jean-pierre charras 60310b3d32 Fix qa/geometry/test_segment.cpp to reflect the changes in SEG class (changes in commit cbb5708c36) 2017-04-15 09:10:42 +02:00
Miles McCoo b321efffaf Minor Pcbnew Python scripting fix to expose SHAPE_POLY_SET interface
The recent refactoring work to move zones from CPolyLine to
SHAPE_POLY_SET resulted in a reduction in pcbnew's python
capabilities.  This change exposed SHAPE_POLY_SET to restore
that functionality (albeit with slightly different method names)
2017-04-14 10:23:42 -04:00
jean-pierre charras cbb5708c36 seg.h: revert to version just before commit f68ce306bd, and update a few outdated comments. 2017-04-14 14:56:56 +02:00
Miles McCoo 11c42cdff7 Minor Pcbnew Python scripting improvement.
Added NETCLASSPTR constructor to swig interface. This enables scripts to
generate new net classes.
2017-04-14 08:49:51 -04:00
jean-pierre charras 74cd53fb31 finishing work started in commit ba37d6fca3:
Command add corner to zone in GAL mode: fix corner cases (existing when a zone has holes).
(Well, "corner case" is the right word: I can't resist)
2017-04-14 14:39:45 +02:00
jean-pierre charras 83169af988 Code refinement for commit 80371134d7 2017-04-14 14:39:44 +02:00
Lachlan Audas a208ba6566 Fix Eagle plugin board free text rotation import bug.
When using angle's other than 90, 180, and 270, the Eagle plugin did not
correctly set the text angle.
2017-04-14 08:30:57 -04:00
Konrad Beckmann c4ea54227e Remove redundant statement in DSNLEXER::PopReader 2017-04-13 14:03:37 -04:00
Simon Wells 117faf898f Disable icons in menus by default on osx 2017-04-13 13:49:55 -04:00
jean-pierre charras b347443b95 Make Help sub-menus working in footprint viewer 2017-04-13 18:36:07 +02:00
jean-pierre charras 80371134d7 better fix than commit 6c083ebf4c, because the issue was existing in other dialogs
Fix incorrect frame deletion, only noticeable when eeschema is run in stand alone mode.
After selecting a footprint using the footprint viewer, the application cannot be closed.
Reason:
the footprint viewer ctor creates an instance (not shown) of a FRAME_PCB.
Unfortunately, this pcb frame was not deleted by Eeschema, in stand alone mode,
preventing the application to be closed because a frame was still active after closing the schematic editor frame.
Now the footprint viewer ctor delete this instance after use, if it was not previously existing.
2017-04-13 18:28:16 +02:00
jean-pierre charras 6c083ebf4c FOOTPRINT_SELECT_WIDGET: fix incorrect frame deletion, only noticeable when eeschema is run in stand alone mode.
After selecting a footprint using the footprint viewer, the application cannot be closed.
Reason:
the footprint viewer ctor creates an instance (not shown) of a FRAME_PCB.
Unfortunately, this pcb frame was not deleted by Eeschema, in stand alone mode,
preventing the application to be closed because a frame was still active after closing the schematic editor frame.
2017-04-13 15:17:30 +02:00
Maciej Suminski 801e50450b Revert "Fix component chooser dialog crash if there are no FPs available"
This reverts commit 0a8a659ff7.
The patch is incorrect, as it removes the FP chooser drop-down list.
I cannot reproduce the crash with the patch reverted, so there must
have been something specific to my configuration at that time.
2017-04-13 10:58:10 +02:00
jean-pierre charras 02abf18046 Eeschema: speed up netlist creation. 2017-04-12 08:18:46 +02:00
jean-pierre charras 57ded58231 Cvpcb: fix not working footprint filtering by component keyword. 2017-04-11 08:27:20 +02:00
Vlad Ivanov 1e25c47362 cmake: use GNUInstallDirs to obtain lib/lib64 path
Fixes lp:1679795

https://bugs.launchpad.net/kicad/+bug/1679795
2017-04-10 16:21:50 -04:00
jean-pierre charras e6545ec982 Gerbview: evaluate Aperture Macro Parameters using precedence rules for the arithmetic expressions found in AM. 2017-04-10 18:44:32 +02:00
jean-pierre charras f007601507 Gerbview: fix an issue (crash or hang) when a aperture macro definition contains ( and ).
Note: currently Gerbview does not handle yet operator precedence in aperture macro parameters.
2017-04-09 16:42:17 +02:00
jean-pierre charras 9992a07def Gerbview: Fix an issue in aperture macro for a Circle AM primitive inside a macro definition 2017-04-08 17:41:53 +02:00
jean-pierre charras 36255d8523 Gerbview: Fix a few issues in aperture macro definitions. 2017-04-08 15:35:11 +02:00
jean-pierre charras aad80c9bf4 Fix compil issue on Linux 2017-04-08 14:26:32 +02:00
jean-pierre charras ba517db96c Gerbview: fix a subtle issue when reading parameter values in Gerber files.
In Gerber files the char 'X' is used as separator.
But when reading parameter values, the sequence "0xnnn" is a number in hexadecimal format, and the 'X' char is not seen as separator by usual strtod or strtol C functions.
This is now fixed.
2017-04-08 12:53:40 +02:00
jean-pierre charras 675eb37163 Fix a typo in a tool tip 2017-04-08 08:21:35 +02:00
jean-pierre charras c9ff885c1d Cmakelists: remove no longer used boost libraries from required boost components lists 2017-04-07 16:57:17 +02:00
Simon Richter 7b4ea2a382 Mark kicad-ogltest as GUI binary for Windows and MacOS 2017-04-07 08:14:54 -04:00
Simon Richter 5d48d8a2f8 Fix signature of dummy Pgm() function 2017-04-07 07:43:49 -04:00
Simon Richter 30446b8327 Tell the whole case to link dynamically against Boost 2017-04-07 07:43:49 -04:00
Simon Richter f16304b9d8 Use target name instead of platform dependent path 2017-04-07 07:43:49 -04:00
Simon Richter c845a9c88d Add missing GLEW and GLM include dirs for ogltest 2017-04-07 07:43:49 -04:00
jean-pierre charras 9a7abd5914 Pcbnew: fix some issues in GAL when adding holes in zones. 2017-04-07 11:57:02 +02:00
jean-pierre charras 70c961fe6a Pcbnew: fix serious issues (broken files) when saving and loading .kicad_pcb files when zones have holes in outlines. 2017-04-07 08:02:26 +02:00
jean-pierre charras ba37d6fca3 Temporary fix of broken command add corner to zone in GAL mode.
Fixes: lp:1680339
https://bugs.launchpad.net/kicad/+bug/1680339
2017-04-06 19:04:47 +02:00
jean-pierre charras bf21640ae5 Fix a few issues when changing a color in render, in GAL mode.
Now colors of ratsnest, vias, not plated holes and anchors can be set.
However not plated holes still have a color issue.
2017-04-05 16:31:29 +02:00
jean-pierre charras 23a8741b5e Pcbnew: fix a crash when changing a color in render, in legacy mode, if the GAL mode was previously used. 2017-04-05 16:31:29 +02:00
Wayne Stambaugh 578f01bfd9 Fix debug build error in symbol remap dialog. 2017-04-05 08:43:05 -04:00
Wayne Stambaugh 36606ceeb7 Add symbol library table remapping dialog.
Create dialog and code to allow legacy schematic symbols to be remapped
from the old library path look up method to the new symbol library table
method by using the following steps:

  1) Create a project symbol library table containing all of the symbol
     libraries defined in the old library look up list not found in the
     global symbol library table.

  2) Map each symbol to the correct symbol in the symbol library table
     if possible.

Recreate library link to symbols so look up method can be converted to
symbol library table properly.

Add function to SCH_COMPONENT to link library symbols using the symbol
library table.
2017-04-04 18:31:28 -04:00
Wayne Stambaugh 5dbfc02334 Board editor footprint properties dialog 3D model viewer fix.
Move the dialog layout refresh from the ctor to TransferDataToWindow which
is called by event after the dialog object is constructed.  This was causing
the 3D view panel to be drawn incorrectly on windows builds.

Remove unnecessary wxT() macros.

Fixes lp:1665888

https://bugs.launchpad.net/kicad/+bug/1665888
2017-04-04 10:05:01 -04:00
Fabrizio Tappero 91dcd2357b Minor toolbar bitmap improvements. 2017-04-04 09:13:33 -04:00
Maciej Suminski bf590780b8 Do not store 'force cursor position' setting in VIEW_CONTROLS::SETTINGS
Fixes: lp:1678875
* https://bugs.launchpad.net/kicad/+bug/1678875
2017-04-04 00:57:54 +02:00
jean-pierre charras 1f3fe6fefb Fix Eeschema: Part library editor "save current library as" crash if no current library selected.
Fixes: lp:1678698
https://bugs.launchpad.net/kicad/+bug/1678698
2017-04-03 07:58:34 +02:00
jean-pierre charras 2f9be81b19 Very minor change in 2 strings to help I18n translations. 2017-04-02 11:51:40 +02:00
Maciej Suminski 2c33fad45f Fixed pad net names display (GAL)
Fixes: lp:1678272
* https://bugs.launchpad.net/kicad/+bug/1678272
2017-04-02 00:56:21 +02:00
jean-pierre charras 6eb2000b69 fix Coverity warning (CID 151565) (CID 155147) 2017-04-01 20:05:33 +02:00
jean-pierre charras 04e24282a8 Fix bug: Render->Grid(Color) doesn't saved between kicad sessions.
Fixes: lp:1670084
https://bugs.launchpad.net/kicad/+bug/1670084
2017-04-01 11:48:02 +02:00
Chris Pavlina af88781262 Rewrite pcbnew preferences tooltips for consistency, fix a couple typos
Fixes: lp:1591428
* https://bugs.launchpad.net/kicad/+bug/1591428
2017-03-31 19:40:43 -04:00
Wayne Stambaugh 9c2ebf32f1 Initial symbol library table implementation prep work.
Add loading symbol library table code to schematic PROJECT object.

Fix minor issues with loading global symbol library table.

Add default symbol library path environment variable to the environment
variable list and change the variable name to KICAD_SYMBOL_DIR.

Add code to SCH_SCREENS to test if all library nicknames of the symbol
library IDs are empty.

Remove unnecessary KICAD_USE_SCH_IO_MANAGER build option.
2017-03-31 16:29:34 -04:00
Fabrizio Tappero dcaa0559de Minor edit component properties dialog improvements. 2017-03-31 15:30:00 -04:00
Maciej Suminski 0b57907a68 Fix crash on toggling 'Render' tab items visibility
Fixes: lp:1678169
* https://bugs.launchpad.net/kicad/+bug/1678169
2017-03-31 17:50:59 +02:00
Maciej Suminski 0a8a659ff7 Fix component chooser dialog crash if there are no FPs available 2017-03-31 17:15:09 +02:00
John Beard c3ff34e0df Add reset text attributes function to GAL - use for arc tool
Independent drawing functions (that don't expect any particular state to
be set up fo them) on the GAL need to reset the GAL properties they
use. This adds GAL::ResetTextAttributes() to make this easier.

This is important, as failing to reset mirroring can cause asserts in
OpenGL.

This is used in the Ruler tool (which previously did it one attribute at
a time) and also the Arc layout assistant, which previously failed to
reset mirroring.

Also reset on GAL construction, as these members appear to be
uninitialised.
2017-03-31 15:59:31 +02:00
Collin Anderson 9b876d9d98 Fix build of Python plugin for macOS 2017-03-31 08:49:48 -04:00
Jon Evans 8cd1df0524 Add output stream operator for COLOR4D 2017-03-31 06:48:04 -04:00
jean-pierre charras f16f39fd4c Gerbview: rework on load zip archive: better handling of non ascii7 filenames.
non ascii7 filenames of zip files issues are fixed.
There are still issues with non ascii7 filenames inside the zip archives (especially when a zip archive was created on Windows)
2017-03-31 10:55:13 +02:00
Chris Pavlina 3234087dc9 Move wxDataViewCtrl manipulators out of dialog_choose_component.cpp
Fixes: lp:1677925
* https://bugs.launchpad.net/kicad/+bug/1677925
2017-03-30 21:47:14 -04:00
Wayne Stambaugh b4e2757119 Make FP_TBL_MODEL reusable.
Factor out the FP_LIB_TABLE specific content from FP_TBL_MODEL into a new
LIB_TABLE_GRID class that can be used for any library table grid mix in.

Create new FP_LIB_TABLE_GRID object for the footprint library edit dialog.

Add method GetEnvVariables() to return any environment variables found in
a LIB_TABLE object.
2017-03-30 18:36:37 -04:00
Jon Evans 3ec28e2acf Refactor layer enumerations to all live in the same place 2017-03-30 16:01:48 -04:00
Wayne Stambaugh 40f60c9871 Fix netlist generation bug cause when component unit is set to zero.
Fix if statement logic to ensure the unit number is never set to zero.

Add logic to the legacy schematic plugin to automatically convert any
schematic files that have components with a unit setting of zero.  Set
the schematic modified flag so that the user will be notified of a
changed schematic.

Add a user warning when the schematic parser fixes the bug and sets
the file modified flag.

Fixes lp:1677282

https://bugs.launchpad.net/kicad/+bug/1677282
2017-03-30 15:44:47 -04:00
John Beard ef9f8d40c6 Init GAL class members (Coverity fixes)
Fixes: CID 157139 (GAL)
       CID 157138 (CAIRO_GAL)
2017-03-30 16:05:56 +02:00
John Beard c94269e173 Pcbnew GAL: Switch CW/CCW hotkeys to match legacy mode 2017-03-30 16:05:56 +02:00
John Beard 0b593faa93 Pcbnew: correct CW/CCW rotation.
These were backwards since internal angles are CCW due to the inverted Y
axis.

The hotkeys have NOT changed. This means 'R' is now clockwise and
'Shift+R' is anti-clockwise. This is the same as EEschema, but not the
same as Legacy mode.
2017-03-30 16:05:56 +02:00
Chris Pavlina e8b811bab7 kicad-ogltest: use OPENGL_GAL 2017-03-29 19:00:24 -04:00
John Beard fc7dad600f Ruler tool: reset text mirror/bold/italic before painting
This is required as the OpenGL GAL doesn't support mirrored
text, and if the state is not cleared after painting other mirrored
text, this is what is attempted.

Fixes: lp:1677210
* https://bugs.launchpad.net/kicad/+bug/1677210
2017-03-29 23:27:44 +02:00
Chris Pavlina 23590d8d3f kicad-ogltest: if version can't be interpreted, print it 2017-03-29 16:25:32 -04:00
Chris Pavlina c8ef5208ee Add initial ogltest tool for user testing
This tool is currently very rudimentary. I pushed it because I need to
collect responses from it from users with diverse graphics
configurations, so I want the tool to be in the nightly builds.

This affects no KiCad code.
2017-03-29 16:19:43 -04:00
John Beard 8f3423b803 Add Select Layer And Add Via actions to GAL router tool
On these actions, invoke the layer select dialog and set the via layer
pairs accordingly.

Fixes: lp:1672820
* https://bugs.launchpad.net/kicad/+bug/1672820
2017-03-28 15:13:27 +02:00
John Beard 69115e4b9d Signal via actions with flags, not event equality checking
This allows actions to encode both via type and other behaviours
intrisically witohut having to individually test for each action.
2017-03-28 15:13:24 +02:00
Chris Pavlina c8cdb51fa8 Add relational operators to component search
Fixes: lp:1578264
* https://bugs.launchpad.net/kicad/+bug/1578264
2017-03-27 21:26:49 -04:00
Chris Pavlina c7c172d368 Fix FP_LOADER_THREAD resource leak
The mechanism of thread termination was changed in 61c2beea and not done
correctly - the thread was not notified that it should terminate.
2017-03-27 14:23:03 -04:00
Chris Pavlina ffef8b6c56 Increase number of footprints listed in component chooser 2017-03-27 14:15:42 -04:00
Chris Pavlina feba091594 Highlight the first choice in rescue dialog
Fixes: lp:1455970
* https://bugs.launchpad.net/kicad/+bug/1455970
2017-03-27 08:45:05 -04:00
Chris Pavlina a9afb872d5 libedit: fix crash on Delete Component with no selection
This bug was actually here before the new component chooser this time;
I'm not sure what the purpose of this error message was since it is
being displayed in a non-error state. Maybe a copy/paste bug from when
Delete Component was changed to use the main component chooser?
2017-03-27 08:07:30 -04:00
Chris Pavlina d2b0a4b358 Component chooser: show aliases better
- In the listing, display alias names in italics
- In the info panel, display per-alias description correctly, as well as
  root description

Fixes: lp:1676190
* https://bugs.launchpad.net/kicad/+bug/1676190
2017-03-27 07:55:26 -04:00
jean-pierre charras cfac7bd31c Eeschema: fix a crash when closing the choose component dialog by OK button, if no component selected. 2017-03-27 08:53:19 +02:00
Chris Pavlina 61c2beea22 Fix FP_LOADER_THREAD access to destroyed dialog
Fixes: lp:1672733
* https://bugs.launchpad.net/kicad/+bug/1672733
2017-03-26 19:44:18 -04:00
Chris Pavlina ef11d110b2 Fix crash in cvpcb when filtering by component with no components
Fixes: lp:1656685
* https://bugs.launchpad.net/kicad/+bug/1656685
2017-03-26 18:48:50 -04:00
jean-pierre charras 0f0cb64a63 Minor fix in DRC test courtyards. 2017-03-26 08:13:23 +02:00
Nick Østergaard abd61ac1e7 Add boost include dir to qa/geometry
This is needed on OSX, I don't know why it works on linux and windows
without it.
2017-03-25 17:57:08 -04:00
Chris Pavlina 4011ed4e31 Convert UTF8 to/from wxString correctly around LIB_ID
Fixes: lp:1675942
* https://bugs.launchpad.net/kicad/+bug/1675942
2017-03-24 21:38:00 -04:00
Chris Pavlina 68853c988e Fix SYNC_QUEUE build issue on Boost < 1.56
Prior to Boost 1.56, boost::optional had no move constructor, preventing
use of std::unique_ptr inside it
2017-03-24 10:09:08 -04:00
Chris Pavlina 849b3c2a4b Add footprint select dropdown to component chooser, serious refactoring
- DIALOG_CHOOSE_COMPONENT has footprint select widget
- FOOTPRINT_SELECT_WIDGET
- FOOTPRINT_CHOICE widget (customized wxComboCtrl)
- FOOTPRINT_FILTER class
- FOOTPRINT_INFO rework:
    - FOOTPRINT_ASYNC_LOADER to load without freezing UI
    - Rewrite loader threads as queue-driven thread pool
    - Make FOOTPRINT_INFO available via kiway
- FP_LIB_TABLE::PrefetchLib
- Access to global fp-lib-table via kiway
- SYNC_QUEUE threadsafe queue template
- Remove KICAD_FOOTPRINT_SELECTOR build option
2017-03-24 09:20:27 -04:00
Alejandro García Montoro cc7825d00b Tests CPolyLine -> SHAPE_POLY_SET refactor.
Adds BOOST tests to the qa folder included in the geometry subdirectory.
The tests check whether the refactored code is consistent with the
legacy code. They also check some of the new code, as the family of
ITERATOR classes.
2017-03-24 10:43:47 +01:00
Alejandro García Montoro f68ce306bd CPolyLine -> SHAPE_POLY_SET refactor.
Removes the need of using the legacy code in polygon/PolyLine.{h,cpp},
refactoring all CPolyLine instances with SHAPE_POLY_SET instances.

The remaining legacy methods have been ported to SHAPE_POLY_SET;
mainly: Chamfer, Fillet, {,Un}Hatch.

The iteration over the polygon vertices have been simplified using the
family of ITERATOR classes.
2017-03-24 10:43:47 +01:00
John Beard 5aa1610362 Remove unused g_ShowPageLimits global variable
This variable was only defined, not declared in any header.
2017-03-23 12:47:05 -04:00
John Beard f723a5319c Move some unit related util function to base_units.h 2017-03-23 12:47:05 -04:00
Maciej Suminski b47a6e415b Fixed a memleak in DIALOG_CHOOSE_COMPONENT 2017-03-23 16:52:33 +01:00
John Beard e98ae3e463 Move executable name constants to own file
The executable name constants are only used by two files, they do not
have to be in common.h.

Also converted to const wxString for better type-safety and removed
old-style wxT macros.
2017-03-23 09:23:45 -04:00
John Beard ece7eeb280 Move SystemDirsAppend to own header
This function is called only from three sites, it doesn't need to be in
common.h.

The implementation was already in systemdirsappend.cpp, so a matching
header was created for it.

This reduces the visibility of the function to only the files that need
it and slightly shrinks common.h.
2017-03-23 09:23:45 -04:00
John Beard 27374c0aa3 Move file locking utilities to a separate file
The global ::LockFile() function is used in a single place, but it's in
common.h, so visible to all files.

The GetKicadLockFilePath function is used in only two places, and one of
them is LockFile.

This commit puts them both in a separate header, so they're only visible
to code using them.

The implementation of GetKicadLockFilePath is moved to lockfile.cpp,
where LockFile already was.

Also removed a (large) handful of wxT macros, which aren't needed any
more and make code less readable.
2017-03-23 09:23:45 -04:00
Maciej Suminski f2763e90ea Disable autopanning & cursor capture when drawing is finished 2017-03-23 14:15:34 +01:00
John Beard 0799d9e45c OPENGL_GAL: Init currentTarget
The currentTarget member of OPENGL_GAL is not initialised, but the
currentManager member is.

This commit uses SetTarget to initialise both target and manager to a
consistent state at construction.
2017-03-23 14:08:26 +01:00
jean-pierre charras 68b141dcb8 Make polygon built by BOARD::GetBoardPolygonOutlines strictly simple.
It fixes issues in 3d viewer (crashes and incorrect 3D board outline in some cases)

Fixes: lp:167484
https://bugs.launchpad.net/kicad/+bug/1674844
2017-03-23 08:56:52 +01:00
John Beard 9fe780f1b3 Rework zone creation in GAL
The zone creation in DRAWING_TOOL was a complex event loop whici
simultaneously managed the event handling, construction of the preview
polygon and the creation and commiting of the zone, all in the same
scope. This has been broken into several pieces:

* POLYGON_ITEM preview item, used to preview the polygon in progress
* POLYGON_GEOM_MANAGER is a class that collects points from user input
  and used them to describe a polygon's geometry, including calculation
  of 45-degree constrained leader lines
* ZONE_CREATE_HELPER is a class which deals with creating zones based on
  geometry from a geometry manager and parameters from the DRAWING_TOOL
* The (much simpler) event loop in DRAWING_TOOL drives the
  POLYGON_GEOM_MANAGER. With a minor refactor, this loop can be reused
  in future for other polygonal tools if wanted.

The polygon preview now has a translucent fill which makes it easier to
visualise the zone.

This also adds the Close Zone Outline and Delete Last Corner actions as
part of the new event loop.

Fixes: lp:1663885
* https://bugs.launchpad.net/kicad/+bug/1663885

Fixes: lp:1667885
* https://bugs.launchpad.net/kicad/+bug/1667885
2017-03-22 17:18:12 +01:00
John Beard 1fd503bf58 Move DIRECTION45 to common/geometry
This class is useful for generic geometric layout of 45-deg constrained
line chains, not only in the PNS router.
2017-03-22 15:23:09 +01:00
John Beard ea10a67d14 Refill zones after editing properties
After editing properties (in Legacy or GAL) using the dialog, zones are
not refilled.

Fixes: lp:1674595
* https://bugs.launchpad.net/kicad/+bug/1674595
2017-03-22 13:31:52 +01:00
jean-pierre charras 0f7e898caa Allow selection of number of segments to approximate a circle in convert_drawsegment_list_to_polygon. 2017-03-22 11:47:03 +01:00
jean-pierre charras 05220a86f1 BOARD::GetBoardPolygonOutlines(): do not generate a separate SHAPE_POLY_SET for holes.
They are already managed by SHAPE_POLY_SET board outline.
2017-03-22 11:47:03 +01:00
John Beard d99fbddc22 Enable angle snap for pcbnew GAL ruler tool
This uses the two-point geometry manager to split the logic of the ruler
geometry and the preview item display. This allows the ruler to use that
manager's angle snap feature.
2017-03-22 10:59:47 +01:00
Maciej Suminski ddf4f3b2bc Remove not used cursor fields & methods in Cairo GAL 2017-03-22 10:37:43 +01:00
John Beard b8edecc10f Move cursor shape flag into GAL settings
The motivation here is to concentrate display options in the GAL display
settings, ready for removal of legacy canvases. Instead of having the
property as a member of the DRAW_FRAME, with the GAL canvas retreiving
it from there, it is now in the GAL_DISPLAY_OPTIONS struct, and both GAL
and legacy get it from there.

The options for setting cursor shape are then moved out of the general
options dialog, and into the GAL display options widget, where they can
be used in all GAL-aware programs.

GAL cursor shape works on GAL, but not legacy, so the option is now
available on OSX (but only affects GAL, and is labelled as such).
2017-03-22 10:24:48 +01:00
John Beard b4a4748672 Move sketch mode area in pcbnew display options
This gives a bit more space to the GAL options in the left panel

Also tidy up some code style and unnecessary default arguments in the
GAL display planel widget.
2017-03-22 10:24:48 +01:00
John Beard 01c733bdb5 Dim GAL cursor when forced but no interactive tool
This makes it clearer when a tool is active, otherwise interactive tool
effects like auto-pan can come as a surprise when the cursor is forced
to display all the time.
2017-03-22 10:24:48 +01:00
John Beard 78a5185857 Allow GAL cursor to be always displayed
A new items is added to the GAL display options (and the dialog), and a
hotkey (Ctrl+Shift+x) is added to toggle it.

Fixes: lp:1673633
* https://bugs.launchpad.net/kicad/+bug/1673633
2017-03-22 10:04:56 +01:00
jean-pierre charras 45b10f0f09 Pcbnew: fix a Regression in fallback to bounding box for board render in 3d-viewer
Fixes: lp: 1674844
https://bugs.launchpad.net/kicad/+bug/1674844
2017-03-22 08:40:48 +01:00
Chris Pavlina 72cfd38979 De-templatify CMP_TREE_MODEL_ADAPTER::FindAndExpand
std::function lets this be a plain method instead of a template; this
cleans up the header a bit and possibly reduces a bit of bloat
2017-03-21 22:45:36 -04:00
Chris Pavlina b2f1d22bbf Fix preselect in CMP_TREE_MODEL_ADAPTER 2017-03-21 22:45:17 -04:00
jean-pierre charras 12b65cf56b Fix typo 2017-03-21 16:45:35 +01:00
jean-pierre charras 5bd61d7eb6 Pcbnew fix: checking properties on error marker crashed pcbnew
Fixes: lp:1674671
https://bugs.launchpad.net/kicad/+bug/1674671
2017-03-21 16:44:56 +01:00
jean-pierre charras c20cf4a3e0 Fix incorrect calculations in GAL DrawGrid() methods, that create very long calculation time when the grid origin is not 0 2017-03-21 13:09:24 +01:00
jean-pierre charras 48f19c031a Fix a few issues when importing a .ses specctra session file.
(potential crash due to missing update of ratsnet data, add missing traces in GAL mode)
2017-03-21 11:22:03 +01:00
jean-pierre charras 806e71b17e update 2017-03-20 20:33:19 +01:00
jean-pierre charras c2227abb36 Specctra import: accept layer names like numbers (i.e. +12). 2017-03-20 19:50:07 +01:00
jean-pierre charras 230980fc9d Compile specctra file with pcbnew files, not with pcbcommon files (they are now used only by pcbnew) 2017-03-20 19:49:10 +01:00
John Beard ce731f8b62 Add GAL microwave tools
This adds the microwave tools to GAL in Pcbnew as a new tool:
MICROWAVE_TOOL.

Some new preview items are introduced to support this:

* TWO_POINT_GEOM_MANAGER for managing construction of two-point
  geometries, such as that used to construct the inductor.
* CENTRELINE_RECT_ITEM a preview item to draw ractangle with a given
  aspect ratio along a line (specified using a TWO_POINT_GEOM_MANAGER)

PCB_TOOL gets a generic event loops which should be useful for more
than just microwave tools:

* doInteractiveItemPlacement() - handles event loops that wait for a
  click, create an item on click and then allow moving it
  around/flipping, etc.

Fixes: lp:1531323
* https://bugs.launchpad.net/kicad/+bug/1531323
2017-03-20 16:10:51 +01:00
John Beard 3994e9a268 Allow calling of MW inductor function externally
This makes it possible to access the creation functions
for the microwave inductor externally, so that it can be
used from GAL.

Unlike the Gap/Stub tools, the inductor tool is more interactive, and
doesn't just return a MODULE*.

Introduces a new directory in pcbnew called 'microwave' to better
isolate generic (i.e. canvas-agnostic) functions, and a namespace MWAVE
to avoid polluting the global namespace.
2017-03-20 16:10:51 +01:00
jean-pierre charras 796e5fdc45 Fix an issue with pads not on copper layers (only on tech layers) when exporting .dsn file.
The pad is invalid in .dsn file and crashes Freeroute.
2017-03-20 15:19:20 +01:00
jean-pierre charras e4b39cfb09 remove duplicate code 2017-03-20 15:19:19 +01:00
John Beard e4a10ac355 Tweak _clang-format to bring closer to 'normal' KiCad style 2017-03-20 09:45:51 -04:00
jean-pierre charras ecdfa404cb More work courtyard overlap detection: better code. 2017-03-20 13:06:00 +01:00
Tomasz Włostowski 77c1b1b4ea Refresh vias geometry when switching via display mode
Fixes: lp:1674096
* https://bugs.launchpad.net/kicad/+bug/1674096
2017-03-20 12:06:56 +01:00
Tomasz Włostowski f599f10a03 gal: reset autopan state when autopanning is disabled
Fixes: lp:1674022
* https://bugs.launchpad.net/kicad/+bug/1674022
2017-03-20 11:45:57 +01:00
jean-pierre charras 2637835a1e First version of courtyard overlap detection 2017-03-19 20:27:45 +01:00
jean-pierre charras b365f17e9f First draft of courtyard overlap detection. 2017-03-19 20:27:44 +01:00
Chris Pavlina f7632d5473 Update year in copyright header template 2017-03-19 09:18:40 -04:00
Chris Pavlina ef12f0bcbc Fix warning: shadowed wxWindow::IsShown in sim_plot_panel.h 2017-03-19 09:18:28 -04:00
Chris Pavlina bfa22c6ce8 Fix warning: uninitialized constant in sim_plot_panel.h 2017-03-19 09:18:23 -04:00
jean-pierre charras 98e3bfb95a rebuild dialog_edit_module_for_Modedit.cpp with a more recent wxFormbuilder version to avoid deprecated compil warnings 2017-03-18 10:37:19 +01:00
jean-pierre charras 713d475df6 mark override 2 virtual methods. 2017-03-18 09:39:56 +01:00
Chris Pavlina b535303a0a kicad2step: unused variable 2017-03-17 22:45:41 -04:00
Chris Pavlina 527c98fe15 kicad2step: shadowed virtual because of wrong qualifiers 2017-03-17 22:45:28 -04:00
Chris Pavlina 200c3f78a0 LSET: undefined behavior in va_start() 2017-03-17 22:43:54 -04:00
Chris Pavlina 7360bdb7eb SPIN_INCREMENTAL_TEXT_CTRL: unused member warning 2017-03-17 22:42:43 -04:00
Chris Pavlina c9936e2a47 Fix warning about shadowing std::ignore 2017-03-17 22:16:32 -04:00
Chris Pavlina 74dfe80e21 Fix warning about creation of null reference
This is a code path that should never run.
2017-03-17 22:15:23 -04:00
John Beard 5f303f7b25 Enhance Pcbnew arc construction
This adds a richer overlay to the arc-by-three-points tool in Pcbnew,
including more guide-lines and a live display of radius and angle.

Also included is ability to go back to the previous step (if setting end
angle, you can go back to setting start point, etc) using Backspace, and
Ctrl snaps the start/end angles to 45 degree multiples.

This adds new classes

* MULTISTEP_GEOM_MANAGER: represents a generic "geometry manager" that
  builds up some geometrical construction based on a sequence of points.
  Used by:
* ARC_GEOM_MANAGER: handles the logical flow of constructing an
  arc by centre-point, set radius, set angle. This moves the logic out
  of the Pcbnew DRAWING_TOOL event loop in drawArc().
* ARC_ASSISTANT: graphical overlay to communicate current arc shape to
  the user during the drawing process
2017-03-17 20:56:54 +01:00
Miles McCoo db174862c8 Minor Pcbnew Python scripting improvements.
Add typedef for wxCoord to wx.i to enable usage of methods like
EDA_RECT.Inflate.

Added id.h to pcbnew.i to expose window toolbar identifier names.

Added Refresh() and WindowZoom() to pcbnew_scripting_helper.
2017-03-17 10:41:00 -04:00
Wayne Stambaugh 9ddb4fe67e Fix uncaught exception in footprint and symbol library table parsers.
Fixes Coverity CID 154580
Fixes Coverity CID 154581
Fixes Coverity CID 154582
Fixes Coverity CID 154583
Fixes Coverity CID 154584
Fixes Coverity CID 154585
2017-03-17 07:56:47 -04:00
John Beard 996cba7e7f Fix GAL display properties spin buttons on Windows 2017-03-16 10:40:06 -04:00
John Beard 7e1eea4122 Use abbreviated unit (not symbol) in design rule dialog
Fixes: lp:1667644
* https://bugs.launchpad.net/kicad/+bug/1667644
2017-03-16 08:30:00 -04:00
John Beard ef3553c086 Use TransferData* methods for DIALOG_DISPLAY_OPTIONS
Replaces the existing manual evdent handling, in line with UI
Guidelines.

Also remove the wxStaticLine, which is not a standard dialog element.
2017-03-16 08:01:42 -04:00
John Beard bdc9ae75f5 Add a display settings dialog to Modedit
For a start, this contains the GAL display settings (AA settings and
grid styling).

In future, other modedit-specific settings could go here too.

Fixes: lp:1672150
* https://bugs.launchpad.net/kicad/+bug/1672150
2017-03-16 08:01:33 -04:00
John Beard f2aa4d2911 Make GAL options panel a reusable panel
The primary motivation here is to allow other GAL canvas users (eg
Modedit, and soon Gerbview) to be able to easily modify GAL canvas
options.

For now, this doesn't change the display properties dialog in
appearance, but if more GAL options are added, it might need a bit of
tweak and maybe tabs or similar, like Eeschema preferences.
2017-03-16 08:01:26 -04:00
Tomasz Włostowski 3cc90ce2d2 Fixed center-on-zoom behaviour in the GAL canvas
Fixes: lp:1672868
* https://bugs.launchpad.net/kicad/+bug/1672868
2017-03-15 11:48:35 +01:00
Adam Wolf 0a29ab9031 Update macOS portion of compiling.md.
In general, replace OSX with macOS.  Moved the minimum OS version from 10.7 to 10.9.  Moved the maximum version from 10.10 to the current 10.12.
2017-03-14 19:08:18 -04:00
Cirilo Bernardo 54eeea4821 Patch OpenCascade Community Edition (OCE) to fix mingw UTF8 file name bug.
This patch is only known to work with OCE version 0.17.3 on mingw.  It
should not be used for any other purpose.  It breaks all other OCE builds
except mingw.
2017-03-14 18:48:08 -04:00
Cirilo Bernardo 8af174f7d2 Add wxWidgets bug fix patch.
Calling external applications with wxWidgets failed when the file name
contained non-ASCII characters.

Please note that this patch does not require wxWidgets to be recompiled.
It only changes a header file which means the patch can be applied to
an existing wxWidgets install.  However, KiCad does need to be rebuilt
after this patch is applied.  This patch is not required if you do not
need non-ASCII character file name support.
2017-03-14 18:33:14 -04:00
Cirilo Bernardo 960c139064 Fix UTF8 filename issues in kicad2step 2017-03-14 18:33:14 -04:00
jean-pierre charras ccfad8306b eeschema: fix an annoying issue created by commit fdb53f28e6: enter a label size starting by 0 (like 0.3) was not possible. 2017-03-14 20:40:21 +01:00
jean-pierre charras 69b350c9b0 Fix can't always group delete in fp-lib-table dialog
Fixes: lp:1672760
https://bugs.launchpad.net/kicad/+bug/1672760
2017-03-14 20:31:44 +01:00
Oliver fdb53f28e6 Improvement for label edit dialog in eeschema:
- Added wxTE_RICH property to label text controls (allows ctrl+backspace in Windows)
- Added numeric validator to text size
2017-03-14 13:08:36 -04:00
Tomasz Włostowski 2f730cad81 EDIT_TOOL: restore cursor position on exit
Fixes: lp:1671564
* https://bugs.launchpad.net/kicad/+bug/1671564
2017-03-14 10:54:58 +01:00
Michael 679074fdb2 Made libcontext compile on FreeBSD. Code formatting too. 2017-03-14 10:01:17 +01:00
Julius Schmidt 5b3f6d850d Fix format string assertion in select net dialog. 2017-03-13 16:45:41 -04:00
Kristoffer Ödmark d6dd176aca Changed default increment values and added shift+scroll for fine tuning
Fixes: lp:1669550
* https://bugs.launchpad.net/kicad/+bug/1669550
2017-03-13 11:25:40 -04:00
Oliver 3fc62d5fcd Improve right-click menu entry for doc
- Changed "doc" to "Open Documentation"
2017-03-13 09:58:05 -04:00
Diego Herranz 0a29e94a60 Calculator: Simplify color code tolerance chooser + typo
Since for this tool the only difference for different tolerances
is the 4th band, which is present for tolerance <= 2% and not
present for 10%/5%, reduce radio choices to those two groups for
clarity.

Fix a typo (4rd -> 4th) and rename one variable to make it
more descriptive as well.
2017-03-13 09:56:31 -04:00
Chris Pavlina e96673ed8d Add clang-format configuration 2017-03-13 09:56:25 -04:00
jean-pierre charras bbedad3456 Fix a Coverity warning, which looks like a (minor) bug in ccontainer2d.cpp. 2017-03-13 12:53:01 +01:00
jean-pierre charras 8f3fc7b858 Optimization in class_library.cpp: speed up power component list creation. 2017-03-13 12:49:24 +01:00
jean-pierre charras 28a6ca1e23 Eeschema: fix wrong position of symbol fields when adding a symbol in a schematic
Fixes: lp:1665718
https://bugs.launchpad.net/kicad/+bug/1665718
2017-03-12 17:04:42 +01:00
Chris Pavlina 5e5259b59c CMP_TREE_MODEL*: fix uninitialized members
Coverity CID 157141
Coverity CID 157136
2017-03-11 19:27:44 -05:00
Maciej Suminski fe4f02f5b9 Coverity fixes
CIDs:
- 153097
- 157120
- 157119
- 155148
- 155146
- 153103
- 153099
- 153095
- 153087
- 153086
2017-03-11 22:20:08 +01:00
Jon Evans 082b8dd2a9 Refactor BRIGHT_BOX to common so it can be used by other programs 2017-03-11 21:38:01 +01:00
Tomasz Włostowski 0a55d8e053 Fixed differential pair gap clearance error when gap equaled minimum clearance.
Fixes: lp:1533551
* https://bugs.launchpad.net/kicad/+bug/1533551
2017-03-11 20:57:59 +01:00
Maciej Suminski 3fafd48764 Fix drawing circles in GAL
Fixes: lp:1672039
* https://bugs.launchpad.net/kicad/+bug/1672039
2017-03-11 20:30:24 +01:00
jean-pierre charras 2c56085f41 Drc calculations fix a minor issue that detected a bad clearance when distance between a circle and a segment was the clearance value.
Also, give a margin of 1 nanometer during DRC calculations to avoid false error DRC detection due to rounding issues.
2017-03-11 18:09:18 +01:00
Chris Pavlina 5af825e21c Use ki_mutex.h in FOOTPRINT_PREVIEW_PANEL 2017-03-11 08:22:08 -05:00
Chris Pavlina 23a23d3c63 Fix typo in fp-lib-table help text
Fixes: lp:1671910
* https://bugs.launchpad.net/kicad/+bug/1671910
2017-03-10 23:44:12 -05:00
Chris Pavlina bbaa29fbc4 Refactor FOOTPRINT_PREVIEW_PANEL
- Pull out compound widget bits into FOOTPRINT_PREVIEW_WIDGET
- Move all pcbnew-specific bits *inside* pcbnew; implementation should
  be private for users
- Make a few class members and inner types private
2017-03-10 23:26:45 -05:00
jean-pierre charras de30dc9f5d Speed up schematic libraries loading. 2017-03-10 21:17:56 +01:00
Chris Pavlina a72d32d3fd Test for dangling pins after symbol is edited
Fixes: lp:1562897
* https://bugs.launchpad.net/kicad/+bug/1562897
2017-03-10 12:01:12 -05:00
Maciej Suminski f46961d003 Fix a memleak in COLOR_SWATCH 2017-03-10 17:56:41 +01:00
John Beard 8c3b8ee693 Add a ruler tool to pcbnew GAL
This allows to measure between features on a PCB. It uses a preview
EDA_ITEM in common, but due to the use of the IDs, it's currently
Pcbnew/Modedit only.

This also adds several "utils" for graphical functons useful when
drawing preview items on GAL canvases.

Fixes: lp:1467313
* https://bugs.launchpad.net/kicad/+bug/1467313
2017-03-10 16:21:44 +01:00
John Beard 9c08873210 Make SELECTION_AREA a generic overlay item
This simplifies the (already simple) SELECTION_AREA class. It is also
moved into KIGFX::PREVIEW and put in the common library, where it can be
reused by other GAL-aware tools (not just in Pcbnew) in future.
2017-03-10 16:21:44 +01:00
John Beard 5e84e953f3 Add a simple item class for graphical overlays
This introduces SIMPLE_OVERLAT_ITEM, which is an abstract EDA_ITEM,
designed for use as an overlay for assisting interactive tools.

The item is drawn only on the GP_OVERLAY layer, and sets the fill,
stroke and line properties before calling a virtual function to draw the
shape, which will depend on the implementaiton of the derived class.

The motivation here is to simplify and unify basic overlays used when
in interactive tools. It is not designed to be the base class of all
possible overlays - more complex ones would be more clearly represented
as their own derivative of EDA_ITEM.

Applications of this class can include: zoom/select rectangles, zone
polygon previews, geometric shape helpers, and so on.
2017-03-10 16:21:44 +01:00
Wayne Stambaugh 9636086f52 Fix build bug for const incorrectness. 2017-03-10 10:09:55 -05:00
Wayne Stambaugh cc64c6af1d Fix broken symbol link in schematic after editing.
The save current symbol command had a different code path then save current
library so the schematic symbol was not being refresh after is was modified
in symbol editor.

Split out the save current symbol command from Process_Special_Functions()
to help reduce function growth hormone imbalance syndrome.

Some coding policy fixes and wxT() macro removal.

Fixes lp:1671456

https://bugs.launchpad.net/kicad/+bug/1671456
2017-03-10 08:39:29 -05:00
Chris Pavlina 7bf4c90be5 Component chooser: properly normalize description/keywords
Fixes: lp:1671814
* https://bugs.launchpad.net/kicad/+bug/1671814
2017-03-10 08:34:20 -05:00
Maciej Suminski d337d08060 Sketch graphics mode for GAL 2017-03-10 14:08:59 +01:00
Maciej Suminski f21cfa167f Use DECIDEG2RAD function in PCB_PAINTER 2017-03-10 14:08:59 +01:00
Maciej Suminski 737dc20409 Make OpenGL GAL great again
Reenabled VIEW_ITEMs cache. Previously, the first init was called with
GAL_TYPE_NONE, causing all layers to be set to non-cached. During the
proper init, the layers were already set to non-cached and were not
changed.
2017-03-10 14:08:59 +01:00
Maciej Suminski 11f8e53e27 Smoother arc rendering in OpenGL GAL
Fixes: lp:1496114
* https://bugs.launchpad.net/kicad/+bug/1496114
2017-03-10 14:08:59 +01:00
Jon Evans 3208d24ad4 Add DrawArcSegment() GAL method, to support drawing outlined arcs 2017-03-10 14:08:59 +01:00
jean-pierre charras 0be56451b1 More optimization in project rescue. 2017-03-10 10:31:50 +01:00
John Beard c523ba45e1 Fix shadowed variable in python_scripting.cpp 2017-03-10 09:08:45 +01:00
jean-pierre charras 4605cae588 Displays the number of instances to modify in rescue dialog. 2017-03-09 19:16:24 +01:00
jean-pierre charras ae7e3f725b Speed up project rescue calculations, by optimizing the number of searches in libs. 2017-03-09 18:13:03 +01:00
jean-pierre charras 2a91d7bc21 Speed up SCH_COMPONENT::ResolveAll(). 2017-03-09 15:46:12 +01:00
jean-pierre charras a592832886 fix I18n issue (empty string) 2017-03-09 11:47:40 +01:00
Chris Pavlina a73abbfc31 Fix possible threadsafety issue in FOOTPRINT_PREVIEW_PANEL 2017-03-08 17:02:10 -05:00
Chris Pavlina 82f587f4ff Show the busy cursor while loading component chooser 2017-03-08 15:34:11 -05:00
Chris Pavlina 2e4e0a9a05 Minor cleanup in cmp_tree_model_adapter.h 2017-03-08 14:49:00 -05:00
Chris Pavlina 7ee0adabd7 Optimize component chooser startup time more
- Stop wx from sorting the items. We've already sorted them, and
  profiling shows our sort is faster than theirs.

- Go back to using strings as cache keys, because using pointers means
  the cache doesn't survive from one invocation to the next. Switch to
  wxHashMap because it can use wxString keys in an unordered (faster)
  map.
2017-03-08 14:41:34 -05:00
Chris Pavlina 28848373ce CMP_TREE_MODEL: add the correct number of units
Fixes: lp:1671174
* https://bugs.launchpad.net/kicad/+bug/1671174
2017-03-08 12:39:44 -05:00
Chris Pavlina 3bddc14dc6 CMP_TREE_MODEL_ADAPTER: use more suitable cache type
Fixes: lp:1671086
* https://bugs.launchpad.net/kicad/+bug/1671086
2017-03-08 12:34:11 -05:00
Chris Pavlina 2232edfb87 Rewrite DIALOG_CHOOSE_COMPONENT without wxFormBuilder
This will allow near-future use of controls not supported by
wxFormBuilder with minimal hackery.
2017-03-08 12:00:49 -05:00
Simon Richter ae9bbf7aeb Fix building benchmark test
Passing a wxString to std::ifstream::ifstream() is ambiguous, at least on MSVC.
2017-03-08 10:45:26 -05:00
Simon Richter bb61cd5a50 Add missing header
color_swatch.cpp uses std::unique_ptr
2017-03-08 10:39:11 -05:00
Simon Richter ef0a5ff71c Make Mac-specific function conditional
If we want to have an override marker on this function, it needs to be
conditional on Mac.
2017-03-08 10:24:59 -05:00
Maciej Suminski 62235348d1 Use GAL axes instead of a ORIGIN_VIEWITEM in module editor 2017-03-08 10:35:51 +01:00
Jon Evans 2513f0b002 Add setting to have GAL draw axes on the grid 2017-03-08 09:37:40 +01:00
Maciej Suminski 14cbdcec1f Fixed mismatched new[]/delete in 3D viewer 2017-03-08 09:12:16 +01:00
Chris Pavlina cf373e543f Fix Windows (and macOS?) build error caused by 11f4622ea 2017-03-07 17:51:25 -05:00
Chris Pavlina 36e400ec5b Avoid collapsing component chooser column widths to zero
Fixes: lp:1670762
* https://bugs.launchpad.net/kicad/+bug/1670762
2017-03-07 14:59:51 -05:00
Chris Pavlina 11f4622ea5 Fix GL assertion failure during GAL teardown 2017-03-07 14:37:02 -05:00
Chris Pavlina 3854637ec5 Footprint preview: do not Freeze/Thaw
This causes issues under Ubuntu Unity (possibly due to calling Show()
while frozen).

Fixes: lp:1670705
* https://bugs.launchpad.net/kicad/+bug/1670705
2017-03-07 14:32:02 -05:00
Wayne Stambaugh ef74f245cb Fix broken HTML formatting in about dialog. 2017-03-07 14:18:37 -05:00
Tomasz Włostowski eedf7cb243 Switched coroutine library from Boost libcotext to custom libcontext.
Fixes lp:1658249

https://bugs.launchpad.net/kicad/+bug/1658249
2017-03-07 11:45:29 -05:00
Maciej Suminski 338735c5bf Added a missing include to tool_manager.h
Previously full information about VC_SETTINGS type was not
available, so it was not possible to create a VC_SETTINGS stack
for some compilers.
2017-03-07 17:18:58 +01:00
Maciej Suminski c6e3ac7067 Removed boost::adaptors from TOOL_MANAGER 2017-03-07 17:18:22 +01:00
Julius Schmidt 29eb696ef7 Fix crash when switching from dragging to routine (PNS router)
The attached patch fixes a bug where triggering InlineDrag while routing
is in progress will crash pcbnew.  The problem is that the InlineDrag
event does not terminate performRouting.  Once InlineDrag is finished
it will call StopRouting which deletes the m_placer.  The Wait() in
performRouting will then return and it will crash as soon as it tries
to access the m_placer.
2017-03-07 13:56:44 +01:00
John Beard c86773462f GAL: Respect SHAPE_LINE_CHAIN closed setting
When drawing polylines using SHAPE_LINE_CHAIN, the polyline is always
was drawn closed in GAL and open in Cairo, regardless of the state of
SHAPE_LINE_CHAIN.
2017-03-07 13:28:14 +01:00
José Ignacio Romero 45d1082517 Make all layers slightly semitransparent as before 2017-03-07 11:57:52 +01:00
Chris Pavlina 2bb234d3f5 Fix assert in DIALOG_EESCHEMA_CONFIG when removing many libs at once 2017-03-06 17:24:12 -05:00
Simon Richter 12c1339296 Remove false "override" comments. 2017-03-06 16:34:56 -05:00
jean-pierre charras 0b3e5952b7 Eeschema: fix a crash if a schematic project was not loaded due to a incorrect file format error (Linux only)
Fixes: lp:1670322
https://bugs.launchpad.net/kicad/+bug/1670322
2017-03-06 21:41:43 +01:00
Chris Pavlina f8415633bd Switch component chooser to wxDataViewCtrl, refactor
This refactors COMPONENT_TREE_SEARCH_CONTAINER into a Model-View-Adapter
architecture comprising:

- eeschema/cmp_tree_model.h
    - CMP_TREE_NODE: Base class representing a searchable library
        set with scoring and sorting

        - CMP_TREE_NODE_UNIT
        - CMP_TREE_NODE_ALIAS
        - CMP_TREE_NODE_LIB
        - CMP_TREE_NODE_ROOT

- eeschema/cmp_tree_model_adapter.h
    - CMP_TREE_MODEL_ADAPTER: mediator between wxDataViewCtrl (via
        wxDataViewModel) and CMP_TREE_NODE*

                   +---+                      +------------------+
 +---+  Generates  | A |                      |       VIEW       |
 | M |  from libs  | D |   wxDataViewModel    |------------------|
 | O | <---------- | A | <------------------> |  wxDataViewCtrl  |
 | D |             | P |                      |------------------|
 | E | <---------> | T | <------------------- |    wxTextCtrl    |
 | L | UpdateScore | E | UpdateSearchString() |------------------|
 +---+             | R |                      |                  |
                   +---+                      +------------------+

Representing the data with a proper model allows the wxDataViewCtrl to
be updated in bulk, which is significantly faster than the old method of
populating it one item at a time. This also adds flexibility if more
data is to be added in the future (which may come in handy with the
upcoming .sweet format, as that adds more ways components can be related
to each other).

Replacing the wxTreeListCtrl with a wxDataViewCtrl also significantly
reduces the general GUI quirkiness, as wxDataViewCtrl is much more well
behaved.
2017-03-06 09:50:48 -05:00
Maciej Suminski fc4240886b Store VIEW_CONTROLS settings on a stack
This is the right implementation of the commit b25ded4d.
Previously if there were tools launched from another tool,
the settings could be stored in a wrong TOOL_STATE object.
2017-03-06 15:04:27 +01:00
Maciej Suminski d1550b0cdb Renamed VIEW_CONTROLS::SETTINGS to VC_SETTINGS.
Because nested types cannot be forwarded.
2017-03-06 15:04:27 +01:00
Maciej Suminski 3174573361 Removed code resetting VIEW_CONTROLS settings
As the VIEW_CONTROLS settings are managed for each tool,
there is no need to restore the settings to initial state
when a tool is finished.
2017-03-06 15:04:27 +01:00
Maciej Suminski ac38f1112d Removed duplicated code from TOOL_MANAGER::RunAction() 2017-03-06 15:04:27 +01:00
Chris Pavlina 541b91fd15 Fix FOOTPRINT_PREVIEW_PANEL loader thread synchronization 2017-03-05 22:22:25 -05:00
Wayne Stambaugh 6f3ec438cb Add missing install package to the compiling document.
The base-devel package install was missing from the "MSYS2 The Easy Way"
section of the compiling developers document.

Fixes lp:1670067

https://bugs.launchpad.net/kicad/+bug/1670067
2017-03-05 14:08:12 -05:00
Chris Pavlina 1cee5780a5 Fix GAL focus bug
Caused by yours truly in 4618e6c7
2017-03-05 13:58:31 -05:00
Wayne Stambaugh d9260d42c8 Fix broken schematic symbol library links in sub-sheets.
Only the root sheet symbol library links were being updated when the
schematic was loaded so changed call to update all sheets.

Fixes lp:1670079

https://bugs.launchpad.net/kicad/+bug/1670079
2017-03-05 13:18:26 -05:00
Wayne Stambaugh f181961866 Remove excessive schematic symbol library re-linking.
For some reason, the schematic symbol library link was being regenerated
every time the schematic was redrawn in SCH_SCREEN::Draw().  Remove the
re-link call from the Draw() and Plot() functions.

Add function the SCH_SCREENS to update the links in all of the schematic
sheets.

Update all schematic sheet symbol library links whenever the symbol
library list is modified or any library in the library list is modified.
That should cover all cases where the symbol library links could be
broken.

Refresh schematic window after applying library changes to update any
possible symbol changes.

Add KIWAY message to update the schematic when symbol library changes
could change the schematic.  The KIWAY mail was used because the schematic
frame is not a parent of the symbol library editor so wxEvents cannot be
used.
2017-03-04 16:02:33 -05:00
Wayne Stambaugh 84835ed4e1 Use component library symbol when looking for a pin in the schematic.
For some reason, rather than using the LIB_PART object reference by an
SCH_COMPONENT to check if a pin was at a given position in the schematic,
a LIB_PART search was performed for every component in a schematic.  This
made absolutely no sense and was changed to use the LIB_PART referenced
by the SCH_COMPONENT object.  This should significantly speed up any
operations that call SCH_SCREEN functions, IsTerminalPoint(),
MarkConnections(), and IsJunctionNeeded().

Add function to SCH_COMPONENT to access PART_REF object.
2017-03-04 15:16:44 -05:00
Chris Pavlina 551b2b2312 Component chooser: fix ugly border on macOS 2017-03-04 12:29:49 -05:00
jean-pierre charras 7a120ad698 selection_tool.* add comments and use better names for 2 similar methods. 2017-03-04 17:35:34 +01:00
jean-pierre charras 5b3d7962bb Fix questionable code and memory leak. 2017-03-04 17:35:34 +01:00
jean-pierre charras 101a600be6 Fix coding style issue and a minor other issue. 2017-03-04 17:35:34 +01:00
jean-pierre charras af161771b8 Fix compil issue on Windows 2017-03-04 17:35:33 +01:00
Chris Pavlina 4618e6c7f8 Component chooser: event and focus cleanup 2017-03-04 11:14:04 -05:00
Maciej Suminski 24a9003b5e Removed obsolete Shader.cmake script
Better way of including shader programs was introduced in 77f9cd0c
2017-03-04 11:48:37 +01:00
Maciej Suminski e6cfb6af52 Revert "Fix setting the background color in OPENGL_GAL"
Causes flickering on some GPUs.
This reverts commit ca985791bc.
2017-03-04 08:51:35 +01:00
Maciej Suminski 94d8e1e69c Fixed a memleak in ReadHotkeyConfig() 2017-03-04 08:38:35 +01:00
Cirilo Bernardo 68bcdec87e Workaround for non-ASCII filenames in Windows 2017-03-03 14:30:47 -05:00
Tomasz Włostowski 966052272f Coding style fixes 2017-03-03 20:27:05 +01:00
Tomasz Włostowski 18a9f037d2 DRC markers can now be selected and deleted in GAL like other items.
Fixes: lp:1621190
* https://bugs.launchpad.net/kicad/+bug/1621190
2017-03-03 20:26:34 +01:00
Tomasz Włostowski cc3d79f932 Reworked selection passing mechanism in SELECTION_TOOL.
- The tools can now specify if the items in the selection must be editable/
deletable. This is groundwork to be able to select/delete DRC markers, which can't
otherwise be edited.
- Fixed disappearing of selected objects
2017-03-03 20:26:34 +01:00
Tomasz Włostowski 9e73c3117e Added possibility to disable undo entries creation in COMMIT/BOARD_COMMIT 2017-03-03 20:26:34 +01:00
Kristoffer Ödmark 49c7400ca9 Reallow large scaling of 3D models
Fixes: lp:1669510
* https://bugs.launchpad.net/kicad/+bug/1669510
2017-03-03 10:30:09 -05:00
Simon Richter 1502e27695 Remove debug code matching on specific component names 2017-03-03 08:30:48 -05:00
jean-pierre charras 4eeed8d04f Icons options menu: code rework 2017-03-03 14:18:25 +01:00
Maciej Suminski 1dfd74bec9 Display S3DSG in single line during CMake configuration step 2017-03-03 13:38:12 +01:00
Maciej Suminski 389c7b2bbc Added AUTOROUTER_CONTEXT to keep objects used by autorouter
The main reason is to keep cached board bounding box and limit repeating
parameters in functions used by the autorouter.
2017-03-03 13:28:19 +01:00
Maciej Suminski 2483dab72f Do not cache board bounding box 2017-03-03 13:28:19 +01:00
Maciej Suminski a073a90c45 Remove BOARD::SetBoundingBox()
Bounding box should be computed basing on the items belonging to the
board.
2017-03-03 13:28:19 +01:00
Jon Evans 88f7c55d95 Move ZoomFitScreen and ZoomPreset from PCBNEW_CONTROL to COMMON_TOOLS
BOARD::GetBoundingBox() now directly calls BOARD::ComputeBoundingBox()
and there is a new method BOARD::GetBoardEdgesBoundingBox() used for
call sites that needed to use ComputeBoundingBox( true ) in the past.

This allows COMMON_TOOLS to implement ZoomFitScreen without knowledge
of the BOARD class.
2017-03-03 13:28:19 +01:00
Kristoffer Ödmark dda51ab550 CrossProbes Schematics from eeschema to pcbnew
Adds a similar crossprobe as modules has in pcbnew. When clicking a
sheet in eeschema, the items that are exclusive in that scheet will be
selected in pcbnew if using the GAL canvas.
2017-03-03 07:25:32 -05:00
Kristoffer Ödmark 69a649c093 Refactored out the function that selects items based on the sheetname 2017-03-03 07:21:41 -05:00
Maciej Suminski 906ee77dbf Fixed VIEW_ITEM memory leaks 2017-03-02 23:57:13 +01:00
Chris Pavlina 586c8f0feb Fix signed/unsigned compare warning 2017-03-02 14:46:19 -05:00
John Beard 75a9589213 io_benchmark: Add wxBufferedInputStream benchmarks
When run, these show a 10x speed up over wxFileInputStream alone and
about 30% over wxFFInputStream.
2017-03-02 12:28:53 -05:00
John Beard 814ff7c7fc io_benchmark: construct std::ifstream directly
This appears to normally use the move constructor, but on Jenkins Fedora
20, it tried to use the copy ctor, which is deleted.

Constructing directly fixes this, and is the right way, anyway.
2017-03-02 17:25:58 +01:00
jean-pierre charras e7e972804a Make show/hide icons in menus a run time option, instead of compil option. 2017-03-02 15:45:54 +01:00
John Beard bea0a9ab6e IO benchmark program: RICHIO vs std::fstream and wxStream
This compares the performance of RICHIO line readers against other
implementations, and can be used for profiling and optimisation.

Current benchmarks provided:

* richio FILE_LINE_READER
* Raw std::ifstream (no LINE_READER wrapper), using getline (so no line
length limiting)
* LINE_READER wrapper around std::istream, with a std::ifstream
implementation
* Existing richio wxInputStream wrappers (with File and FFile
implemntations)
2017-03-02 09:29:38 -05:00
Maciej Suminski 35c7974a96 Enable grid snapping when dragging items (GAL)
Fixes: lp:1668077
* https://bugs.launchpad.net/kicad/+bug/1668077
2017-03-02 15:21:49 +01:00
Tomasz Włostowski 4a911e0790 Highlight net tool in GAL now cross-probes to EEschema if clicked on a pad
Fixes: lp:1663767
* https://bugs.launchpad.net/kicad/+bug/1663767
2017-03-02 14:43:37 +01:00
John Beard e67882f0a3 Add WithAlpha method to COLOR4D
This is useful for taking a "base" color and making derived colours with
the given alpha, but the same RGB value.
2017-03-02 13:58:20 +01:00
Maciej Suminski 275ba503d1 Fix drawing arcs on Edge.Cuts layer
Fixes: lp:1666822
* https://bugs.launchpad.net/kicad/+bug/1666822
2017-03-02 13:52:36 +01:00
Maciej Suminski a5ac165c4b Make 'Enumerate Pad' tool more user friendly
Effects of enumeration are shown instantly, instead of after accepting
the changes.
2017-03-02 12:34:19 +01:00
Maciej Suminski 1d8730752c Restore valid force cursor setting before saving VIEW_CONTROLS settings
There are times, when TOOL_MANAGER has to force cursor position
to make tools work as expected (e.g. when popping up a menu,
so tools get the right click position instead of current position
pointing to an entry in the menu).

If another tool is invoked, VIEW_CONTROLS settings have to be stored
in the TOOL_STATE object. In such case, it is necessary to revert the
force cursor setting when saving VIEW_CONTROLS settings.

Fixes: lp:1668712
* https://bugs.launchpad.net/kicad/+bug/1668712
2017-03-02 12:07:09 +01:00
Maciej Suminski ca985791bc Fix setting the background color in OPENGL_GAL
Fixes: lp:1669098
* https://bugs.launchpad.net/kicad/+bug/1669098
2017-03-02 09:32:10 +01:00
Kevin Cozens 458b0e75e0 Prevent raytracing render engine option from crashing the 3D viewer
Fix for lp bug #1667722 using a change made by Mario Luzeiro.

Fixes lp:1667722

https://bugs.launchpad.net/kicad/+bug/1667722
2017-03-01 18:34:19 -05:00
jean-pierre charras 9f1e154753 Update Clipper to 6.4.2 2017-03-01 14:55:21 +01:00
John Beard 9dff85f0dc Add developer docs about testing 2017-03-01 14:05:51 +01:00
Maciej Suminski d7e1152aa3 Correct way of freeing memory in NGSPICE class
Strings created with strdup() should be deleted using free(), not
delete.
2017-03-01 13:56:24 +01:00
Martin Stoilov fc0814caef More flexible node mapping in Spice netlist exporter
Allows to map nodes to pins for Spice models that have more pins than
corresponding schematic symbol. An example is a MOSFET model containing
gate, source, drain & body, whereas schematic symbol part has only gate,
source & drain with body and source connected inside the part.
2017-03-01 13:51:21 +01:00
John Beard 4547b2e26d Don't init wxBitmaps before GUI is ready
Init'ing static wxBitmaps in the global scope happens before the GUI is
ready, which segfaults, at least on GTK+. This can happen in, for
example, the Python module. In normal use, the singletop/kicad
loader has initialised the GUI first, so it doesn't manifest there.
2017-03-01 13:28:10 +01:00
jean-pierre charras 8526935183 GAL: better progression between zoom in/zoom out (in/out/in sequence keeps the same zoom value) 2017-03-01 13:00:42 +01:00
jean-pierre charras 1cffcafe2d GAL mode: Add small cross option to grid style (now: options are Dots, Grid, Small cross) 2017-03-01 10:29:19 +01:00
John Beard 96b32861cd Fix layer color swatches in Linux 2017-03-01 09:51:52 +01:00
Maciej Suminski f4be80a3af Code formatting 2017-03-01 09:50:36 +01:00
John Beard 1d039cb4c1 Break row indicators out to own class
The introduces INDICATOR_ICON, which is a very simple class holding a
bitmap that can toggle on or off.

The ICON_PROVIDER class then provides icons to INDICATOR_ICONS, which
means the class can be used for more than just row indicators.

A default row icon provider is also provided for use in the standard row
selector.
2017-03-01 09:44:41 +01:00
John Beard 72354c5a81 Use Bind rather than Connect in LAYER_WIDGET
Bind is safer than Connect. Bind is more flexible and has a more concise
signature.
2017-03-01 09:44:41 +01:00
John Beard b8d0b0d7be Move layer/render swatches to own class
This introduces COLOR_SWATCH, which is a reusable
widget that shows a color swatch and can invoke the colour picker
when duble/middle clicked.

It uses it's own wxCommandEvent to signal the change.

This makes the layer widget simpler internally, and also allows other
code to show identical swatches if needed.
2017-03-01 09:44:41 +01:00
John Beard e609bc3f0d Use wxStaticBitmaps for layer/render swatches
On Linux with recent GTK+ toolkits, these swatches had very wide
borders, resulting in colour swatches of only a few pixels. On OSX, all
borders were disabled, leaving only the swatch.

This commit changes the wxBitmapButton to wxStaticBitmap, which fixes
the issue on Linux GTK+ and also removes the platform-specific element,
as it will now be the same on all systems.

These widgets aren't used as buttons anyway, a single click is handled
across the whole row, not just the swatch. So using a button was not the
most intuitive affordance.

Fixes: lp:1605411
* https://bugs.launchpad.net/kicad/+bug/1605411
2017-03-01 09:44:41 +01:00
Jon Evans a4fdbe6f2c Register common tools in footprint viewer to fix zoom controls 2017-03-01 08:56:26 +01:00
Maciej Suminski 7034ea0c95 Added missing PROPERTIES parameter to function calls in PART_LIB 2017-02-28 15:19:03 +01:00
Maciej Suminski 8b8de76aa5 Store information about buffering & caching in properties
PROPERTIES object has been recreated every time it was needed, using
two fields in PART_LIB class. Now the buffering & caching settings are
stored directly in a PROPERTIES object.
2017-02-28 15:18:58 +01:00
Jon Evans fd4e2b042c Refactor SELECTION, SELECTION_CONDITIONS, and context menus to common
SELECTION now holds EDA_ITEMs not BOARD_ITEMs so various places had to
change to casting the selected items to BOARD_ITEMs.

Fixed compilation warnings on clang (Tom)
2017-02-28 14:47:20 +01:00
Jon Evans 0afb249447 Add drawing priority support to VIEW
Call UseDrawPriority( true ) after creating GAL to enable.

VIEW::Add() gets a new optional argument to specify the draw order
when adding an item.  If the new argument is left default, the draw
order will increment with each call of VIEW::Add().

Fix std::bind calls after change to VIEW::Add
2017-02-28 14:47:20 +01:00
jean-pierre charras be10de8d28 Eeschema: Fix crash when reading a library if a symbol having aliases generates a parse error after its ALIAS list definition 2017-02-28 12:52:37 +01:00
jean-pierre charras 94037f4d3d Fix eeschema crashes when a library has a component where the name under "DEF" does not agree with the name under "F1"
(now "F1" is forced to name given by "DEF", like in stable version)
Fix also an incorrect parsing of .dcm file, if  a component was not found in corresponding symbol lib.
(Can happen for not updated .dcm files)
2017-02-28 11:48:01 +01:00
John Beard a0df0f7f06 When filling/unfilling zones, create undo points in GAL
This is a feature which is apparently not available in legacy, but the
undo points created in GAL do work in legacy mode.
2017-02-27 18:00:51 +01:00
John Beard 796f3219d0 Draw zone hatching in GAL
This just uses the same hatch lines that are built into the zone as
legacy.

They are always drawn, even when there is a fill, as if the fill
doesn't reach the corners, the hatches can be seen.

Fixes: lp:1487043
* https://bugs.launchpad.net/kicad/+bug/1487043
2017-02-27 18:00:46 +01:00
jean-pierre charras 64d6c3f91c eeschema segfault when a library "T" command is missing Halign Valign values
Fixes: lp:1668082
https://bugs.launchpad.net/kicad/+bug/1668082
2017-02-27 17:22:06 +01:00
jean-pierre charras f35cb6cd6a Fix: if a part description has a problem in a library, Eeschema crashes due to a double deletion. 2017-02-27 16:13:16 +01:00
Maciej Suminski 799c8b6922 Fixed a shadowed variable warning in clipper 2017-02-27 10:42:32 +01:00
Maciej Suminski 9ead2b068b Fixed crash when placing a component in standalone eeschema
Fixes: lp:1668157
* https://bugs.launchpad.net/kicad/+bug/1668157
2017-02-27 10:29:53 +01:00
Oliver d6097cf1aa Better footprint association and filtering:
1. If a footprint filter contains a : (colon) character, then the filter is matched against the pattern <LibName>:<FootprintName>
2. If there is *no* : (colon) character present, then it is matched against <FootprintName>
3. The same behaviour applies for the manual filter string in CvPCB
2017-02-26 18:15:23 +01:00
jean-pierre charras 6b431b4791 Fix transaltion issue.
Rebuild dialog_display_options_base with a recent wxFormbuilder version.
2017-02-26 13:03:38 +01:00
jean-pierre charras 1001442a48 Pcbnew: Fix an assert in debug mode, and fix a minor issue in menubar 2017-02-26 11:47:15 +01:00
jean-pierre charras 94bef6abd2 Pcbnew: files written when layers have numeric name (like +24)cannot be read
Fixes: lp:1667867
https://bugs.launchpad.net/kicad/+bug/1667867
2017-02-25 10:10:43 +01:00
Chris Pavlina e6de99cc86 No more wxSearchCtrl in DIALOG_CHOOSE_COMPONENT
It is buggy on several platforms
- macOS: eats Esc key
- Windows: poor text alignment
2017-02-24 16:01:58 -05:00
jean-pierre charras 6bd2110449 Remove a printf clearly for debug, certainly a very old bug 2017-02-24 20:51:50 +01:00
jean-pierre charras 6ae7c15d89 Rework on pcbnew menubar: make code more easy to read and modify. 2017-02-24 20:51:49 +01:00
Chris Pavlina 23d4da9e49 Optimize TWO_COLUMN_TREE_LIST column sizing
This was particularly slow for very long lists on macOS.
2017-02-24 12:51:53 -05:00
Chris Pavlina 9effcb80e7 Optimize SCH_PLUGIN enumeration for populating the component chooser 2017-02-24 11:47:27 -05:00
Maciej Suminski adba96fd2b Changed optional::value_or() to optional::get_value_or()
get_value_or() is considered deprecated, but still works in the newest
boost (1.63). On the other hand, value_or() is not available in some
versions that are still used by major distros.
2017-02-24 17:34:23 +01:00
Maciej Suminski e34b73e187 Do not freeze cursor when a tool was cancelled using the context menu
dispatchContextMenu() stores the cursor position before displaying a
menu, so the tools use the original cursor position when processing
events (instead of the mouse position pointing to a menu entry). Later,
the previous position has to be restored, but if in the meantime the
tool was cancelled - previous settings were restored to a wrong tool.
2017-02-24 16:55:18 +01:00
Maciej Suminski b25ded4d90 Store VIEW_CONTROLS settings when tools are switched
Fixes: lp:1663783
* https://bugs.launchpad.net/kicad/+bug/1663783

Fixes: lp:1667580
* https://bugs.launchpad.net/kicad/+bug/1667580
2017-02-24 16:47:19 +01:00
Maciej Suminski 57050cdeb3 Introduced VIEW_CONTROLS::SETTINGS to keep settings
The new class facilitates saving and restoring VIEW_CONTROLS
settings such as cursor visibility, snapping, etc.
2017-02-24 13:33:17 +01:00
Maciej Suminski d3edc4f843 Disable router menu when the tool is stopped 2017-02-24 13:32:47 +01:00
Maciej Suminski 72cae92320 Disable context menu trigger if the assigned menu is set to null 2017-02-24 13:32:43 +01:00
John Beard c001c6114f Add cancel interactive tool action to GAL
This is used to provide menu entries that allows cancellation of
interactive drawing and routing tools without needing the keyboard.

It is provided in the drawing tools and the router tool.

The cancel event doesn't have any new functionality (e.g. track rip-up
for the PNS router - lp:1448460), this just adds it to the menu, where
it behaves the same as an Escape keypress.
2017-02-24 10:37:07 +01:00
Chris Pavlina d3cb23b7d7 Remove unneeded state member in DIALOG_CHOOSE_COMPONENT 2017-02-23 20:59:15 -05:00
Chris Pavlina 2683af26c0 Fix DIALOG_CHOOSE_COMPONENT enter and double-click events 2017-02-23 20:51:29 -05:00
Simon Richter 986c92f880 Remove unnecessary double define
CMake already sets NDEBUG by default for Release builds, no need to duplicate this.
2017-02-23 14:54:11 -05:00
Simon Richter 70b3edd06f Drop unnecessary and possibly harmful optimization setting
Using -O3 is default for release builds with gcc/clang anyway, so this
doesn't gain anything, but overwriting the existing flags might remove some
that might be needed.
2017-02-23 14:44:15 -05:00
jean-pierre charras 04d1b2fca7 fix incorrect COLOR4D::COLOR4D( EDA_COLOR_T aColor ) ctor for UNDEFINED_COLOR 2017-02-23 18:17:47 +01:00
jean-pierre charras 039910cb21 Fix incorrect initialization of a color parameter, which make the drawings in black in libedit 2017-02-23 17:55:55 +01:00
jean-pierre charras 2f24b31b28 simplify color calculation. 2017-02-23 17:55:55 +01:00
Simon Richter 3bf0b9534c Fix incorrect parameter if the compiler doesn't support -Wshadow option 2017-02-23 17:55:55 +01:00
John Beard 88fb7483eb Register COMMON_TOOLS in modedit
Without this, no actions from that tool will work, which includes things
like settings the grid size.

Fixes: lp:1667264
* https://bugs.launchpad.net/kicad/+bug/1667264
2017-02-23 15:20:22 +01:00
jean-pierre charras 1f345052cd Fix erroneous conversion between wxColor and COLOR4D 2017-02-23 14:30:43 +01:00
jean-pierre charras cf70aa925c Fix shadowed warnings with overzealous compilers 2017-02-23 13:17:23 +01:00
jean-pierre charras 11dcb76fc9 Add -Wshadow compil option, if exists to warn about shadowed variables.
Swig auto generated .cxx file has a lot of shadowed variables, so this option cannot be used to compil all files.
2017-02-23 13:17:23 +01:00
jean-pierre charras a9d6af8001 Fix a comment 2017-02-23 13:17:23 +01:00
Marco Sterbik d284fb87e8 Change reporter message of footprint missmatch to warning on netlist-import
The message of a changed footprint during netlist-import in pcbnew was declared
as RPT_UNDFINED and therefor the filter didn't work correctly ('Warning' was
in the message-string).
This makes the message a proper warning and enables filtering as expected.
2017-02-23 11:59:00 +01:00
Maciej Suminski 887f2b2a70 Adjusted "Select" context menu conditions
Shows "Select" submenu when there is at least one item selected.
It is necessary to use "select same sheet" and selection filter
effectively.
2017-02-23 10:50:38 +01:00
John Beard c6046d6da2 Add selection filter dialog to GAL
Fixes: lp:1535805
* https://bugs.launchpad.net/kicad/+bug/1535805
2017-02-23 10:50:38 +01:00
John Beard 6ba9a512b6 Factor DIALOG_BLOCK_OPTIONS into separate compilation unit
This means the dialog can be accessed from both GAL and legacy modes.

This also removes the use of static bools for passing the selection
states and instead used a struct of values passed in by the calling
code.
2017-02-23 10:50:38 +01:00
Maciej Suminski 1077b679c5 Minor updates to the Tool Framework documentation 2017-02-23 09:45:43 +01:00
John Beard 6b39e9ea81 Update GAL tool documentation
Update to reference new PCB_ACTIONs (used to be COMMON_ACTION)

Also expand on use of BOARD_COMMIT.

Add doxygen TOC markup
2017-02-23 09:00:55 +01:00
jean-pierre charras 10396ff435 Tool manager: renames Yield() to KiYield(), due to a collision name between the Yield macro in wxWidgets and Tool manager Yield.
Can be dependent on platforms.
2017-02-23 08:30:29 +01:00
Chris Pavlina d1a2ed63c0 Add gal as dependency of common
This is required due to the use of COLOR4D in common
2017-02-22 19:45:52 -05:00
Jon Evans f9bc5914b3 Wrong type of arguments in wxPen constructor
Has pointed out by Jon Evans the constructor need the .ToColour() and should be called like:
wxPen pen( GetParent()->GetGridColor().ToColour(), h );

Submitted-by: Diogo Condeco <diogocondeco@gmail.com>
2017-02-22 14:12:58 -05:00
Joseph Y. Chen ed16beb5cd Rearranged Part Editor Icon Positions
The changes were made to rearrange the positions of the first 5
icons in the part editor so that they are consistent with footprint
editor.

Signed-off-by: Joseph Y. Chen <joseph.chen59@yahoo.com>
2017-02-22 13:24:49 -05:00
Maciej Suminski d7bf44eee0 Removed a few more headers from base_struct.h 2017-02-22 17:54:01 +01:00
Maciej Suminski 0dc88bb4cf Changed COLOR4D defines to static consts 2017-02-22 17:35:00 +01:00
Jon Evans 3ec8941ffc Revert from wxColourPickerCtrl to wxBitmapButton
wxColourPickerCtrl apparently looks bad on Windows 10
2017-02-22 17:35:00 +01:00
Jon Evans a52250a91e Change from EDA_COLOR_T to COLOR4D globally; arbitrary color support
eeschema now supports arbitrary colors for all object types, and
pcbnew does in GAL canvas.  When switching from GAL to legacy canvas,
pcbnew will convert colors to the nearest legacy color.
2017-02-22 17:35:00 +01:00
Jon Evans 4c83b0a94d Move TOOL_ACTIONs to their corresponding tools; create COMMON_TOOLS
Some grid/zoom tools are left in PCBNEW_CONTROL because they currently
depend on Pcbnew-specific class members.  Once refactoring is done to
make it possible to use all zoom and grid controls outside of pcbnew,
these last tools can be moved to common to match their ACTIONs.
2017-02-22 10:32:48 +01:00
Jon Evans 167f45ca2b Refactor COMMON_ACTIONS into a base and derived class
New virtual class ACTIONS is added as a member to EDA_DRAW_FRAME so
that the TOOL_DISPATCHER can have access to the appropriate derived
version of TranslateLegacyId()
2017-02-22 10:32:48 +01:00
Cirilo Bernardo 2b2b73ee4b Fix bug: Footprint add 3D shape recognizes only files with lower case ext on Windows
Fixes: lp:1659027
https://bugs.launchpad.net/kicad/+bug/1659027
2017-02-22 10:22:33 +01:00
Fabrizio Tappero 68c2639e7d Update pl editor icon 2017-02-22 08:53:36 +01:00
Chris Pavlina 35a8d78921 Fix component selector segfault on MacOS
Fixes: lp:1666081
* https://bugs.launchpad.net/kicad/+bug/1666081
2017-02-21 18:37:37 -05:00
Chris Pavlina 8bed8af03f Add missing break in switch 2017-02-21 15:22:30 -05:00
John Beard a8eea6155a Move bitmaps.h out of base_struct.h
bitmaps.h was included in nearly every file in the project due to it
being included by base_struct.h

Only about 130 files actually use the XPM definitions defined there, and
many of those already included bitmaps.h themselves, or via
menu_helpers.h. However, touching bitmaps.h would result in over 400
rebuilt files for pcbnew alone.

This commit moves the bitmap-related types like BITMAT_DEF out to a new
header, which is still included by base_struct.h, which is less
avoidable for now, it's it's used in the interface.

The icon list is still in bitmaps.h. This has the side effect that's
it's now easier to automatically generate this file.

Many classes in pcbnew and eeschema needed some functions moved
to the implementaitons from the headers too.
2017-02-21 09:50:15 -05:00
Dick Hollenbeck 45cf772833 Make the python pcbnew native module from the _pcbnew.kiface, phase 1 of a 2 part plan. 2017-02-21 07:56:17 -05:00
jean-pierre charras dba49ab299 fix incorrect wxWindow style for TREE_PROJECT_FRAME 2017-02-21 09:37:13 +01:00
Chris Pavlina ca7f1d5a08 Remove accidentally committed diodes.lib 2017-02-20 14:57:45 -05:00
Chris Pavlina 57de6ec0af Remove SetFocus hack after changing to wxSearchBox 2017-02-20 14:41:21 -05:00
Joseph Y. Chen cc11c269e3 Swapped part editor icon order to be consistant with footprint editor
Signed-off-by: Joseph Y. Chen <joseph.chen59@yahoo.com>
2017-02-20 13:38:32 -05:00
Maciej Suminski 6fdccc1829 PAD_TOOL: enable 'Apply' after copying a pad 2017-02-20 11:09:00 +01:00
John Beard 2fa17b4460 Put pad enumerate tool in PAD_TOOL submenu
Prior to this, it was in the top level of the selection
menu, and was always shown, even if the module editor
didn't have a loaded footprint.
2017-02-20 11:08:34 +01:00
John Beard ca91c27852 Adjust pad sub-menu enablements
The apply settings and push settings options now take account of the
validity of the global pad settings when deciding whether to show or
not.

Global pad push now requires a source pad and doesn't push from the
global pad setting when there is no selection.

The whole submenu is hidden when there are no enabled items.

Fixes: lp:1664016
* https://bugs.launchpad.net/kicad/+bug/1664016
2017-02-20 11:08:34 +01:00
John Beard 6164b9be2a Grid line/point size & density settings 2017-02-20 10:53:40 +01:00
John Beard ca75be4b4e Simplify display option selection mappings using CFG_MAP
Rather than defining static functions to do the mapping, this can be mor
concisely done with the UTIL::CFG_MAP utility functions.
2017-02-20 10:52:34 +01:00
John Beard 8766b475c6 Sanitise incoming GAL config options using mapping tables
When reading config options from files, it's important to make sure the
value makes sense - the incoming data could be anything, and may have
incompatible values or be otherwise unreliable.

This introduces a simple way to define and use "mapping tables" which
can map between a "native" value, probably an enum (but not necessarily)
and some external value, for example the value written to file.

This provides a decoupling between the two values, as well as sanitising
inputs and outputs. This is important, as over time, if there isn't a
decoupled interface, changing options result in corrupt configs, or a
proliferation of obsolete enum values kept for compatibility.
2017-02-20 10:52:34 +01:00
John Beard 1f5619f740 Add protected virtual dtor for GAL_DISPLAY_OPTIONS_OBSERVER
GAL_DISPLAY_OPTIONS_OBSERVER aren't deleted by a base class pointer -
they are an "incidental" part of other classes. Add a virtual protected
destructor to make this explicit.
2017-02-20 10:52:34 +01:00
John Beard 0bf3a19967 Add user control for grid minimum spacing in GAL
This allows the user to set a thicker grid line without causing the
grid lines to become over dense, or just make the grid denser according
to preference.

The term "density" is modified to "minimum grid spacing", which is
the pixel spacing between adjacent grid lines.

The spacing settings now comes in along, with other GAL display settings,
as part of GAL_DISPLAY_OPTIONS observer functionality. To this end, the
setter in GAL interface is removed, as an external user should be
setting this parameter via the GAL_DISPLAY_OPTIONS interface.
2017-02-20 10:52:34 +01:00
John Beard 970e4f8eb4 Add grid line thickness control to Display Options Dialog
This adds a user-settable control for the grid line thickness on GAL
canvases to the display options dialog.

The thickness settings now comes in, along with other GAL display
settings, as part of GAL_DISPLAY_OPTIONS observer functionality. To this
end, the setter in GAL interface is removed, as an external user should
be setting this parameter via the GAL_DISPLAY_OPTIONS interface.

Fixes: lp:1662482
* https://bugs.launchpad.net/kicad/+bug/1662482
2017-02-20 10:52:34 +01:00
John Beard 061d659bb1 Add a class to govern an "incrementing" text control
This class, INCREMENTAL_TEXT_CTRL, is used to provide a frameworks for
classes that want to control a text control that can be incremented
according to some scheme.

Also provided is a wxWidgets implementation with spin buttons for
control, as well as mousewheel support.
2017-02-20 10:52:34 +01:00
John Beard 971f2db034 Break Display Options control value/enum mapping to functions
The mappings from enums to control settings can be done in static
functions, which makes the set/retreive functions more concise, and also
puts the mapping functions in a clearly delineated place.
2017-02-20 10:52:34 +01:00
John Beard ff3bfaf82b Make KIGFX::GRID_STYLE an enum class
This provides stronger typing to these values.
2017-02-20 10:52:34 +01:00
John Beard 7ad30b7167 Move Grid style to Graphics Options dialog
This puts the graphical/display options with the other similar options
in that dialog, rather than with the dimension options found in the Set
Grid dialog, which is in the Dimensions menu.

Also place the option itself in the GAL Display Options structure, so it
can be updated using the observer mechanism there.

The setter for the style in the GAL interface is removed, as the public
interface for setting this option is now to modify the
GAL_DISPLAY_OPTIONS structure and notify the GAL when done.
2017-02-20 10:52:34 +01:00
John Beard ddded86a06 Give all GAL canvases access to a GAL_DISPLAY_OPTIONS structure instance
Also loads the gal options when loading a canvas, as the canvas
otherwise might not register the initial settings.
2017-02-20 10:52:34 +01:00
John Beard cdfcc9a2ab Put draw_frame.h GAL_DISPLAY_OPTIONS behind firewall
The GAL_DISPLAY_OPTIONS member of EDA_DRAW_FRAME is a private member and
is used in only a couple of places in the class. The real use of this
member is by a by-ref interface, GetGalDisplayOptions.

Because te GAL options are used by a very select few users of
EDA_DRAW_FRAME, it makes little sense to force all the (many) files
including draw_frame.h to also include gal_display_options.h, when the
vast majority have no need for it.

This massively speeds up compilation of the project when
gal_display_options.h is changed.

More isolation could be acheived by separating the GAL config types (eg
OpenGL antialias modes and grid style) from the options header, as,
although the GAL class uses them, not many includers of the GAL header
need the options struct as well.
2017-02-20 10:52:33 +01:00
Jon Evans 9d68c970dc Remove dependence on LAYER_ID from EDA_DRAW_PANEL_GAL 2017-02-20 09:15:55 +01:00
Chris Pavlina a416f3a4e4 Remove unnecessary TRANSFORM::operator=
The default assignment operator is significantly more efficient - often
inlined, and has no branches...
2017-02-19 22:13:50 -05:00
Chris Pavlina 0182e454c5 Adjust component chooser GUI slightly 2017-02-19 19:31:53 -05:00
Wayne Stambaugh 1672d37782 Fix bug in legacy schematic I/O plugin.
When part definition contained in line comments, the next line was not
being loaded causing and infinite loop.

Fixes lp:1666024

https://bugs.launchpad.net/kicad/+bug/1666024
2017-02-19 17:44:53 -05:00
Chris Pavlina 70301a6244 Component chooser: display correct unit in reference field 2017-02-19 15:11:35 -05:00
Chris Pavlina 2e07d83461 Reduce footprint preview flickering in component selector 2017-02-19 14:54:36 -05:00
Chris Pavlina 69165aa0a0 Do not show hidden fields in the component selector
This is not necessary anymore, as they are displayed in the info box.
2017-02-19 13:43:50 -05:00
Chris Pavlina a61be7e00e Move LIB_PART::Draw drawing options into a struct
This makes configuring the options clearer, avoiding the long list of
non-self-explanatory arguments at the small cost of requiring a few more
lines.
2017-02-19 13:40:26 -05:00
Chris Pavlina 5dea5e2ada Component chooser: add missing info panel updates 2017-02-19 10:01:45 -05:00
Chris Pavlina b4f4ff9353 Clean up updateSelection() megafunction 2017-02-19 09:24:40 -05:00
Chris Pavlina 3d88cc2a36 Rename method for consistency with similar class
FOOTPRINT_PREVIEW_PANEL::AddToPanel -> InstallOnPanel
2017-02-19 07:53:02 -05:00
Chris Pavlina fb6bf0c861 Fix SetColumnWidth() assertion in TWO_COLUMN_TREE_LIST
Fixes: lp:1665982
* https://bugs.launchpad.net/kicad/+bug/1665982
2017-02-19 06:38:53 -05:00
jean-pierre charras 1e242f3710 Remove a #define used in a debug session, and now useless in panel_prev_model.* 2017-02-19 08:30:34 +01:00
Chris Pavlina 2632b1d1a0 Revamp component chooser and add footprint preview
This commit brings several changes:

- Add a footprint preview pane to the eeschema component selector
- Upgrade component list to wxTreeListCtrl
- Factor out wxTreeListCtrl subclass TWO_COLUMN_TREE_LIST which
  patches a column size bug
- Linkify datasheet URL in info pane
2017-02-18 21:39:55 -05:00
Clemens Koller d99da201fb kicad: tree_project_frame: fixup drawframe style.
wxNO_BORDER and wxSW_3D seem incompatible and the border flickers
when the tree frame gets resized. Using KICAD_DEFAULT_DRAWFRAME_STYLE
avoids this.

Signed-off-by: Clemens Koller <cko@embeon.de>
2017-02-18 18:07:26 -05:00
Wayne Stambaugh 0898b6c94d Prevent symbol libraries from being unnecessarily reloaded.
When Eeschema is relaunched from KiCad, the symbol libraries were always
reloaded which isn't necessary as they are maintained by the kiface project
object until the project is changed.

Fix minor title capitalization in symbol library progress dialog.
2017-02-17 19:31:47 -05:00
Wayne Stambaugh ccbdb41186 Remove conversion from wxString using FROM_UTF8() when loading symbols.
A conversion from wxString using FROM_UTF8() was inadvertently used when
loading and enumerating symbols from the legacy plugin.  This conversion
would break any non-ascii characters in the symbol name.

Fixes lp:1664642

https://bugs.launchpad.net/kicad/+bug/1664642
2017-02-16 14:03:19 -05:00
Jon Evans 7cd72d6ffb Move layer colors from PCB_RENDER_SETTINGS to RENDER_SETTINGS 2017-02-16 17:30:31 +01:00
Jon Evans 7058e4eb21 Setup painter in PCB_DRAW_PANEL_GAL instead of EDA_DRAW_PANEL_GAL 2017-02-16 17:30:31 +01:00
Wayne Stambaugh 9375e18fb6 Fix broken symbol library alias root symbol links.
Check to see if the root symbol alias already exists before adding it to
the symbol library alias list in the legacy schematic I/O plugin.  There
currently about six different ways that the root alias can be changed in
the root symbol which causes issues.  This really needs to be cleaned up.

Use buffering when updating a symbol in a library to prevent the library
file from being written before it is backed up.

Update the alias and unit selection menubar drop down lists.

Delete the output formatter so the file is closed so that reading the
file time stamp can be performed to prevent unnecessary cache reloads.

Fixes lp:1664834

https://bugs.launchpad.net/kicad/+bug/1664834
2017-02-15 20:28:36 -05:00
Wayne Stambaugh 58ed5466b4 Fix legacy schematic I/O symbol library parser bug.
Apparently symbol definition blocks can have a '0' character in the lock
position which is typically defined as 'L' or 'F'.  This must have been
a oversight at some point since both versions of the DEF parameters
exist in library version 2.3 files.

Disable the symbol library cache buffering after saving.
2017-02-14 14:49:22 -05:00
Jon Evans 92a2b2b684 Correctly filter copyable objects for copy hotkey (Fixes lp:1571316) 2017-02-14 09:48:28 -05:00
jean-pierre charras 19fef1e9ba Fixes: lp:1664349 (DRC complaining about not connected pads even if they are not on a copper layer)
(happens when creating pads with complex shapes)
https://bugs.launchpad.net/kicad/+bug/1664349
2017-02-14 14:40:34 +01:00
Julius Schmidt 877a65dcc7 Fix ratsnest calculation for pads connected with zones (GAL)
This patch fixes a problem with GAL where zones are ignored in ratsnest
calculation.
The problem is that calling RN_DATA::Update on a zone with no polygons
(an unfilled zone) will remove the zone successfully, but then
RN_DATA::Add is a no-op.
From this point on, because ::Update refuses to work on items that have
not been ::Add'ed, the zone is removed entirely from ratsnest
calculation and will only be reconsidered once it is explicitly ::Add'ed
again.
The fix is to explicitly create an empty RN_ZONE_DATA object for every
zone that is ::Add'ed.

A second problem is that the point editor forgot to call
RN_DATA::Recalculate after calling Fill_Zone.

Fixes: lp:1537120
* https://bugs.launchpad.net/kicad/+bug/1537120
2017-02-14 00:39:41 +01:00
hauptmech 461c72c034 Prevent segfault when aOutline has no vertices.
When attempting to read a pcad file exported from Altium, kicad was
segfaulting because it was trying to access an empty array. This patch
fixes that.

The reason the array was empty was the the board outline in the pcad
file was composed of only arcs and the plugin only processes lines in
the board outline. Adding this functionality is for another patch I
suppose.

Signed-off-by: Clemens Koller <cko@embeon.de>
2017-02-13 17:33:09 -05:00
Wayne Stambaugh 175d68fbb1 Fix schematic cache library broken by schematic I/O plugin changes.
Check for existence of cache library when before attempting to rebuild
the cache.  Create a new cache library object if no cache library was
loaded.

Add missing buffering and cache properties to LIB_PART::FindAlias() to
prevent the plugin from reloading the cache library that may not exist.

Add method to find library by full path and file name.

Revert the check for a symbol in the cache library remove from last
patch.

Add checks for plugin cache file name validity and existence of a the
file before attempting to verify the file modification time to prevent
wxWidgets from raising an assertion in debug builds.

Clear modified flag when saving buffered and/or cached library.
2017-02-13 13:47:46 -05:00
Mario Luzeiro 2a793cc22c Remove mm_malloc from raytracer
There is no need to use mm_malloc at this moment. Explanation:
1) It was planned that there was advantadge to use aligned memory but it
was not measured the performance. 2) aligned memory is needed for use
with SIMD (i.e: SSE) but that is not used at moment.

Fixes: lp:1626278
https://bugs.launchpad.net/kicad/+bug/1626278
2017-02-13 10:08:20 -05:00
jean-pierre charras 010c10853c Libedit: add "create new lib" in file menu (was only available from the main toolbar)
Make also "Save Lib" shortcut modifiable by user, like other shortcuts.
2017-02-13 09:53:47 +01:00
Wayne Stambaugh d5bf465dc6 Fix library save bug in legacy schematic I/O plugin.
Add the ability to save empty symbol library file for caching and empty
schematic.

Remove check for existing symbol in cache populating routine.  Just perform
a complete rebuild of the cache library and overwrite the existing one.

Fixes lp:1663871

https://bugs.launchpad.net/kicad/+bug/1663871
2017-02-12 18:40:53 -05:00
jean-pierre charras 3f1bcf5be8 Pcbnew: Fix "push pad settings" segfault when no pad selected.
Fixes: lp: 1663915
https://bugs.launchpad.net/kicad/+bug/1663915
2017-02-12 08:09:21 +01:00
Wayne Stambaugh e8cf4f0724 Fix bug in legacy schematic I/O plugin.
Move adding LIB_PART to library until the part is fully parse.  The problem
was unique_ptr was cleaning up the part when an exception was thrown during
parsing causing a double free when the cache was deleted.

Add missing try/catch block when loading the cache library during an append
schematic operation.

Fixes lp:1663869

https://bugs.launchpad.net/kicad/+bug/1663869
2017-02-11 20:19:52 -05:00
Wayne Stambaugh eb06b35852 Eeschema: fix schematic I/O plugin symbol name issue.
LIB_ID was changing the symbol name due to the parser dropping everything
past the first '/' character which is interpreted by LIB_ID as the item
version.  Add flag to ignore this in LIB_ID::SetLibItemName() and add a
new ctor so the library nickname, item name, and revision can be set as
required to prevent the standard LIB_ID parsing.

Fix a few places where PART_LIBS functions FindLibraryAlias() and
FindLibPar() were translating wxString symbol names to LIB_IDs where the
LIB_ID parser was truncating the symbol name.
2017-02-11 13:44:17 -05:00
Kristoffer Ödmark 37c086896e Enables selection of components and tracks on same sheet.
Modifies the selection menu to be adaptive and disable selection options
that are not possible.

Adds a new selection option that is only available when selecting
modules, this tool will select all footprints on the same sheet level or
belonging to subsheets. It will also search for nets that are only
connecting between modules on the same sheet or lower and select every
segment and via belonging to it.
2017-02-11 07:33:49 -05:00
Maciej Suminski 092c61e021 More robust condition to avoid division by 0 in D_PAD::ViewGetLOD() 2017-02-11 09:18:56 +01:00
Jean-Samuel Reynaud 3ec6f1d33b Fixed crash when pads have negative clearance
Fixes: lp:1663173
* https://bugs.launchpad.net/kicad/+bug/1663173
2017-02-11 09:16:59 +01:00
Maciej Suminski 95794df088 Code formatting 2017-02-10 23:23:56 +01:00
John Beard 728349ea12 Add similar zone tool in GAL
This action launches the normal interactive zone tool, but re-uses the
settings from an existing zone, based on a flag passed to the main zone
function.
2017-02-10 23:23:55 +01:00
John Beard abe83b54ae Add zone cutout tool to GAL
When activated, the zone interactive editor is launched with a flag. The
drawn zone is then used to modify the existing zone at the end of the
action.
2017-02-10 23:23:55 +01:00
John Beard d37586aeaf Refactor GAL dialog prompt for new zone settings
Break a chunk of the new zone tool out into a separate function to keep
the code clear. When zone cutouts and similar zone tools are added,
they'll get the settings from existing zones.

This commit now used std::unique_ptr for the temporary zone item, which
simplifies handling of the ownership of that item.
2017-02-10 23:23:55 +01:00
John Beard 1f9c483535 Allow delete whole track in GAL
This commit wires up the as-yet-unused "remove alternate" tool action
and uses it to select copper connections (normally 'U') before deleting
segments.

THis also reverses the sense of Delete and Backspace (Delete used to be
'remove' and Backpace was 'remove alt', now it is reversed). This means
that backspace is the key that removes a segment and Delete removes the
track. This is the same as legacy behaviour. Other delete actions are,
for now, the same between Delete and Backspace.

Fixes: lp:1517213
* https://bugs.launchpad.net/kicad/+bug/1517213
2017-02-10 22:42:55 +01:00
John Beard 0cd121049f Allow selectConnection/Copper/Net on multiple items
The previous behaviour was to act on only the first item in the
selection. The new behaviour is to act on every eligible item (in this
case, tracks and vias).
2017-02-10 22:42:55 +01:00
Aurabindo J 112c10fbd9 Pcbnew: Update Ratsnest immediately after rotation/flip/mirror
Provide a visual feedback to the user how each rotation
will affect the routing by immediately reflecting the
change in ratsnest orientation.

Signed-off-by: Aurabindo J <mail@aurabindo.in>

Fixes: lp:1663488
* https://bugs.launchpad.net/kicad/+bug/1663488
2017-02-10 22:25:47 +01:00
Julius Schmidt a54830897b Fix intermittent canvas revert to default
The attached patch fixes a minor bug where opening the 'View' menu
will sometimes revert the canvas to the default canvas.  The problem is
that wxMenuItem::Check will cause a menu event when the status is changed even
if the checkmark is being *unset*.  The workaround is to only call Check with
a true argument.  This works because the menu items are radio buttons.
2017-02-10 14:52:26 -05:00
jean-pierre charras dd5b024903 Pad export/import settings functions: remove duplicate code. 2017-02-10 20:44:35 +01:00
jean-pierre charras 9d43817db8 Make a debug message not translatable. 2017-02-10 20:44:35 +01:00
Wayne Stambaugh 899fe08f20 Remove KICAD_USE_SCH_IO_MANAGER build option from docs and build info. 2017-02-10 11:58:15 -05:00
Wayne Stambaugh 7ccdca5ced Use library ID to store library symbol information in the schematic symbol.
Use LIB_ID instead of wxString for storing the library symbol information
in the schematic symbol in preparation for the upcoming symbol library table
implementation.

Change the FindLibAlias and FindLibPart functions in the PART_LIBS object
instead of wxString.  Please note that only the library ID name is used to
search the list of libraries.  The library nickname is ignored.  Once the
symbol library table is implemented and full LIB_IDs are defined, the
library search code will no longer be used and will only be kept to load
older schematics that have not been converted.

Move SCH_LEGACY_PLUGIN_CACHE definition so that the legacy plugin knows
how to properly delete the cache object.
2017-02-10 08:36:59 -05:00
Wayne Stambaugh ebfbbcc1f5 Fix missing part library broken by schematic I/O plugin changes.
The LIB_PART object stores a pointer to the PART_LIB that it belongs to.
Now that the PART_LIB is no long responsible for loading the library, add
the PART_LIB pointer after the library is loaded by the plugin.
2017-02-10 08:36:58 -05:00
Wayne Stambaugh fda677eecc Prevent schematic I/O plugin from setting the library cache to null.
Don't call init() when performing library functions as it was always
setting the m_cache variable to null which cause the library to be
reloaded every time a library command was performed as well as a
memory leak.

Delete cache object when the plugin is destroyed.
2017-02-10 08:36:58 -05:00
Wayne Stambaugh 73bbc35c3e Make the schematic I/O plugin the only option.
Add SCH_PLUGIN object to PART_LIB object.

Convert all PART_LIB I/O to use SCH_PLUGIN.

Remove library caching from PART_LIB and use caching provided by SCH_PLUGIN.

Add support to use PROPERTIES for buffering and document file write control
instead of adding code the SCH_PLUGIN object in the SCH_LEGACY_PLUGIN that
will not be required when the new file formats are implemented.

Add buffering to SCH_LEGACY_PLUGIN to prevent cache from writing file on
every change to library.  This is to prevent the cache library from being
written every time a new symbol is added.

Add option to not save library document file when saving library.  This is
primarily used by the cache library write code.

Move symbol library write code out of LIB_PART and into SCH_LEGACY_PLUGIN.

Add exception handling where LIB_PART caught the exception and returned
an error status.

Remove KICAD_SCH_IO_MANAGER build option as it is no longer optional.
2017-02-10 08:36:57 -05:00
jean-pierre charras 283ba553ba Change wxItemMenu GetLabel (deprecated) to GetItemLabelText
GetLabel can compile or not, depending on the compatibility level used to build wxWidgets.
2017-02-10 08:33:48 +01:00
Maciej Suminski 1bcbbb41cd Fixed double menu entries in context menus 2017-02-10 00:08:53 +01:00
Maciej Suminski 5f90c0e8b8 Capitalized menu labels to follow the UI policy 2017-02-10 00:08:48 +01:00
Maciej Suminski 060e163511 Fixed invoking TOOL_ACTIONs in submenus
Fixes: lp:1663101
* https://bugs.launchpad.net/kicad/+bug/1663101
2017-02-10 00:08:23 +01:00
Maciej Suminski 6dec72b3c6 Added const modifier to strings in pcb_calculator xpm files
When there is no const modifier gcc warns:
warning: ISO C++11 does not allow conversion from string literal to
'char *' [-Wwritable-strings]
2017-02-09 13:17:31 +01:00
Clemens Koller c9b7647fe0 pcb_calculator: make color code tolerance selection top aligned.
Signed-off-by: Clemens Koller <cko@embeon.de>
2017-02-09 13:04:50 +01:00
Clemens Koller 0a950282c8 pcb_calculator: delete obsolete sources of binary bitmaps (.pngs)
The bitmaps/*.xpm files can be edited as regular pictures
(i.e. using GIMP), so, bitmaps/sources/color_code/* don't need to be
kept as well.

Fixes: lp:1005383

Signed-off-by: Clemens Koller <cko@embeon.de>
2017-02-09 13:01:08 +01:00
Clemens Koller 1161a23b7d pcb_calculator: Cleanup color code bitmaps and remove Ohm sign.
Fixes: lp:1005383

Signed-off-by: Clemens Koller <cko@embeon.de>
2017-02-09 12:58:22 +01:00
John Beard bed0ad142d Add zone duplicate onto layer to GAL
This adds it into the PCB_EDITOR_CONTROL tool, alongside the zone merge
tool.
2017-02-09 12:50:48 +01:00
John Beard 7045ed92fb Add CCW rotation to GAL canvas
This makes "rotate" into two separate TOOL_EVENTs, which each have a
"multiplier" parameter.

Also added is a namespace for 'free functions' that use TOOL_EVENT
public interfaces (perhaps with other inputs too) to centralise some
decision-making and calculations.

Fixes: lp:1660731
* https://bugs.launchpad.net/kicad/+bug/1660731
2017-02-09 12:50:47 +01:00
Maciej Suminski a3e16988be Remove shadow of drawn arcs after undoing them (GAL) 2017-02-09 12:19:16 +01:00
Maciej Suminski 7806cb7bca Drag tracks/vias menu entry (GAL) 2017-02-09 12:03:28 +01:00
Maciej Suminski a16586756f Moved EDIT_TOOL::hoverSelection() code to SELECTION_TOOL::CursorSelection() 2017-02-09 12:03:28 +01:00
Maciej Suminski 14b9e5991b Draw ratsnest lines using the color selected in the layer widget (GAL)
Fixes: lp:1657039
* https://bugs.launchpad.net/kicad/+bug/1657039
2017-02-09 12:03:28 +01:00
Maciej Suminski 2a9c6a6283 Minor DRAWING_TOOL refactor
Automatically switch to a drawing layer, if a copper layer was
preselected. No annoying message boxes.
  Do not deactivate the tool on layer switch.
  Replaced setting updatePreview with direct calls to VIEW::update
  Line width is kept in m_lineWidth for all shapes.
2017-02-09 12:03:28 +01:00
Maciej Suminski 6c5e5c27e2 Fixed bounding box computation for EDIT_POINTS class 2017-02-09 12:03:28 +01:00
jean-pierre charras 0dc11936ad Fixes: lp:1662702 (Pad Properties Dialog not responding to OK button when run from ModEdit toolbar)
https://bugs.launchpad.net/kicad/+bug/1662702
2017-02-08 09:27:52 +01:00
John Beard 2710221f5f Do not include arc centre in bounding box
Arc centres don't land in the bounding box when the arc angle is small.
Currently, there are added to the BB, which leads to surprising
selection beheviour of arc segments (the BB can be much larger than
expected).

This commit omits the arc centre from the calculation.

Fixes: lp:1492734
* https://bugs.launchpad.net/kicad/+bug/1492734
2017-02-07 23:33:18 +01:00
Nick Østergaard 1cb171acf0 Rename bitmaps to match the new pad tool naming 2017-02-07 23:08:09 +01:00
Nick Østergaard 45a8c2e27f Rename pad copy actions in the pad tool
Import becomes apply and export becomes copy.

The term "push" to apply settings globally has not been renamed.

Swap the order of the copy and apply in the context menu.
2017-02-07 23:08:09 +01:00
Chris Pavlina 8f5c3c9e4e pcbnew: menu bar UI compliance tweaks 2017-02-07 16:38:41 -05:00
Chris Pavlina 59a4dffdcb modedit: menu bar UI compliance tweaks 2017-02-07 16:38:34 -05:00
Chris Pavlina b7edc464b0 kicad: menu bar UI compliance tweaks 2017-02-07 16:38:27 -05:00
Chris Pavlina 9bb1b33e89 libedit: menu bar UI compliance tweaks 2017-02-07 16:38:23 -05:00
Chris Pavlina 93a90926c2 eeschema: menu bar UI compliance tweaks 2017-02-07 16:38:18 -05:00
Chris Pavlina bca74853d1 Display more information in component selector 2017-02-07 15:01:20 -05:00
John Beard cdc392867a When 'Find-moving' modules in GAL, pick up at origin
Perviously, the generic snapping code would choose the nearest of the
module origin and origin of each module pad when selecting a module
using the "Find module" tool (T hotkey).

This is unlikely to be expected unless the cursor is already near the
correct pad or the module centre.

New behaviour is to pick up by module origin first, then
select the module. This means that the cursor is already nearest the
main module origin anchor, so that is what will be used.

Fixes: lp:1571214
* https://bugs.launchpad.net/kicad/+bug/1571214
2017-02-07 11:19:38 -05:00
Oliver a5dcc192dc Fix for bug where rotating / editing a selected item would remove it from screen
- Added test to see if there was a currently-editing item

Fixes: lp:1661866

https://bugs.launchpad.net/kicad/+bug/1661866
2017-02-07 09:12:38 -05:00
Wayne Stambaugh f96628f5c2 Fix minor layout issues in footprint editor footprint properties dialog. 2017-02-07 08:43:25 -05:00
John Beard 4ffabcc836 Show lines of zero thickness in GAL
If a line has zero thickness, use the outline thickness to draw it.

This avoids having invisible items on the PCB that could still end up in
outputs, or "losing" an item by setting thickness to 0.

This only affects GAL drawing routines, the PCB data structures are not
affected, so any outputs will be the same.

Fixes: lp:1501749
* https://bugs.launchpad.net/kicad/+bug/1501749
2017-02-07 08:33:16 -05:00
Chris Pavlina ec952c9cde Design rule editor: minor UI improvements
- Move Select All buttons, after discussion in IRC found that numerous
users are unclear on exactly what those buttons would do. The <<< in
them was an attempt to associate them with a listbox, but in reality
created an association in the user's mind with the above "move" actions.

- Spacing, punctuation adjustments
2017-02-07 08:08:41 -05:00
jean-pierre charras 9074c57a28 panel_prev_model.cpp: try a better way to fix issue with wxSpinButtons on Linux. 2017-02-07 11:05:08 +01:00
jean-pierre charras fec02f6161 panel_prev_model.cpp: Fix a minor issue on Linux with wxSpinButtons.
The min and max values must be set, and the curr value forced to 0, to avoid disabling up or down arrows.
2017-02-07 10:26:03 +01:00
jean-pierre charras 42c9e4d602 panel_prev_model.*: fix minor issues. 2017-02-07 09:06:43 +01:00
jean-pierre charras cca0ffed60 panel_prev_3d: Add spin buttons and inc/dec by mouse wheel for 3D parameters 2017-02-07 09:06:43 +01:00
jean-pierre charras 43cb4560bf Rewrite code for PANEL_PREV_3D because the way events were previously managed are not compatible with a good mouse event management.
To avoid a lot of tedious code, wxFormbuilder is used to create the PANEL_PREV_3D_BASE class.
2017-02-07 09:06:42 +01:00
Maciej Suminski 6561c8e61a Fixed a crash occuring on closing pad properties dialog in Windows
Fixes: lp:1660276
* https://bugs.launchpad.net/kicad/+bug/1660276
2017-02-07 00:07:43 +01:00
Jean-Samuel Reynaud 13395d34dd Action plugins: handle undo/redo feature when running an action plugin. 2017-02-06 08:39:32 +01:00
Chris Pavlina 431abcff0c libedit: no units in the new Delete Part dialog 2017-02-05 09:08:07 -05:00
Oliver 4cd7514c8e libedit: Improved selection process for DeleteComponent
- Reused SelectComponent dialog
- Reduced selection to current library only
- Ability to filter component for deletion
- Automatically pre-select the current component
2017-02-05 08:50:22 -05:00
jean-pierre charras 9a6e5734bf Minor fixes: fix UI capitalization issues, and better comment in a menu. 2017-02-04 10:21:41 +01:00
jean-pierre charras 1338ff02f9 Fix a build issue, broken by commit 78a5f450ce 2017-02-04 10:08:54 +01:00
Maciej Suminski 8dadc18429 Check if selection is not empty before modifying it in EDIT_TOOL
Fixes: lp:1661311
* https://bugs.launchpad.net/kicad/+bug/1661311
2017-02-02 23:32:11 +01:00
Dick Hollenbeck 340da50315 Update tools/property_tree support so it builds again. 2017-02-02 12:58:03 -05:00
jean-pierre charras 7dddb1d1c1 When editing a label property it always goes to right orientation by itself
Fixes: lp:1661264
https://bugs.launchpad.net/kicad/+bug/1661264
2017-02-02 16:50:49 +01:00
Chris Pavlina 1ab1d8e7e6 Revert "libedit: Improved selection process for DeleteComponent"
This reverts commit 4ba0fef8c1.

This was accidentally merged before review due to clumsiness, and has a
bug.
2017-02-02 06:28:56 -05:00
Oliver 4ba0fef8c1 libedit: Improved selection process for DeleteComponent
- Reused SelectComponent dialog
- Reduced selection to current library only
- Ability to filter component for deletion
2017-02-02 06:14:32 -05:00
Oliver 702795f4a9 Added progress dialogs for library loading
- Modal wxProgressDialog when loading symbol libraries (eeschema / libedit)
2017-02-02 06:14:32 -05:00
Cirilo Bernardo 227ef64212 Fix coding style of 'sexpr' code in kicad2step 2017-02-02 08:58:35 +01:00
Cirilo Bernardo 4a1e2644a4 kicad2step was not accepting module names which are valid numbers.
Fixes: lp:1660841

https://bugs.launchpad.net/kicad/+bug/1660841
2017-02-01 20:14:57 -05:00
Cirilo Bernardo d29f39dce4 Fix line number tracking in sexpr parser 2017-02-01 19:43:44 -05:00
Cirilo Bernardo cf1003955d Added more info to kicad2step parsing failures 2017-02-01 19:43:44 -05:00
Morgan Quigley 1b9c8676df Fix bug in STEP import with curve intersections.
Set BRL precision to 10 nanometers to prevent floating point round errors
from creating arcs that leave gaps in the board outlines.  Note: it may
be prudent to make this setting 100 nanometers if there are gerber export
issues.

Fixes lp:1652406

https://bugs.launchpad.net/kicad/+bug/1652406
2017-02-01 19:32:27 -05:00
Simon Richter 78a5f450ce Copy and adapt FindCairo.cmake for Pixman 2017-02-01 19:22:47 -05:00
Simon Richter 632cce7aa7 Reduce minimum required Pixman version
The newest version is 0.34. 1.0 doesn't exist, this only worked because
there is no actual version test.
2017-02-01 19:22:36 -05:00
Wayne Stambaugh 9319ef034d Fix rotate bug in symbol library editor.
The rotate hotkey was rotating individual items when a block was selected
which is invalid behavior.  Add check for block mode and disable rotating
items when block mode is active.

Fixes: lp:1660875

https://bugs.launchpad.net/kicad/+bug/1660875
2017-02-01 13:07:20 -05:00
Maciej Suminski 77af6547c1 Coverity fixes (mostly initializing variables) 2017-02-01 17:31:55 +01:00
Forrest Voight bce04c930d 3d-viewer: draw dimension graphics
Fixes: lp:1406754
* https://bugs.launchpad.net/kicad/+bug/1406754
2017-02-01 09:45:32 -05:00
jean-pierre charras 4d3054599b Fix a warning in Debug build on Linux, when there is no wizard loaded. 2017-02-01 13:02:08 +01:00
John Beard fb6de689b9 Factor an EDIT_TOOL selection routine
Also add some commentary to other EDIT_TOOL selection functions.
2017-02-01 09:57:58 +01:00
John Beard 45b60b1bb0 Add exchange modules GAL tool (in EDIT_TOOL)
Includes tool action and the transistion binding in EDIT_TOOL.

Fixes: lp:1541460
* https://bugs.launchpad.net/kicad/+bug/1541460
2017-02-01 09:57:36 +01:00
John Beard 32ddd72038 Move DIALOG_EXCHANGE_MODULE to dialogs dir
DIALOG_EXCHANGE_MODULE class now has its own header file in the
pcbnew/dialogs directory, and the xchgmod.cpp files was moved along with
it. This has two aims:

* (minor) Standardise the location of "base dialog" derived classes,
  like most other dialogs in KiCad.
* (major) Allow inclusion of this dialog class into both legacy-mode
  pcbframe.cpp and into GAL tools.
2017-02-01 09:19:48 +01:00
Chris Pavlina e03fef3266 Reorder eeschema toolbar slightly
- Put the output generation steps (annotation through pcbnew) in the
  correct order as expected by the user running through them.

- Add a Plot button to match pcbnew
2017-01-31 16:06:27 -05:00
Diogo Condeco 8033c6fa9a Eeschema one field dialog text selection.
This patch selects the text in the dialog_one_field.
For annotated symbols the number is selected. For unannotated symbols the ? is selected.
All other cases the entire text is selected, including references in library editor.
2017-01-31 16:01:08 -05:00
Chris Pavlina 49f881375b libedit: add hotkey for Load Component 2017-01-31 16:01:08 -05:00
Chris Pavlina 1d83e23927 libedit: preselect active component when switching 2017-01-31 16:01:08 -05:00
Wayne Stambaugh 0f7785760f Add missing MSYS2 package on windows to developer's compiling document. 2017-01-31 15:25:30 -05:00
jean-pierre charras 66ed8f00ca Update a really outdated python script example, and remove a too old example. 2017-01-31 18:39:30 +01:00
Jean-Samuel Reynaud 75b08e49cf Add 2 python action plugins in demos 2017-01-31 18:38:03 +01:00
jean-pierre charras b66cb871e6 Fix a serious error in SetActiveLayer(): a GAL specific method was called even if a GAL mode was not active 2017-01-31 09:33:44 +01:00
jean-pierre charras 6ae65b4cba Dialog about: remove dead url link 2017-01-31 08:56:31 +01:00
Maciej Suminski 9627f063ff Added missing handler for 'activate' events in EDIT_TOOL
Fixes: lp:1660306
* https://bugs.launchpad.net/kicad/+bug/1660306
2017-01-30 14:05:44 +01:00
Maciej Suminski f0e0254e27 Added missing tool initialization 2017-01-30 13:21:43 +01:00
Maciej Suminski 4b9243e0bf Allow registering TOOLs in any order. 2017-01-30 13:21:43 +01:00
Diogo Condeco 75ffcbcef5 MACOS Setfocus and CancelButtonIssue moved into dialog_shim.
Setfocus now works on macos dialogs by setting DLGSHIM_USE_SETFOCUS.
This option is only enabled __WXMAC__ is defined.

FixOSXCancelButtonIssue() is now called inside DIALOG_SHIM::SHOW.
All other calls from within the dialogs were removed.
2017-01-29 23:51:35 +01:00
John Beard 019b949646 Pre-select highlighted net in zone create dialog
Applies in GAL mode (legacy mode already did this).

Fixes: lp:1482866
* https://bugs.launchpad.net/kicad/+bug/1482866
2017-01-29 23:46:41 +01:00
John Beard bbf8a0fa06 Tidy consts in class BOARD
Add some consts to "getters" in this class.

Remove const from return type of static return-by-value getter - this
has no effect on the caller except disabling move operations and forcing
copy operations.
2017-01-29 23:46:41 +01:00
jean-pierre charras 00641ab056 Pestore a line removed by mistake. 2017-01-29 13:04:47 +01:00
jean-pierre charras 4d28303e04 Fix a coding style issue. 2017-01-29 12:58:04 +01:00
jean-pierre charras 7bda89cdf6 Rework on plugins reload code: avoid duplicate code. 2017-01-29 12:25:19 +01:00
jean-pierre charras 6c5808fd18 Update dale of last change. Add a small comment about CTL_OMIT_HIDE. 2017-01-29 09:29:49 +01:00
jean-pierre charras 70b39d27ae Fix a compil issue due to incorrect conversion. 2017-01-28 20:33:02 +01:00
jean-pierre charras a7c4c8c7f2 Pcbnew: Fix a crash when reloading python scripts, when Kicad uses wxPython.
also, refresh the board editor action plugins menu, when reloading python scripts from the footprint wizard selector.
2017-01-28 18:47:11 +01:00
Dick Hollenbeck 35fc1f3361 Move "hide" back to prior fp_text location 2017-01-28 09:33:25 -05:00
Eldar Khayrullin 59876c35ae Gerbview: fix wrong html tag 2017-01-28 10:34:57 +01:00
Dick Hollenbeck d0c46a81d9 SCH_TEXT::SwapData() was not swapping m_shape, causing abandoned drag to distort pinsheet.
Fixes: lp:1659683
* https://bugs.launchpad.net/kicad/+bug/1659683
2017-01-27 16:44:24 -05:00
Maciej Suminski 39317eac83 Display clearance for routed tracks (GAL) 2017-01-27 19:11:12 +01:00
Maciej Suminski 487dfeeb01 Display clearance for pads, tracks & vias (GAL)
Fixes: lp:1333100
* https://bugs.launchpad.net/kicad/+bug/1333100
2017-01-27 19:10:40 +01:00
Maciej Suminski fc122834c2 Code formatting 2017-01-27 19:08:32 +01:00
Maciej Suminski 80956ef1e6 Added GAL::DrawPolygon(SHAPE_POLY_SET) & GAL::DrawPolyLine(SHAPE_LINE_CHAIN) 2017-01-27 19:08:32 +01:00
Maciej Suminski 1eb7e7161e Rename DisplayZonesMode enum to DISPLAY_ZONE_MODE 2017-01-27 19:08:32 +01:00
Maciej Suminski 24d63fb5d9 Removed redundant calls to wxUpdateUIEvent handlers
This is done automatically by wxWidgets
and does not need to be called explicitly.
2017-01-27 15:39:51 +01:00
Maciej Suminski 750eed7ff5 Renamed MODULE_TOOLS to MODULE_EDITOR_TOOLS 2017-01-27 15:39:41 +01:00
Chris Pavlina 498e8b122a Clean up file format error message a bit more
If a FUTURE_FORMAT_ERROR wraps another FUTURE_FORMAT_ERROR, only print
the error for it once.
2017-01-27 07:27:53 -05:00
Chris Pavlina 3ffc17c27b Fix PCB format version after 0c459ce moved 'hide'
Fixes: lp:1659736
* https://bugs.launchpad.net/kicad/+bug/1659736
2017-01-27 07:27:33 -05:00
Chris Pavlina 0881bf77bd Add commit message format doc with Fixes: links 2017-01-26 16:03:54 -05:00
Dan Weatherill 5fe5c77234 Remove Ohm sign from color code bitmap
Color code is not specific to resistors.

Fixes: lp:1005383
https://bugs.launchpad.net/kicad/+bug/1005383
2017-01-26 15:41:49 -05:00
jean-pierre charras c761d30ade Make FootprintWizardBase.py compatible with last changes in EDA_TEXT. 2017-01-26 20:19:20 +01:00
jean-pierre charras 2f0ab8b13d Gerbview: Load zip archive: skip files which are not gerber or drill files. Better look of messages. 2017-01-26 18:15:46 +01:00
Dick Hollenbeck d4acfb9f5a Remove doubled fp_text "hide" output, change *.kicad_pcb format under authorization of Wayne. Fix exceptions.cpp PARSE_PROBLEM which was missing the offset %d. 2017-01-26 08:02:35 -05:00
Mario Luzeiro 840bcb5189 3D-Viewer: improvements on reflections and on plastic normal texture
+ make the number of samples for reflection and refraction
parameterizable.
+ add some fuziness to reflection.
+ improvements on plastic normal texture
2017-01-26 07:22:46 -05:00
jean-pierre charras aac13e7ae1 More detailed error messages when loading Gerber or drill files and if no room to load some files. 2017-01-26 13:16:49 +01:00
jean-pierre charras 361c0c2e21 Gerbview: better management of zip archive. Better error messages. 2017-01-26 11:36:01 +01:00
jean-pierre charras 6329ca5065 Gerbview: add in file menu an option to load a zip archive containing Gerber and/or drill files. 2017-01-26 10:45:28 +01:00
Maciej Suminski 8f82f04153 Copy menu title in CONTEXT_MENU::copyFrom() 2017-01-25 20:29:27 +01:00
John Beard 0f5bfdb156 Add mirror tool action for GAL module editor
This is basically a simple clone of the legacy tool with a few minor
tidy-ups for GAL mode.

Fixes: lp:1619301
* https://bugs.launchpad.net/kicad/+bug/1619301
2017-01-25 20:17:28 +01:00
John Beard beed72ffbb Add pad import/export/push to GAL canvas
This implements the pad import/export to the board's master pad setting
in the GAL canvases.

Implemented as a new GAL tool: PAD_TOOL.

It uses the same dialog, which has been split out into its own files in
pcbnew/dialogs, rather than along with frame methods in
pcbnew/globaleditpad.cpp.

Fixes: lp:1619304
* https://bugs.launchpad.net/kicad/+bug/1619304
2017-01-25 20:17:28 +01:00
Wayne Stambaugh 8e7fe9dab2 Fix spice simulator build error due to EDA_TEXT changes. 2017-01-25 09:25:05 -05:00
Dick Hollenbeck 0c459ced97 EDA_TEXT object refactor.
Make all EDA_TEXT data private and rename accessors to avoid function
name collisions in derived classes.

Overload EDA_TEXT's SetTextAngle() and SetEffects() in TEXTE_PCB.

Add support for preserving Reference text position, size, orientation
during a netlist import into a BOARD, as well as the one off footprint
update dialog.
2017-01-25 08:03:32 -05:00
Maciej Suminski 5d9190038f TOOL_EVENTs of "message" type are passed to all tools
Message type is a kind of notification, so it should be received by all
interested tools. It used to be like that in the past, but has been
broken recently.
2017-01-25 11:31:55 +01:00
Wayne Stambaugh 0b6147ed05 Minor developer's documentation fixes.
Fix duplicate table of content links.

Fix heading level issues in version 6 road map.

Add new Python action menu options to compiling document.
2017-01-24 10:14:27 -05:00
diogocondeco 1a05c8a5a8 eeschema/add_component setfocus moved into OnInitDialog
SetFocus executed by OnInitDialog wxInitDialogEvent handler
2017-01-23 12:31:00 -05:00
diogocondeco b54e77e466 Macos SetFocus() and SetSelection moved into OnInitDialog
pcbnew/dialog_find and pcbnew/dialog_pad_properties modified so that SetFocus and SetSelection is handled once the dialog is initiated.
2017-01-23 12:30:59 -05:00
Chris Pavlina fb104a111f gitignore: add .DS_Store 2017-01-23 09:08:22 -05:00
Maciej Suminski 1102eb0d0d Store menu titles in CONTEXT_MENU
Previously a title had to be provided when a submenu was added,
but this led to storing the same title in many places.
2017-01-23 14:52:11 +01:00
Maciej Suminski 6362e5cf0f Added create() method for SELECTION_MENU 2017-01-23 14:52:11 +01:00
jean-pierre charras 2b5769c0a8 Action plugins: simplify code, and fix an issue: the menubar was not correctly rebuilt after closing and reopening pcbnew from kicad.
It was also not correctly rebuilt after language change.
2017-01-23 13:27:49 +01:00
Jean-Samuel Reynaud 5ef3e5a15d Pcbnew: Add ACTION_PLUGINS class. It allows loading python scripts in footprint editor and run them from the Tools/External Plugins menu
This plugin mechanism is enabled only if option -DKICAD_SCRIPTING_ACTION_MENU=ON (it is off by default)
It imply -DKICAD_SCRIPTING=0N
This is currently for testing purposes only for developers, not yet for users.
2017-01-23 13:27:49 +01:00
jean-pierre charras df0d102b9c Remove unused icons. cleanup a svg file (no actual change in icon). 2017-01-23 13:27:03 +01:00
John Beard 89fe9d378c Add C++14-style std::make_unique 'polyfill' for C++11
std::make_unique is a very useful part of the new C++ smart pointers
ecosystem, as it allows one to dispense entirely with "new" and also
provides exception safety in some cases when creating temporary
variables.

It also allows more concise code by avoiding repetition of the type:

    std::make_unique<TYPE>( args );

vs

    std::unique_ptr<TYPE>( new TYPE( args ) );

This commit adds a "polyfill" to provide std::make_unique when C++11 is
enabled. The implementation is that submitted to the C++ committee, and
is essentially how it is done in GCC for C++14.

The intention is to allow KiCad to use this implementation when using
C++11 and when C++14 or greater is a requirement, to remove this code
and use the compiler implementation.
2017-01-23 11:41:00 +01:00
John Beard 7863e70181 Move PostCommandMenuEvent to EDA_BASE_FRAME
There is nothing PCB-frame-specific about this function,
it is equally applicable to an frame, for example
PCB_EDIT_FRAME and CVPCB_MAINFRAME, which have EDA_BASE_FRAME
as the nearest common ancestor, except KIWAY_PLAYER,
which is not really concerned with this kind of UI event method.
2017-01-23 11:41:00 +01:00
Maciej Suminski 59346a6ef1 Alternative way for setting icons for align/distribute actions. 2017-01-23 11:41:00 +01:00
Maciej Suminski f0a7c1715e Fixed warning 'cast pointer from integer of a different size' 2017-01-23 11:40:59 +01:00
Maciej Suminski fc7be1a497 Removed redundant CONTEXT_MENU::m_parent field. 2017-01-23 11:40:59 +01:00
Maciej Suminski 682da70a86 Fixed the issue of creating and event handling in context menus (GAL).
When creating a copy of CONTEXT_MENU, always a CONTEXT_MENU instance was
constructed, whereas an inherited type should be used. Solved with
CONTEXT_MENU::create() that has to be overridden in inheriting classes.

Event & update handlers are now virtual functions, instead of setting
the handlers with Set{Event,Update}Handler().
2017-01-23 11:40:59 +01:00
jean-pierre charras d7ed3ede72 Ensure paths and filenames are always stored with '/' as separator in fp_lib_table, like in other kicad files.
Ensure also paths and filenames read from a fp_lib_table always use '/' as separator (works fine on Windows)
Fixes: lp:1658534
https://bugs.launchpad.net/kicad/+bug/1658534
2017-01-23 11:32:58 +01:00
John Beard 6a1b068dd2 Allow editing locked modules in modedit
Since you have to explicitly enter the module editor with the menu or
hotkey, allowing editing of module sub-parts once in should not cause
any unexpected changes.

Fixes: lp:1591625
* https://bugs.launchpad.net/kicad/+bug/1591625
2017-01-22 20:31:59 -05:00
John Beard 5cc2abaa2b Tidy consts for class D_PAD
Some accessors should be const:

* IsFlipped
* GetRoundRectRadiusRatio

Returning a objects by value as const in these cases is not helpful, as
all it does is prevent the caller moving from the return value, it just
forces a copy.

Some of thse functions come from base class overrides, those haven't
been changed.

* ShapePos
* GetPadName
* GetPackedPadName
2017-01-22 10:42:45 -05:00
Baranovskiy Konstantin 4be2c79b87 Make doc extension (pdf) case insensitive. 2017-01-22 10:40:37 -05:00
Mario Luzeiro 33449216b5 3D-Viewer: Improvements on reflection and refraction
- crete an option for absorvance (works better to make the epoxy
different for regular transparent materials).
- visual fix an issue related with the epoxy render (square bands on the
render).
- fix a reflection issue (it was not take in account the reflection
material color).
2017-01-21 09:21:44 -05:00
Robbert Lagerweij 550a1ea4d6 eeschema: set title of plotted pdf to sheet title
Fixes: lp:1656956
https://bugs.launchpad.net/kicad/+bug/1656956
2017-01-20 17:11:12 -05:00
jean-pierre charras 2de913797a Fix a UI policy issue. Very minor cosmetic change: give same look to Zoom and Grid selection in 2 menus. 2017-01-20 11:35:24 +01:00
jean-pierre charras 92632a7a13 pcb_calculator/transline/microstrip.cpp: remove useless local var, shadowing a member var. 2017-01-20 11:33:01 +01:00
jean-pierre charras adb679dc46 ROUTER_TOOL_MENU: add zoom selection to this menu. 2017-01-20 08:51:12 +01:00
jean-pierre charras d51d53c6b9 CONTEXT_TRACK_WIDTH_MENU EventHandler: better filtering of received events ID.
This is mandatory because currently, on Windows, this handler is also called when clicking on an other menu with submenus like the grid menu.
2017-01-20 08:29:24 +01:00
jean-pierre charras e710b8b370 Fix incorrect parameter type when appending zoom and grid menuitems 2017-01-19 20:26:57 +01:00
Tomasz Włostowski ba9576b014 router: snap to clearance boundaries in Highlight Collisions mode
Fixes: lp:1655819
* https://bugs.launchpad.net/kicad/+bug/1655819
2017-01-19 17:47:15 +01:00
Mario Luzeiro 2eb840b2ed 3D-Viewer: Fix precision issues (experienced on isometric mode) in frustum tests 2017-01-18 18:09:27 -05:00
Maciej Suminski e5fbd0c442 Fixed crash upon finished zone drawing in GAL.
In principle, this patch reverts 2eefa117. The difference is removal of
one unused method (SELECTION::clear) and fixing hidden overloaded
virtual methods warnings.

Fixes: lp:1657569
* https://bugs.launchpad.net/kicad/+bug/1657569
2017-01-18 22:06:23 +01:00
Simon Richter fbace8e513 Fixed two hidden overloaded function warnings.
Correct way of writing commit c4db8bf4.
2017-01-18 17:24:50 +01:00
Maciej Suminski c4db8bf45f Revert "Removed Pin{Shape,Type}ComboBox::SetSelection()."
Enforcing the appropriate type is a good thing, though it results in
build warnings. For the moment we stay with the latter.

This reverts commit 6dd47119fe.
2017-01-18 16:58:20 +01:00
John Beard 5a2be26934 Tool Framework documentation 2017-01-18 16:30:33 +01:00
Tomasz Włostowski bb463ad434 pns: fix assertion fail when placing diff pairs 2017-01-18 15:55:46 +01:00
Maciej Suminski 838c6097d9 Removed a redundant assert in OPENGL_COMPOSITOR. 2017-01-18 14:30:08 +01:00
Maciej Suminski 196c5aca83 Fixed 'unreferenced local variable' warning in OPENGL_GAL. 2017-01-18 14:23:06 +01:00
Maciej Suminski 6dd47119fe Removed Pin{Shape,Type}ComboBox::SetSelection().
These methods were hiding an overloaded method, which was called anyway.
2017-01-18 14:20:39 +01:00
Maciej Suminski 75fb04d650 TOOL_ACTIONs are handled with transitions, no handlers needed in the event loops
There used to be a number of TOOL_ACTIONs that had entries both in
SetTransitions() and the event loop, which seemed redundant and
troublesome.
Now it is not necessary anymore, transitions setup is enough to execute
associated actions.
2017-01-18 14:20:39 +01:00
Maciej Suminski 2eefa11732 SELECTION has-a VIEW_GROUP instead of being-a VIEW_GROUP
Fixed numerous warnings caused by hidden overloaded methods
provided in both classes (Add(), Remove(), etc.)
2017-01-18 13:22:41 +01:00
Maciej Suminski 3c61b16e7b Code formatting 2017-01-18 13:22:40 +01:00
Maciej Suminski c758f434c0 Removed unused fields in VIEW & ANTIALIASING_SMAA classes 2017-01-18 13:22:18 +01:00
Maciej Suminski ee862e1db4 Fixed a hidden overloaded virtual function warning in PNS 2017-01-18 13:22:18 +01:00
Maciej Suminski ee2b1ac321 Shortened code using VIEW & PAINTER classes in MODULE_TOOLS methods 2017-01-18 13:22:18 +01:00
Baranovskiy Konstantin 3dc2050498 Improved MousewheelPAN mode. 2017-01-17 16:34:11 -05:00
jean-pierre charras f079b7f98b gendrill_Excellon_writer.*: make 3 helper methods private. Coding style fixes. 2017-01-17 20:37:14 +01:00
Wayne Stambaugh 56fbfeeb4a Do not use default board solder mask clearance in footprint editor.
The footprint editor was displaying the default solder mask clearance
defined by the temporary BOARD object created a start up.  Change the
temporary BOARD default solder mask to 0 so the pad or footprint solder
mask clearance setting is displayed when editing the footprint.

fixes lp:1653980

https://bugs.launchpad.net/kicad/+bug/1653980
2017-01-17 09:05:57 -05:00
jean-pierre charras fef40c96e2 Workaround for this issue: Pcbnew crashes on exit in OpenGL display mode when a footprint on the board was edited in the fp editor
Fixes: lp:1655858
https://bugs.launchpad.net/kicad/+bug/1655858
2017-01-17 13:17:14 +01:00
John Beard aea9163aa5 .gitignore: add demo files' autosaves and backups 2017-01-16 17:22:21 +01:00
Maciej Suminski 004ca3c6f9 Fixed a memory leak in VIEW_ITEM (proper way of doing 9bc2bb2)
The problem with simple deleting VIEW_ITEM_DATA upon VIEW_ITEM removal was
caused by the default copy constructors that copied pointers.
Once a copy of an item was destroyed, the VIEW_ITEM_DATA has been
destroyed, effectively invalidating m_viewPrivData for the other item.
2017-01-16 14:57:50 +01:00
Chris Pavlina 8ac4790370 Remove icons from canvas selection menu in modedit
No OS renders the combination of icon AND radio button properly.
2017-01-15 07:12:02 -05:00
Chris Pavlina d442009e84 Use radio buttons in canvas selection menu items 2017-01-15 07:05:24 -05:00
jean-pierre charras 053dac45c1 complex_hierarchy: minor changes in texts (add info in page frame) 2017-01-15 08:32:43 +01:00
jean-pierre charras 9c49dea741 Update complex hierarchy demo to use current kicad libraries. 2017-01-14 18:27:04 +01:00
Nick Østergaard c676553f19 Fix OCE link in dev-docs
* Remove duplicate ngspice link
* Add OCE link
2017-01-14 12:24:40 -05:00
Simon Wells 19512b46a3 Fix unlimited zoom with "Use touchpad to pan"
Additionally, fix an unreported bug allowing zoom level to get stuck at
MAX_ZOOM.

Fixes: lp:1625754 (3dviewer zoom not limited with Use touchpad to pan)
https://bugs.launchpad.net/kicad/+bug/1625754
2017-01-14 09:17:56 -05:00
jean-pierre charras d0db2de015 Cosmetic enhancement in pcbnew menubar: use specific icon in menuitems to switch canvases, and add a marker to the mode currently in use 2017-01-14 14:43:45 +01:00
Chris Pavlina 99bfa2fea2 Revert "Fixed a VIEW_ITEM memory leak"
This reverts commit 9bc2bb2651.

Fixes: lp:1656481 (pcbnew segfault in KIGFX::VIEW_ITEM_DATA::getGroup)
https://bugs.launchpad.net/kicad/+bug/1656481
2017-01-13 21:37:31 -05:00
Maciej Suminski bf735b6fe7 Yet another trial to use wxString as a std::runtime_error message 2017-01-13 22:48:26 +01:00
Maciej Suminski 90710cfcc5 Added a missing #include directive 2017-01-13 17:15:32 +01:00
Maciej Suminski 7eacd1b15d Restored cursor in OpenGL canvas (still an issue with subpixel AA) 2017-01-13 17:10:16 +01:00
Maciej Suminski 7cf1cfedb3 Change exception message time from wxString to std::string 2017-01-13 16:59:31 +01:00
Maciej Suminski 88eb648cbb Alternative way of handling OpenGL initialization & errors
Some faults could result in a crash, as they were not properly
handled. Now the rendering loop is wrapped with try..catch block
which will revert to Cairo in case of an error and display an
error message.

Fixes: lp:1655766
* https://bugs.launchpad.net/kicad/+bug/1655766
2017-01-13 16:50:36 +01:00
Maciej Suminski ca085de6aa Initialize fields in COMPOSITOR 2017-01-13 16:46:45 +01:00
Maciej Suminski e0577c0218 checkGlError() may throw exceptions or display an error message 2017-01-13 16:46:02 +01:00
Maciej Suminski 5a7604cbb4 More code formatting 2017-01-13 10:36:59 +01:00
Maciej Suminski 9bc2bb2651 Fixed a VIEW_ITEM memory leak 2017-01-12 15:41:00 +01:00
John Beard c50d28d94d Access tools' TOOL_MENUs rather than CONDITIONAL_MENUs
This means that non-top-level tools, for example EDIT_TOOL and
PCB_EDITOR_CONTROL can submit their own menus to the top-level tool's
TOOL_MENU, which will then retain a reference to it and make it
available for the CONTEXT_MENU that is shown.
2017-01-12 14:34:03 +01:00
John Beard d7db84e282 Break out tools' common menu functions and ownership
Add a class TOOL_MENU, which provides a management class for a
CONDITIONAL_MENU and a set of CONTEXT_MENUs. The aim of this is to
provide a central place where all TOOL_INTERACTIVEs can get a "basic"
context menu that either they or other tools can register new items and
sub-menus against.

This means that "top-level" tools no longer need to manage the lifetimes
of any CONTEXT_MENUs that they add, and can also delegate simple menu
display functions.
2017-01-12 14:33:57 +01:00
Maciej Suminski 3d7a509046 Added autogenerated fp_lib_table_* files to gitignore 2017-01-12 14:02:57 +01:00
Maciej Suminski aabf8300c3 Removed non-ASCII characters 2017-01-12 09:20:04 +01:00
Maciej Suminski 67b0a8c990 Fixed type casting in SHADER class 2017-01-11 17:37:10 +01:00
Maciej Suminski e99b79cb2d Merge branch 'anti-aliasing' 2017-01-11 16:20:47 +01:00
Maciej Suminski da00d64877 OpenGL antialising code clean up & formatting 2017-01-11 16:20:37 +01:00
decimad 32a125a767 improve class observable 2017-01-11 16:20:37 +01:00
decimad 5a4e247564 EDA_DRAW_PANEL_GAL now takes the gal display options per dependency injection
Add a hack so that the pad properties base dialog constructor can pass in the dependency. Since the derived dialog's constructor takes the parent by this exact type, the static cast is safe.
2017-01-11 16:20:37 +01:00
decimad e71070fe1b final touch-ups (license information, includes) 2017-01-11 16:20:37 +01:00
decimad 64cd1228ea Clearer error messages for OPENGL_COMPOSITOR::CreateBuffer() (thanks Orson) 2017-01-11 16:20:37 +01:00
decimad 77138e3702 Add UI control to set up gal opengl antialiasing and load/store the settings 2017-01-11 16:20:37 +01:00
decimad d04b3bdc27 Add Antialiasing option to dialog_display_options (Thank you Simon Richter) 2017-01-11 16:20:37 +01:00
decimad bbaeeceeac A model/subscribe helper-class OBSERVABLE to common 2017-01-11 16:20:37 +01:00
decimad 2a8dd508c4 Add smaa (subsample morphological antialiasing) 2017-01-11 16:20:37 +01:00
decimad afacee5d96 Add supersampling (2x/4x) antialiasing 2017-01-11 16:20:37 +01:00
decimad 02bb410cdb Refactor COMPOSITOR/OPENGL_COMPOSITOR to enable customization of scene rendering and presentation 2017-01-11 16:20:35 +01:00
decimad 77f9cd0cb0 remove custom shader header generation build-step in favor of c++11 raw string literals
rework shader loading code to handle an arbitrary amount of to-be-concatenated strings
2017-01-11 16:20:34 +01:00
decimad 047f52e7cb Move builtin font resources out of opengl_gal translation unit 2017-01-11 16:20:33 +01:00
John Beard 378f5cce33 Don't show separator in Select tool if not needed
If the SELECTION_TOOL's Select... menu is not shown, the separator under
it should also not be shown, so use the same SELECTION_CONDITIONS to
enforce this.
2017-01-11 11:15:25 +01:00
John Beard f1c5b9a9ae Add context menu to GAL DRAWING_TOOL, including the zone menu
Includes a tiny class for scoped set-reset of a variable, which is used
here to store the current drawing mode.

Fixes: lp:1218629
 * https://bugs.launchpad.net/kicad/+bug/1518629
2017-01-11 10:41:08 +01:00
John Beard 6baf0edc08 Line segments obey 45 degree preference in GAL
The GAL line segment tool now listens to the global line segment 45
degree locking preference, with Ctrl used to invert the behaviour. The
behaviour therefore follows the setting normally, and the user can
override when needed with Ctrl.

Fixes: lp:1635718
* https://bugs.launchpad.net/kicad/+bug/1635718
2017-01-11 09:57:55 +01:00
jean-pierre charras 853310da6e Remove duplicate definition of LAYER_PAIR, defined both in gendrill_Excellon_writer.h and specctra.h
Now, in gendrill_Excellon_writer.h it is DRILL_LAYER_PAIR, and in specctra.h it is SPECCTRA_ LAYER_PAIR
2017-01-10 20:12:50 +01:00
John Beard 3448698849 Add grid menu to routing context menu
This is a missing GAL feature (though grid cycling by hotkey was already
working fine).

Fixes: lp:1519973
* https://bugs.launchpad.net/kicad/+bug/1519973
2017-01-10 11:18:25 +01:00
Frank Villaro-Dixon c2fb3368f3 Change default symbol pin length to match KiCad Library Convention (KLC). 2017-01-09 16:27:26 -05:00
jean-pierre charras 4f46f79cf0 dialog_footprint_wizard_list.cpp: allows updating (on request) python modules from this dialog.
This option reloads modules which are more recent than already loaded modules, and load new modules.
2017-01-09 14:44:24 +01:00
jean-pierre charras 9684031bc8 Fix I18n issue in dialog_design_rules.cpp 2017-01-09 14:19:02 +01:00
jean-pierre charras 1039b6dda7 Make dialog_footprint_wizard_list.cpp compilable when scripting is not enabled. 2017-01-08 08:25:04 +01:00
jean-pierre charras e72a3b99ee dialog_footprint_wizard_list: cosmetic enhancements. 2017-01-07 21:10:38 +01:00
jean-pierre charras e6a8294c56 dialog_footprint_wizard_list: add button to show the trace of errors when python scripts wizards failed to load. 2017-01-07 20:43:39 +01:00
jean-pierre charras 44cc728b25 enforce a control to avoid crash if pcbnew.py is an incorrect version (bad install). 2017-01-07 16:25:11 +01:00
jean-pierre charras 76a82dcd3b Dialog footprint wizard selector: better dialog (displays the wizard search path list) and allows double click to select a wizard 2017-01-07 13:39:47 +01:00
jean-pierre charras 56f8e10eb4 Footprint wizards management: Now display the list of not loadable footprint wizards in footprint wizard dialog.
Not loadable wizards are Python scripts having a syntax error or are not compatible scripts due to changes in API.
2017-01-06 20:15:23 +01:00
Simon Wells 5fee9b2405 Performance counter: use correct std::chrono clock 2017-01-06 09:54:38 -05:00
Chris Pavlina f407450732 Remove code referring to deleted variable 2017-01-05 20:11:37 -05:00
Diego Herranz 50cdd5cdf1 Pcbnew, plot dialog: grey out advanced net attributes if Gerber X2 is unchecked.
m_useGerberNetAttributes is useless if m_useGerberX2Attributes is not checked.
So disabled (greyed out) when Gerber X2 gets unchecked to make it clear to
the user.
2017-01-04 17:13:26 -05:00
Wayne Stambaugh 50a388fe56 Page setting menu entry consistency fixes.
Move the page setting menu entry from the edit menu to the file menu in
Eeschema so it is consistent with Pcbnew.

Change the page setting menu entry tooltip in Pcbnew so it is the same as
Eeschema.
2017-01-04 15:24:45 -05:00
jean-pierre charras 24192ff3d6 Add Micromatch connectors footprint wizard. Unfortunately, I don't remember the initial author of this script. 2017-01-04 20:01:15 +01:00
jean-pierre charras 995940e992 refinement 2017-01-04 16:17:40 +01:00
jean-pierre charras 02fa9639cd DIALOG_FOOTPRINT_WIZARD_LIST: minor enhancement. qrcode_footprint_wizard.py: use filled polygons instead of square pads on silkscren layer. 2017-01-04 15:03:43 +01:00
jean-pierre charras 8e11d9b628 very minor change. 2017-01-04 09:42:32 +01:00
jean-pierre charras 1a464ab8c8 Coding style fixes 2017-01-03 18:04:35 +01:00
Oliver Walters 66ee44cb1f Footprint Wizards Update 2017-01-03 16:01:47 +01:00
Oliver d1278a48b6 UI Improvements for PCB Design Rules Dialog
* Added floating point validators for wxTextCtrl items relating to via and track sizes
* Prevent entering negative values
* Changed via option wxRadioButton pairs to wxCheckBox
* Toggling the OptAllowMicroVias checkbox toggles the enabled status of the microvia settings controls
* Cleanup of error message(s)
2017-01-02 12:50:13 -05:00
jean-pierre charras d56a49d218 Performance counter rework: More comments, code cleaning, and move GetRunningMicroSecs() prototype from common.h to profile.h.
profile.h should now contain all info for profiling.
2017-01-02 13:49:36 +01:00
jean-pierre charras fff449ecf0 Performance counter rework: Add comments, fix coding style issues. 2016-12-31 13:00:24 +01:00
Simon Richter ac9f858813 Performance counter rework 2016-12-31 12:57:42 +01:00
jean-pierre charras b8b08dafd6 Code cleaning: remove pcbcommon.* which contains nothing really useful. The very few lines of code are moved to a better place. 2016-12-31 12:56:21 +01:00
Tomasz Wlostowski c45cc1de68 Fixes: lp:1653146 (Assertion failed when trying to delete track with router tool active, in debug mode)
https://bugs.launchpad.net/kicad/+bug/1653146
2016-12-30 20:14:44 +01:00
jean-pierre charras 655f54bea5 Fixes: lp:1652353 (pspice netlist export: library include path is always empty)
https://bugs.launchpad.net/kicad/+bug/1652353
2016-12-30 15:32:45 +01:00
jean-pierre charras a9fbedfb12 More Coverity warnings fixes. 2016-12-30 14:36:23 +01:00
jean-pierre charras dec2d6e8cc Fix a few Coverity warnings. A bit of clean code in export_vrml.cpp. 2016-12-30 12:40:05 +01:00
Chris Pavlina aa27e9ff7e IO_ERROR: improve What() message 2016-12-29 13:50:38 -05:00
jean-pierre charras a5178c70db sch legacy plugin: fix a compatibility issue with old schematic files 2016-12-29 19:38:48 +01:00
Chris Pavlina 6078ca85e5 Improve broken edge outline error message 2016-12-29 12:31:12 -05:00
jean-pierre charras a76f40be3b Pcbnew: fix compil issue when Python scripting isn't enabled. 2016-12-29 08:17:33 +01:00
Oliver 636e060c99 A few enhancements from a larger patch, not yet committed, for footprint wizards 2016-12-28 10:26:01 +01:00
jean-pierre charras 352f1a025c Better compatibility with previous Pcbnew versions: save diff pair prms only when values are not set to default values 2016-12-28 10:00:39 +01:00
Mario Luzeiro d365dc590e Soft plastic textures even more 2016-12-22 16:18:38 -05:00
Mario Luzeiro b33e42ef2c Soft plastic textures 2016-12-22 16:18:30 -05:00
Mario Luzeiro ad2458056a Improvements on 3DViewer raytracing render
+ Implement sRGB to Linear and Linear to sRGB conversions.
+ Fix an issue in the AntiAliasing adaptive logic.
+ Improves the ambient color use on the shader.
+ Improves post-shader calculation. Fixes the saturated dark regions.
+ Improves the transparency of soldermak material.
2016-12-22 16:18:20 -05:00
jean-pierre charras 2972f6fbc7 Fix shadowed local variable 2016-12-20 17:51:55 +01:00
jean-pierre charras 9be5398cd2 Add bitmaps to Align/distribute menu ans menu items 2016-12-20 17:50:29 +01:00
Tomasz Włostowski b20323dc63 SELECTION: fixed pointer arithmetic-related segfault in operator[] 2016-12-20 12:01:09 +01:00
jean-pierre charras 3ffa37c8b9 Fixes: lp:1650524 (Trapezoidal pad solder mask is incorrect when the minimal solder mask width is 0)
https://bugs.launchpad.net/kicad/+bug/1650524
2016-12-18 13:03:15 +01:00
Maciej Suminski f631ae27b2 Fixed crash on DRC
Fixes: lp:1650360
* https://bugs.launchpad.net/kicad/+bug/1650360
2016-12-16 12:04:15 +01:00
Chris Pavlina 4c340cefee Also rename footprint attributes in 3D viewer
Follow-up to commit: 809e71a
2016-12-15 14:48:14 -05:00
Chris Pavlina 809e71abac Rename footprint attributes more understandably 2016-12-14 15:53:04 -05:00
jean-pierre charras 188d7812ec Disable Flip board view in Legacy mode (because the view cannot be flipped) 2016-12-13 21:24:29 +01:00
jean-pierre charras 0265a5bac5 Add a specific icon to the Flip board menuitem command 2016-12-13 19:36:17 +01:00
Maciej Suminski 139521750b Fixed a crash on finishing line drawing in the legacy FP editor
Fixes: lp:1649597
* https://bugs.launchpad.net/kicad/+bug/1649597
2016-12-13 17:25:34 +01:00
Maciej Suminski b1e37ae1dc Fixed a few warnings (dialog_track_via_properties.cpp) 2016-12-12 18:01:09 +01:00
Maciej Suminski 72126d3602 Merged Cairo rendering performance boost, flip view, VIEW refactor 2016-12-12 16:49:00 +01:00
Maciej Suminski c8676db84e Fixed panning & cursor control with arrow keys in flipped view 2016-12-12 16:45:52 +01:00
Maciej Suminski 3ea8f12555 Handle flipped view text rendering for Cairo 2016-12-12 16:45:52 +01:00
Maciej Suminski effc8bebb1 Store view flip setting between canvas changes 2016-12-12 16:45:52 +01:00
Maciej Suminski 027515f4e1 Fixed refreshing after flipping the view 2016-12-12 16:45:52 +01:00
Maciej Suminski 7ad5fca6de More code formatting, updated copyright headers 2016-12-12 16:45:52 +01:00
Maciej Suminski 07c7334238 Moved 'Flip View' menu entry
Under Windows wxWidgets there is a problem with the last menu
item having wxITEM_CHECK flag.
2016-12-12 16:45:52 +01:00
Maciej Suminski f94c10b453 Fixed a warning in release builds 2016-12-12 16:45:52 +01:00
Maciej Suminski 8afae179ab convert_to_biu: Changed defines & functions to constexpr 2016-12-12 16:45:52 +01:00
Maciej Suminski a2a950fdae Reduced the Cairo command entry size 2016-12-12 16:45:52 +01:00
Maciej Suminski 660e4ca9d4 Cairo group arguments are stored in a union. 2016-12-12 16:45:52 +01:00
Maciej Suminski 8f924ed125 Added checks to ensure VIEW_ITEM_DATA != nullptr. 2016-12-12 16:45:52 +01:00
Maciej Suminski c96db4f5c4 Removed aCreateUndoEntry flag from COMMIT::Push()
It was not used anywhere and COMMIT should handle creating
undo buffer entries.
2016-12-12 16:45:52 +01:00
Maciej Suminski 89055c4425 Code formatting 2016-12-12 16:45:52 +01:00
Tomasz Włostowski daf103d7e4 GAL: fix grid origin and grid rendering in flipped view mode 2016-12-12 16:45:52 +01:00
Tomasz Włostowski 90a39582b5 added missing FindPixman script 2016-12-12 16:45:52 +01:00
Tomasz Włostowski da28e163d2 Optimizations/fixes to the VIEW/GAL classes:
- much faster Cairo rendering (outperforms legacy)
- improvements in VIEW update handling
- fixed issue with grid rendering in flip view mode
2016-12-12 16:45:52 +01:00
Tomasz Włostowski 3f7c5a0845 fixed post-rebase issues 2016-12-12 16:45:52 +01:00
Tomasz Włostowski c661c30f68 pcbnew: added flip view mode 2016-12-12 16:45:52 +01:00
Tomasz Włostowski 1c1f4e9a50 Refactoring of VIEW/VIEW_ITEM classes:
- Remove dependency of EDA_ITEM on VIEW
- VIEW_ITEM is now a pure virtual interface
2016-12-12 16:45:52 +01:00
Tomasz Włostowski 27a10e8597 Multiple simplifications to GAL tools in PCBNew:
- Finalize transition to BOARD_COMMIT (removed all remaining uses of PICKED_ITEMS_LIST) and implicit view/ratsnest updates
- Simplified SELECTION class, it now can be directly added to a VIEW
- Removed unnecesary casts and templates
- Introduced C++11 features (range based for, lambdas) where they improve code readability
- Added non-undoable COMMITs, which can be used to propagate change notifications to interested listeners (e.g. ratsnest/view)
2016-12-12 16:45:52 +01:00
Tomasz Włostowski 470ccafaeb Added C++ wrapper for prof_counter 2016-12-12 16:45:52 +01:00
Wayne Stambaugh 9c758c4010 Road map updates.
Update version 5 road map to reflect the actual tasks that will be
completed during the current development cycle.

Add version 6 road map and add tasks not completed from the version
5 road map and the general road map.
2016-12-10 13:20:24 -05:00
Wayne Stambaugh 88df496168 Eeschema: implement loading of global symbol table.
Add global symbol library storage and access to SYMBOL_LIB_TABLE object.

Add code to Eeschema to load global symbol table on start up.
2016-12-10 10:23:09 -05:00
Tomasz Wlostowski 5476e97bfa Pcbnew: fix segfault when importing netlist with no footprint assignments.
Fixes lp:1647803

https://bugs.launchpad.net/kicad/+bug/1647803
2016-12-10 10:20:21 -05:00
jean-pierre charras 3d89fb640a Fix an issue in github plugin, when a library is not found (perhaps due to changes in curl 2016-12-07 18:06:26 +01:00
Heikki Pulkkinen f660771ecf Fix redundant via removal code 2016-12-07 17:14:41 +01:00
Maciej Suminski 29ab646e7c Fix 'remove dangling tracks' in board cleanup code
Code removing dangling tracks is called in a loop until
there are no more changes, and relies on removing tracks
instanly. Previously the tracks to be removed were added to
a set and removed in one go, so only one segment for each
dangling connection was removed.
2016-12-07 17:10:43 +01:00
Maciej Suminski e37488f145 Minor code simplification in BOARD_COMMIT 2016-12-07 16:50:23 +01:00
jean-pierre charras 54c5f6bbb0 Simulator frame: fix a min size for panels, and now stores in config the position and size of the frame and panels 2016-12-02 15:34:23 +01:00
Marco Inacio c6cbc9ec95 Fixes: lp:1646224 (Simulation: small tune field)
https://bugs.launchpad.net/kicad/+bug/1646224
2016-12-02 08:58:01 +01:00
jean-pierre charras 6d6542e133 Gerber file generation: in X1 format, in header, use structured comments instead of basic comments.
(a structured comment starts by "G04 #@! " followed by a X2 attribute, and is a comment for old Gerber readers)
2016-11-30 17:48:31 +01:00
jean-pierre charras 9a535d4c70 Fixes: lp:1645430 (CSV BOM generation using bom2csv.xsl script with custom entries has wrong format)
https://bugs.launchpad.net/kicad/+bug/1645430
2016-11-29 13:07:20 +01:00
Maciej Suminski a95df8463d Merge branch 'fix_1553804'
Fixes: lp:1553804
* https://bugs.launchpad.net/kicad/+bug/1553804
2016-11-28 15:51:45 +01:00
Maciej Suminski 524dddaf70 Sync the PNS model when its changed 2016-11-28 15:51:18 +01:00
Maciej Suminski 89a5f8ce69 Remove boost::bind from BOARD_COMMIT 2016-11-28 15:51:18 +01:00
Maciej Suminski bb1390e2f1 Modify TRACKS_CLEANER to use BOARD_COMMIT 2016-11-28 15:51:18 +01:00
Maciej Suminski abb3524563 Code formatting (clean.cpp) 2016-11-28 15:51:18 +01:00
jean-pierre charras 5d7d210f28 Simulator, plot panel: fix incorrect calculation of the vertical size of the traces when resizing the simulator frame 2016-11-28 15:37:00 +01:00
jean-pierre charras c225af747f mathplot: fix a bug and remove unused variables ( it fixes a few compil warnings) from Coverity analysis.
Uncrustify mathplot.h and fix a few coding style issues.
2016-11-28 14:18:22 +01:00
jean-pierre charras 30df041de6 fix shadowed local variables 2016-11-25 18:17:34 +01:00
jean-pierre charras bcfc1e7a3f fix shadowed local variables 2016-11-25 16:00:42 +01:00
Wayne Stambaugh fd54d394bd Version string improvements.
Define empty string variable KICAD_BRANCH_NAME that can be used as an
optional version string element.  When git is used to build the version
string, this variable is set to the git branch name.  It can also be
defined at configuration time as an optional string appended to the
$KICAD_VERSION variable.

Define empty string variable KICAD_VERSION_EXTRA that can be set by
the user at configuration.

The variables KICAD_BRANCH_NAME and KICAD_VERSION_EXTRA are only
appended to KICAD_VERSION if they are set.  Otherwise, only KICAD_VERSION
is uses as the version string.

Update the developer building from source document to reflect the changes.
2016-11-25 09:09:10 -05:00
jean-pierre charras 8806fc03dc Fix PAD_SHAPE_T value in a old python script 2016-11-25 14:52:34 +01:00
jean-pierre charras fe3c72b6de Remove duplicate definitions only needed only by old python wizards. No more useful in master branch, since a long time. 2016-11-25 13:30:11 +01:00
jean-pierre charras 6d7f0b45f4 dialog_export_step_base: cosmetic enhancements, add tool tips and better messages. 2016-11-25 12:05:51 +01:00
jean-pierre charras ccdfabc866 Add tool tips to autosave widget in dialogs (pcbnew and eeschema) 2016-11-22 11:26:32 +01:00
unknown 334c50477a Auto save: fix case of auto save interval is set to 0 (disabling auto save feature)
This fix allows also the new value of the auto save interval immediately taken in account.
2016-11-22 11:26:31 +01:00
Simon Richter f7cc0a9334 Add missing build dependency.
The generated lib_table_lexer.h file is required to build the pcbcommon
static library.
2016-11-21 07:38:15 -05:00
jean-pierre charras 308dc0e46a sch legacy plugin: fix compatibility with old and very old library and symbol files 2016-11-21 09:57:07 +01:00
Wayne Stambaugh 64c892ee23 Make footprint ID into a generic library ID.
Rename FPID to LIB_ID as is now used as a generic library identifier and
is no longer specific to footprints.

Remove all mention of footprint from the new LIB_ID doxygen comments and
code.

Rename files fpid.h and fpid.cpp to lib_id.h and lib_id.cpp.

Rename fp_lib_table.keywords file to lib_table.keywords and adjust CMake
build dependencies accordingly.

Update all source files effected by the code and file name changes.

Update .gitignore for file name changes.
2016-11-20 18:35:08 -05:00
Wayne Stambaugh 4d018039aa Eeschema: lay the groundwork for symbol library tables.
Create SYM_LIB_TABLE and SYMBOL_LIB_TABLE_ROW objects derived from LIB_TABLE
and LIB_TABLE_ROW respectively for supporting symbol library tables.

Add FPID member to LIB_PART for associating a symbol to a specific library
nickname.  Please note, this is not used in any way at this time and will be
implemented when the symbol library table is actually implemented.

Add sym_lib_table keyword to keywords file.  This is a temporary measure
until a more elegant method for parsing and formatting library tables can
be implemented.

Build FPID support in the common library instead of the pcbcommon library
for use in Eeschema.
2016-11-20 13:38:20 -05:00
Wayne Stambaugh 40e93d263d Split out library table common code into separate source files. 2016-11-20 13:34:03 -05:00
jean-pierre charras 430a09a5a0 sch legacy plugin: fix compatibility issues with old library 2.2 version 2016-11-20 15:19:06 +01:00
jean-pierre charras de46873dfe Eeschema, main menu (menubar.cpp): better code and fix outdated command and tool tip texts 2016-11-20 12:57:16 +01:00
jean-pierre charras 6cf8ff9ca6 Fix message. 2016-11-20 07:21:19 +01:00
Wayne Stambaugh 888c5d2a97 Change boost header file in an attempt to make clang happy yet again. 2016-11-19 19:42:43 -05:00
Wayne Stambaugh 2bfce154cc Add boost header file in an attempt to make clang happy. 2016-11-19 19:18:12 -05:00
Wayne Stambaugh b9c296420a Complete library table and library table row refactor.
Derive LIB_TABLE_ROW from boost::noncopyable for use in boost pointer
containers.

Use std::unique_ptr to manage PROPERTIES pointer.

Add clone support for boost pointer containers.

Split common library table code out from FP_LIB_TABLE into base LIB_TABLE
object.  The FP_LIB_TABLE object only contains the code specific to
footprint library tables.

Use boost::vector_ptr for storing library table row objects.

Fix move up and down bugs in footprint library table edit dialog.
2016-11-19 17:16:43 -05:00
jean-pierre charras b960404f22 page layout editor: better icon 2016-11-19 10:22:08 +01:00
Diego Herranz 90897d4983 Pcbnew, plot dialog: fix incorrect wording. 2016-11-19 09:48:32 +01:00
jean-pierre charras 07e2ccdb59 Eeschema: cosmetic enhancement. 2016-11-19 09:05:58 +01:00
jean-pierre charras 19ce3f276c Fixes: lp:1642864 (Pcbnew Eagle import layer 48 incorrectly mapped)
https://bugs.launchpad.net/kicad/+bug/1642864
2016-11-18 13:19:05 +01:00
Aylons Hazzud 5dc43a1d77 Gray out "Units are not interchangeable" if 1 unit
Fixes: lp:1503921
* https://bugs.launchpad.net/kicad/+bug/1503921
2016-11-18 11:42:42 +01:00
jean-pierre charras 682c15ed62 Add connection highlight to eeschema, step 2: Fixes, refinements, add hot key, cleanup code. 2016-11-16 13:09:34 +01:00
Nox_firegalaxy 44b8533d4d Add connection highlight to eeschema, step 1. 2016-11-16 11:07:02 +01:00
jean-pierre charras d3af42d5de Fixes: lp:1641456 (Linux specific: Unable to load Eeschema libraries that have an absolute path, due to an incorrect initialization of a wxFileName variable)
https://bugs.launchpad.net/kicad/+bug/1641456
2016-11-14 13:12:33 +01:00
jean-pierre charras f53cfe58bd Pcbnew: fix outdated environment vars settings for Kicad python on Windows:
On Windows, previously, Pcbnew try to set env vars PYTHONPATH, if <kicad>/bin/python27_us folder is found.
Now, if python.exe is found in kicad bin folder (therefore if our python executable and libs are
installed in Kicad), PYTHONPATH and PYTHONHOME are set to an empty string.
( the default python path work fine with our standard python install )
2016-11-14 08:23:02 +01:00
jean-pierre charras 7051b6d21f Fixes: lp:1635723 (pcbnew: allows sometimes to draw tracks in non copper layers in Gal Mode)
https://bugs.launchpad.net/kicad/+bug/1635723
2016-11-13 19:02:44 +01:00
jean-pierre charras e246a61a72 Eeschema: fix compil warning on 64 bits machines. 2016-11-13 08:43:24 +01:00
Chris Pavlina b9c62b658e Bring back KICAD_REPO_NAME 2016-11-12 16:16:35 -05:00
Chris Pavlina 7e3c0258aa Fix KICAD_BUILD_VERSION build option 2016-11-12 15:37:01 -05:00
jean-pierre charras 318429590e Eeschema: Fix an issue with new schematic plugin: it expects absolute paths for libraries, but if a library is in the current working dir, its filename was not absolute, and the lib was silently ignored. Now, filenames are always absolute. 2016-11-10 17:47:53 +01:00
jean-pierre charras 8734757054 Update icons used in Windows resource files (Eeschema and Pcbnew icon) 2016-11-10 17:43:58 +01:00
Jean-Noel Avila 58af5bc3a4 Eeschema: Fix off-by-one in saving bitmaps 2016-11-09 09:46:35 +01:00
Marvin Schmidt 66aee09388 Add missing include in kicad_string.h
Without this include the HAVE_STRTOKR define won't be available to
the preprocessor and the strtok_r function will be declared
unconditionally and eventually clash with the declaration from the
system provided equivalent.
2016-11-07 12:36:42 -05:00
jean-pierre charras 9ab7cfea0c * Pcbnew: in fill zones calculations, make polygons strictly simple before fracturing them. 2016-11-06 19:51:09 +01:00
jean-pierre charras 3af551cef8 Fixes: lp:1639330 (Assertion failure opening libedit from eeschema in debug mode)
https://bugs.launchpad.net/kicad/+bug/1639330
2016-11-05 11:39:22 +01:00
jean-pierre charras c7fcb2695c Add a specific bitmap for show electrical type option (component editor and component viewer) 2016-11-04 13:59:45 +01:00
jean-pierre charras f15a59f0ad Component Editor and Component viewer: add option to show the electrical pin type. 2016-11-04 12:13:22 +01:00
jean-pierre charras 9a09b0cb3c Remove a test file committed by mistake (I am guessing) 2016-11-02 19:48:42 +01:00
jean-pierre charras 3bb3f31c7a schematic legacy plugin: fix compatibility with old files, and with doc. 2016-11-02 19:47:38 +01:00
jean-pierre charras 941eeee4d1 Fixes: lp:1638499 (footprint editor, footprint transform: incorrect mirror for pads (noticeable only for pads with offset)
https://bugs.launchpad.net/kicad/+bug/1638499
2016-11-02 12:55:19 +01:00
Wayne Stambaugh 192d4b87ad Rework footprint library table for use in symbol library table.
Factor out ROW object from FP_LIB_TABLE so it can be reused to create a
symbol library table row object.

Create base LIB_TABLE_ROW object from ROW object common code.

Derived FP_LIB_TABLE_ROW object from LIB_TABLE_ROW to provide support for
footprint library table rows.

Update all instances of FP_LIB_TABLE::ROW with FP_LIB_TABLE_ROW.

Purge wxT() macros from modified files where possible.
2016-10-28 09:12:28 -04:00
Mario Luzeiro 86dcfeb69d improve anti-aliasing
+re-implement anti-aliasing, making it more acurate, not blured, better
and much faster (unsing much less lines of code)
+rewrite some function on camera and raypacket.
+small improvements on raytracing realtime, remove useless ifs
comparisons.
2016-10-27 10:22:21 -04:00
Wayne Stambaugh d470ac9c24 Eeschema: minor LIB_PART object changes.
Replace LIB_PART::Conflicts() with an external test to for alias name
conflicts.  This was only use in one place so don't clutter the library
API.

Change LIB_PART::AddPart() return type from bool to void since it's not
checked by any callers and differs from the equivalent schematic I/O
plugin function.
2016-10-26 18:37:28 -04:00
Wayne Stambaugh 4ee0b3827e Eeschema: more schematic I/O plugin prep work.
Add code to schematic I/O plugin for updating library modification
hashes.

Remove unused RemoveLibrary() method from PART_LIBS object.

Purge wxT() macros from modified files.
2016-10-25 18:45:33 -04:00
jean-pierre charras 89f9b7df5c Pcbnew: when update PCB from schematic, spread footprints also in legacy mode. Remove also one useless undo command level after update. 2016-10-25 15:34:59 +02:00
jean-pierre charras 4ee344e150 Gerber files: Enable net attributes options in plot Gerber dlg and fix net attribute for "no net" tracks and vias (netcode <= 0). 2016-10-23 19:43:31 +02:00
jean-pierre charras 1840c3c4c7 Eeschema/Pcbnew: Update PCB From Schematics tool: ensure the netlist is reliable: warn user if a component is not annotated before exporting the netlist to Pcbnew (like in netlist creation dialog). 2016-10-22 20:02:15 +02:00
jean-pierre charras 3bf1717002 Fix a minor cosmetic issue in dialog edit libentry fields 2016-10-22 18:43:12 +02:00
Kevin Cozens 31f583f949 Fix compile error 2016-10-21 13:51:22 -04:00
Wayne Stambaugh 1e752ba164 Eeschema: symbol library viewer improvements.
Select the first library in the list and the first symbol in the first
library if they exist the first time the symbol viewer is opened.

Prevent clicking on the next or previous toolbar buttons from wrapping
past the end of the symbol list to mimic the behavior of the up and down
arrow key strokes.opens a select
library dialog.

Use incriminating or decrementing the current symbol selection when using
the next and previous symbol toolbar buttons rather looking up the next
symbol in the library.  Just use the next or previous symbol name in the
list.

Replace the select library and select symbol from library list dialogs
which where redundant with the symbol search dialog used in place symbol
tool in the schematic editor.  This gives the user type ahead search and
selects the library and symbol in one dialog.

Move updating toolbar buttons from the ReCreateHToolbar() function into
dedicated wxUpdateUIEvents.

Break Process_Special_Functions() into individual event handlers.

Remove PART_LIB::GetNextEntry() and PART_LIB::GetPreviousEntry() as they
are no longer required due to the changes to the symbol library viewer.

Purge wxT() macros from all modified source files.
2016-10-21 08:39:18 -04:00
Maciej Suminski a2f06a9dc4 Merge branch 'font-refine' 2016-10-21 10:25:42 +02:00
Maciej Suminski 74b5858665 Fixed a crash when removing zones using the Global Deletion dialog
Fixes: lp:1635266
* https://bugs.launchpad.net/kicad/+bug/1635266
2016-10-20 17:15:50 +02:00
decimad 402f53a302 update font code along with the changes done in the msdf atlas tool (use codepoint spans and refined char placement)
add font coordinate system clarification drawing (svg)
2016-10-20 14:31:09 +02:00
decimad d9a8aac96c transfer font texture width to the fragment shader via uniform variable 2016-10-20 14:31:09 +02:00
jean-pierre charras ce83410c52 export_vrml.cpp: fix shadowed variable. 2016-10-20 13:20:49 +02:00
jean-pierre charras 45e67d25dd Fixes: lp:1635018 (Per-footprint tedit timestamp updated even when footprint isn't (updated at loading time, not after edit))
https://bugs.launchpad.net/kicad/+bug/1635018
2016-10-20 13:20:00 +02:00
Tomasz Włostowski 4d180efa5f router: correct handling of per-pad/per-module clearance 2016-10-19 17:54:00 +02:00
Tomasz Włostowski bb20a7f592 common: remove dependency on libbitmaps in EDA_ITEM::GetMenuImage() 2016-10-19 17:54:00 +02:00
Tomasz Włostowski 69cd7177b9 SHAPE_POLY_SET: mark all newly added hole outlines as closed 2016-10-19 17:54:00 +02:00
jean-pierre charras 1924478558 Eeschema: editors: show the pin position (when clicking on it) in message panel.
Pin properties dialog: show pin position ( and allow editon ).
2016-10-18 18:59:26 +02:00
Wayne Stambaugh c483574658 Add stitching via support to the version 5 road map. 2016-10-17 11:11:35 -04:00
Henner Zeller cd49ff0120 Pcbnew: prevent reversal of pad loading order when loading board.
When opening a board file and storing it again, the pads in all
embedded modules get reversed.  This is generally not really nice
if the PCB is managed by version control as it creates churn and
could make merges hard.
2016-10-17 10:07:29 -04:00
Michele Renda 64bb1ca924 Fix infinite loop when schema file contains a comment or an empty line 2016-10-17 08:35:20 -04:00
Maciej Suminski ba81eda197 Extended gitignore rules for build directories 2016-10-17 11:59:10 +02:00
Maciej Suminski af3d5befa7 Solve codemodel libraries loading problem in ngspice
Fixes: lp:1630675
* https://bugs.launchpad.net/kicad/+bug/1630675
2016-10-17 10:11:27 +02:00
jean-pierre charras d1e4399a29 dialog edit libentry fields in lib: Add button to edit spice parameters, and therefore to add spice parameters in lib components. 2016-10-15 20:05:03 +02:00
Wayne Stambaugh fc07716aed Eeschema: schematic I/O plugin preparation work.
Rename PART_LIB GetEntryNames() and RemoveEntry() to GetAliasNames() and
RemoveAlias() respectively for improved readability.

Rename PART_LIBS FindLibraryEntry() to FindLibraryAlias() improved
readability.

Remove commented out PART_LIBS::FindLibraryEntries().

Remove PART_LIB::GetFirstEntry() and update all effect code accordingly.

Remove unused PART_LIB::SetFileName() method.

Remove unused PART_LIBS::RemoveAllLibraries() method.
2016-10-14 19:29:24 -04:00
jean-pierre charras d167407d1a Pcbnew: add "edit all tracks and vias" command in edit menu.
Previously, this command was accessible only by right clicking on a track and only in the legacy mode.
2016-10-14 21:07:39 +02:00
Wayne Stambaugh 87eda6180d Allow the contents of KiCadVersion.cmake to override git version.
When the version string in KiCadVersion.cmake is set to something other
than the default "no-vcs-found", it ignores the git version even if a
.git folder exists in the source folder.
2016-10-14 09:43:38 -04:00
jean-pierre charras 038f8713ce Pcbnew: trace length calculations:
fix incorrect calculation when a small segment at the end of the track was inside a pad: it was not taken in account.
Fix also the len die values not always taken in account (references to pads at end of track not always stored)
This is a partial fix of bug 1628585.
2016-10-14 10:35:08 +02:00
jean-pierre charras 9fdcba8229 Gerbview: Fix 2 (minor) issues in aperture macro "moire". Add a .gbr test file for this aperture macro. 2016-10-13 10:26:49 +02:00
Wayne Stambaugh 03da56a9b5 Minor version string generation improvements.
Remove the KICAD_REPO_NAME option from the main cmake file and the
generated config.h file since it is no longer used.

Set the default branch name to "undefined" in CreateGitVersionHeader.cmake
instead of the KICAD_REPO_NAME option.

Remove generating KICAD_FULL_VERSION from CreateGitVersionHeader.cmake
and add it to WriteVersionHeader.cmake so that the default settings and
the new KiCadVersion.cmake definitions can be used to generate the full
version string as well.

Check to see if the branch name is set and only use the version to
generate the full version string.  This allows the use of the KiCad
version cmake file to create a version only string like "4.0.4" with
no trailing branch name.

Change build_version.cpp to use the full version string rather than
concatenating the version and branch strings.
2016-10-12 20:29:46 -04:00
Wayne Stambaugh b54166daa3 Improve version string generation for stable release source archives.
Add KiCadVersion.cmake to set the build version and branch name.

Update WriteVersionHeader.cmake to include KiCadVersion.cmake to set
the defaults in case no .git directory is found.
2016-10-12 16:24:14 -04:00
Wayne Stambaugh 129fa52b65 CvPcb: remove broken footprint documentation feature.
At one point, all of the footprints provided by the KiCad footprint
libraries were merged into a single pdf file.  The link to open this
file was provided on the toolbar.  Since the footprint libraries have
been split out into individual repositories, this file is no longer
created so the toolbar button and the underlying code to open this
file were removed.

Improve a few CvPcb menu strings.

Fixes lp:702785

https://bugs.launchpad.net/ubuntu/+source/kicad/+bug/702785
2016-10-11 15:08:40 -04:00
Maciej Suminski 4e5f11c646 Fixed a crash when a negative (although invalid) net code occurs in legacy plugin 2016-10-11 16:03:00 +02:00
Cirilo Bernardo aa7d78494d Fixed scaling problems in VRML export 2016-10-10 20:11:59 -04:00
Simon Richter 6000336fe7 Add missing include
std::iota is defined in <numeric>
2016-10-10 19:44:46 -04:00
Cirilo Bernardo 48ed9f080e Add Help Menu item to open browser at kicad-pcb.org/contribute 2016-10-10 19:01:45 -04:00
Fabrizio Tappero 194bd1d617 Minor menu text consistency improvements. 2016-10-10 18:54:58 -04:00
Simon Richter b0f9864bc4 Clean up warnings from exception handlers
The exception objects caught are either not referenced at all, or only in
debug builds. This avoids the warnings for the unused variables.
2016-10-10 11:08:49 -04:00
Mario Luzeiro 6d27087053 Improve board texture (make it square), add directional light to top/bot. 2016-10-09 11:34:28 -04:00
Mario Luzeiro f59bde8cc3 Improve brushed and plastic textures 2016-10-09 11:34:20 -04:00
Mario Luzeiro ae8c62843e Raytracing: implement brushed metal perturbator 2016-10-09 11:34:09 -04:00
Mario Luzeiro 995fde8d9c (forget to staged modified files) 2016-10-09 11:33:53 -04:00
Mario Luzeiro 8493a2f6d5 Raytracing: implement textures based on normal perturbation
Implement normal perturbation for black epoxy and color plastic.
Fix some UI issues in 3D-Viewer (menu options was not proper saved or
updated)
2016-10-09 11:33:25 -04:00
Mario Luzeiro ee71875b4b Implement normal perturbation materials on raytracing 2016-10-09 11:33:16 -04:00
Mario Luzeiro 89bb47ede6 Improve shadow on postshader and add a gamma sRGB color space convertion 2016-10-09 11:33:09 -04:00
Mario Luzeiro 49dce5d191 Improve shadow calculation on Raytracing
Makes it not so dark.
Speed optimization on post shader calculation.
2016-10-09 11:32:59 -04:00
decimad 4248a7ffce remove boost::thread dependency 2016-10-09 10:33:52 -04:00
Cirilo Bernardo 44ba343a7b Changed test for invalid numeric strings in VRML files 2016-10-09 08:43:36 -04:00
Wayne Stambaugh 213ceaa280 Eeschema: add delete symbol library code to schematic legacy plugin. 2016-10-09 08:29:44 -04:00
Wayne Stambaugh f14dc8f2be Pcbnew: fix epic footprint editor DXF import fail.
The unfortunate combination of using static_cast to promote board items
to module items then using the assignment operator without any thought as
to what would happen in MODULE::Add() caused the board objects to not be
added to the module.  This is expected because board items cannot be in
modules.  Did this ever work or did someone have a colossal brain cramp?
If it did work, who ever changed it did not test it because in debug
builds, you would have gotten and assertion on every object imported.  On
release builds nothing is imported silently.

Add module object types to the DXF importer and code to choose which type
of object to import.

Remove offending static casts and assignment operator and pass the correct
object directly to the MODULE::Add() function when importing DXF in the
footprint editor.

The usual coding policy fixes.
2016-10-07 21:10:51 -04:00
Wayne Stambaugh abf33cce68 Pcbnew: fix drill file naming issue.
On windows when the project path include a remote volume name (\\NAME),
the volume name does not get cleared by calling wxFileName.SetDir( "" ).
This caused the volume name to be prepended to the file name when
calling wxFileName::GetFullPath().  Use wxFileName::GetFullName()
which resolves the issue.

Fix some minor grammar errors.

Fix some minor coding policy issues.

Fixes lp:1606240

https://bugs.launchpad.net/kicad/+bug/1606240
2016-10-07 10:58:48 -04:00
Maciej Suminski 7a4f1685df Extended fixes_alias description 2016-10-07 16:52:52 +02:00
Maciej Suminski 26ee676278 Handle Spice_Netlist_Enabled attribute in Spice netlist exporter
Fixes: lp:1630502
* https://bugs.launchpad.net/kicad/+bug/1630502
2016-10-07 16:50:47 +02:00
Maciej Suminski efdfaebf62 Support subdirectories in relative paths in Spice model dialog 2016-10-07 16:07:38 +02:00
Wayne Stambaugh 4f0c2ad083 Eeschema: add create symbol library to legacy schematic I/O plugin. 2016-10-07 09:18:15 -04:00
jean-pierre charras fdebcd8a6d Fixes: lp:1629387 (pagelayout text sometimes shrinking)
https://bugs.launchpad.net/kicad/+bug/1629387
2016-10-06 17:19:55 +02:00
Jean-Pierre Charras e0fb7f89f4 Pcbnew: additional scripting build warning fixes.
Add pcbnewPYTHON_wrap.cxx to the list of files to apply -Wno-suggest-override
compiler flag to prevent compiler warnings on file that is generated by SWIG.
2016-10-06 09:06:42 -04:00
John Beard 93a843c022 Add override specifier in scripting dialog 2016-10-05 15:07:06 -04:00
John Beard 6504b7b55c Disable -Wsuggest-override for scripting files, but not other files
This allows the warning to be active for code which would benefit from
it, but not spew hundreds of warnings for code over which KiCad does not
have control of the override specifiers.
2016-10-05 10:43:56 -04:00
jean-pierre charras 4505896634 A few zone outline context menu commands missing after creating a keepout area
( partial fix of lp:1630368 )
2016-10-05 15:12:10 +02:00
jean-pierre charras 15517964c9 Fixes: lp:1630105 (Gerbview print dialog does not display graphic layers list on some windows managers like Unity)
https://bugs.launchpad.net/kicad/+bug/1630105
2016-10-04 09:51:35 +02:00
Chris Pavlina 278ee7da7d Remove deprecated 'register' storage spec 2016-09-30 22:32:24 -04:00
Chris Pavlina b9abcc309f Fix Validate hiding overloaded virtual in 3D viewer dialog 2016-09-30 22:32:24 -04:00
Chris Pavlina 71263c32e8 Dismiss signed index warning in opengl_gal.cpp 2016-09-30 22:32:24 -04:00
Chris Pavlina 91c8201b8b Dismiss warning for inconsistent exception spec in ~KIWAY_PLAYER() 2016-09-30 22:32:24 -04:00
Chris Pavlina 9547dd4e52 Fix GetBoundingBox hiding overloaded virtual 2016-09-30 22:32:24 -04:00
jean-pierre charras c9fec4a4ed Do not use -Wsuggest-override option if KICAD_SCRIPTING is enabled because it creates too many useless warnings when compiling pcbnewPYTHON_wrap.cxx 2016-09-30 18:38:23 +02:00
jean-pierre charras 67faa5e656 clean.cpp: better code. 2016-09-30 18:33:46 +02:00
Wayne Stambaugh 9d258ba921 Eeschema: fix parsing bug in legacy schematic I/O plugin.
Yet another quirk parsing LIB_TEXT object was found.  Apparently even in
library version 2.3, the text properties can be dropped so a check for
end of line was added to prevent the parser from choking on a valid text
line.

Fixes lp:1628160

https://bugs.launchpad.net/kicad/+bug/1628160
2016-09-30 10:01:50 -04:00
jean-pierre charras b5839893d0 Pcbnew, clean board: fix issues and add option in dialog to remove bad track segments (short circuit between 2 nets) 2016-09-30 11:11:52 +02:00
jean-pierre charras 1ebac06d2f Pcbnew, undo redo: fix a crash in legacy mode when undo a footprint change (for instance a 45 degrees rotation) 2016-09-30 11:11:52 +02:00
Heikki Pulkkinen ab0cf7dee1 clean.cpp little bug fix 2016-09-30 11:11:52 +02:00
jean-pierre charras 502d0a38be Fix a missing parameter initialization (arc angle) in footprint DXF import 2016-09-30 11:11:52 +02:00
Maciej Suminski abbd47e2f2 Remove an unused variable and a debug printf 2016-09-30 09:31:40 +02:00
Tomasz Włostowski 3257f1a863 pns: fixed inline drag grid snapping & undo-related assertion failure
Fixes: lp:1628697
* https://bugs.launchpad.net/kicad/+bug/1628697
2016-09-30 09:29:49 +02:00
Tomasz Włostowski 4bc4dc80b6 pns: unique_ptr for BOARD_COMMIT member 2016-09-30 09:05:58 +02:00
Chris Pavlina 2b7e6e73ec Fix uninitialized variable in drawing_tool.cpp 2016-09-30 09:04:18 +02:00
Chris Pavlina 7454f5565f Dismiss unused variable warning in ratsnest_data.cpp 2016-09-30 09:04:14 +02:00
Wayne Stambaugh aa5e979b8a Eeschema: add delete symbol method to schematic I/O plugin. 2016-09-29 18:34:31 -04:00
Simon Richter 04e21d5c8f Remove check for undefined behaviour
Triangle::NeighborAcross returns a reference, which must refer to a valid
object whose address cannot be 0. Thus, this test is nonsensical.
2016-09-29 18:26:19 -04:00
Maciej Suminski 7a5f72c948 Fixed a crash when drawing a single point polyline 2016-09-29 15:34:08 +02:00
Dick Hollenbeck 904ae200e8 Add python script for DDR3 length matching using T topology. 2016-09-28 11:02:05 -04:00
Wayne Stambaugh 92216b7351 Eeschema: fix assertion on delete node hot key while busy.
Performing a delete node hot key operation while Eeschema is busy performing
another operation causes an assertion in the delete node command event
handler in debug builds.  It also causes the operation in progress to be
cleared if the assertion is ignored or in release builds.

Fix a similar issue when the leave current sheet hot key is called while
busing performing another operation which causes rather interesting behavior
in the sheet that was exited.

Fixes lp:1627434

https://bugs.launchpad.net/kicad/+bug/1627434
2016-09-27 20:40:59 -04:00
Chris Pavlina 245607d05c Fix version header rewrite (happened too often)
This commit also simplifies the rewrite logic slightly, removing the
regex parsing.

Bug introduced in:

    commit 47772e7ae3
    Author: Chris Pavlina <pavlina.chris@gmail.com>
    Date:   Sun Sep 25 10:28:50 2016 -0400

        cmake: rewrite version header when branch changes

        Before, only KICAD_BUILD_VERSION, which includes the hash but not the
        branch, was compared when deciding whether to regenerate
        kicad_build_version.h. This header also contains the branch name though,
        so we should compare both to address the case of two branches pointing
        at the same commit.
2016-09-27 11:40:12 -04:00
Jean-Samuel Reynaud 91479bebf8 Fix for compilation error on Ubuntu 14.04 (has no effect on 16.04, and on Windows/msys2, certainly due to more recent swig and cmake versions) 2016-09-27 16:50:22 +02:00
Maciej Suminski 18695751e8 Fixed a footprint editor crash on DXF import
Fixes: lp:1627422
* https://bugs.launchpad.net/kicad/+bug/1627422
2016-09-27 13:36:52 +02:00
jean-pierre charras 673b094b2b Fix a few missing override qualifiers and shadowed vars. 2016-09-27 10:58:05 +02:00
Maciej Suminski f2462925ec Fixed a crash when adding/removing pads
Fixes: lp:1627296
* https://bugs.launchpad.net/kicad/+bug/1627296
2016-09-27 09:30:32 +02:00
Cirilo Bernardo 451cbedd2c Change KICADMODEL definition from struct to class for consistency 2016-09-26 23:54:34 -04:00
Chris Pavlina 52aa4ecdf4 Unify window title formats
Most window titles are now of the format "Application — file [info]",
with adaptations as necessary. Version information has been removed from
titles.
2016-09-26 17:28:25 -04:00
jean-pierre charras 41735b6563 Add missing override keywords. 2016-09-26 19:58:33 +02:00
jean-pierre charras 89914fa9de Fix 2 Coverity warnings. 2016-09-26 19:58:32 +02:00
Maciej Suminski 1420a0179f Removed deprecated pragmas to mute warnings 2016-09-26 14:53:43 +02:00
jean-pierre charras 2717c63c6a Add missing override to 4 virtual methods in kicad2step.cpp. 2016-09-26 08:40:12 +02:00
Simon Wells 7a1d39ccc6 Add system to OCE includes, Change order of local includes for kicad2step 2016-09-26 08:17:57 +02:00
Simon Richter ad088db6d2 Add more "override" markers. 2016-09-25 13:59:41 -04:00
Simon Richter ff41c8f7cb Warn about missing override specifiers, if supported (gcc 5.1, clang 3.5) 2016-09-25 13:59:41 -04:00
Maciej Suminski 83c805e8fb Simplified code for adding/removing items in RN_DATA 2016-09-25 19:37:51 +02:00
John Beard 6b7c2685b2 Protect against uninitialised netcodes when adding to RN_DATA 2016-09-25 19:37:51 +02:00
Chris Pavlina 47772e7ae3 cmake: rewrite version header when branch changes
Before, only KICAD_BUILD_VERSION, which includes the hash but not the
branch, was compared when deciding whether to regenerate
kicad_build_version.h. This header also contains the branch name though,
so we should compare both to address the case of two branches pointing
at the same commit.
2016-09-25 10:31:30 -04:00
Cirilo Bernardo bf4b26d73f Remove STEP diagnostic print
This patch removes a stdcerr print which was accidentally left in the code.
2016-09-25 10:08:13 -04:00
jean-pierre charras 48c18604fc Layers manager: add (in context menu) show all layers and hide all layers, and code cleanup. 2016-09-25 13:08:04 +02:00
dino 33e1a4e884 pcbnew: Added 'show all layers' and 'hide all layers' option in layers manager 2016-09-25 10:57:33 +02:00
jean-pierre charras e9c0dc1a2b Fix a minor issue when creating net attributes in Gerber files for oval pads when they are not horizontal or vertical . 2016-09-25 10:55:24 +02:00
Wayne Stambaugh 8b59350e44 Pcbnew: fix override release build error.
NETINFO_ITEM::Show() method was not wrapped in #ifdef DEBUG/#endif causing
an error in release builds.
2016-09-24 16:00:09 -04:00
Simon Richter 59c81976dc Explicitly mark overriding functions. 2016-09-24 14:53:15 -04:00
John Beard 360794b3a4 On a failure to cache a symbol lib, don't skip subsequent libs
By rethrowing the exception here, the entire caching process is
curtailed if there is an IO_ERROR while parsing a lib. This means any
libs up to the one before the bad one will be cached, but ones after it
wil not be.

Change to wxLogError to gather the errors to present to the user at the
end of the process.
2016-09-24 12:08:12 -04:00
Wayne Stambaugh 9490b02cb8 Pcbnew: fix board I/O plugin formatter build warnings.
Internally time stamps are defined as unsigned long.  On some platforms,
time_t is defined as unsigned long long.  Cast all time_t instances to
unsigned long to prevent the compiler from complaining.
2016-09-24 11:53:22 -04:00
Wayne Stambaugh 58abb29827 Eeschema: add delete alias from library to I/O manager.
Modify base I/O manager class to delete alias from a symbol library.

Add delete alias from legacy symbol library plugin.
2016-09-23 13:29:17 -04:00
Simon Wells 3a50f7367f Modified path on osx due to GetExecutablePath() pointing to the root of the .app bundle 2016-09-23 10:24:52 -04:00
Dick Hollenbeck 374808ac5b Cleanup SWIG's board.i, remove scrap *.{ref,orig} files, and add .pyc to .gitignore 2016-09-23 08:04:12 -04:00
Maciej Suminski 3623421912 Fixed a PNS crash after undoing the last operation while routing 2016-09-23 13:58:33 +02:00
decimad 6a9c1cb6a1 Split the undo/redo event into the two stages "pre" and "post" for convenient synchronization of dependent state. 2016-09-23 13:29:25 +02:00
Cirilo Bernardo 8ea643cefc Fix export_vrml.cpp warnings and removes the few instances of wxT() in that file. 2016-09-23 09:55:33 +02:00
Dick Hollenbeck b8dc6af706 fix swig warning 2016-09-22 15:42:42 -04:00
Maciej Suminski 9e587a1ea2 Fixed an assertion in SIM_PLOT_FRAME
wxListCtrl cannot have wxLC_REPORT and wxLC_SMALL_ICON enabled at the same time (Windows)
2016-09-22 18:27:56 +02:00
Simon Wells 44d3018125 Added explicit conversion from wxstring to cstring 2016-09-22 10:59:40 -04:00
Dick Hollenbeck 45f6f8b305 Remove experimental code added during swig work. 2016-09-22 10:51:29 -04:00
Cirilo Bernardo 8b8626ceeb Removed wxT() from kicad2step modules and made modifications to the STEP Export GUI 2016-09-22 08:37:16 -04:00
Cirilo Bernardo ba65c39b40 Fixed error in setting Windows extension on executable file 2016-09-22 08:37:16 -04:00
Cirilo Bernardo 88cdb8bbbe Removed dialog, instead the autosave() is always invoked for a dirty PCB 2016-09-22 08:37:16 -04:00
Cirilo Bernardo 8b259f2837 Fixed typo preventing compilation on MSWin 2016-09-22 08:37:16 -04:00
Cirilo Bernardo fb59a7416a Added option to remove Virtual Components from STEP assembly 2016-09-22 08:37:16 -04:00
Cirilo Bernardo 33948e572d Added STEP Export menu item and supporting code 2016-09-22 08:37:16 -04:00
Cirilo Bernardo 34fef23bd4 Reworked cmdline options and added output filename option 2016-09-22 08:37:16 -04:00
Cirilo Bernardo a9cb10c947 Added --no-virtual option to suppress inclusion of 3D models from components with the virtual attribute 2016-09-22 08:37:16 -04:00
Cirilo Bernardo 375741eeaa Modified parser to skip drill specifications for SMD pads 2016-09-22 08:37:16 -04:00
Cirilo Bernardo ad7302358b Fixed install path for OSX 2016-09-22 08:37:16 -04:00
Cirilo Bernardo 1848a87844 Fixed build conditions to depend on KICAD_USE_OCE (formerly USE_OCE) and removed extra spaces 2016-09-22 08:37:16 -04:00
Cirilo Bernardo 11a44388ee Added options to use Drill or Grid origin for outptu STEP file 2016-09-22 08:37:16 -04:00
Cirilo Bernardo 231b08e58f Added kicad2step tool. 2016-09-22 08:37:16 -04:00
Cirilo Bernardo 809b0040ea Added mroszko's SEXPR parser (ref: https://github.com/marekr/sexpr) 2016-09-22 08:37:16 -04:00
Dick Hollenbeck 29be200843 Add SWIG support for NETCLASSPTR. Reduce SWIG visibility from C++ headers. 2016-09-21 19:52:04 -04:00
Dick Hollenbeck 85ef7ee467 Remove BOARD::Add() from board.i, since it is inherited from board_item_container.i 2016-09-21 19:12:45 -04:00
Simon Richter eeae8c741a Synchronize forward declaration with definition
The actual definition uses "class", so the forward declarations should do
so, too.
2016-09-21 16:35:00 -04:00
Gustav Bergquist 061a7b8450 Cast TOOL_EVENT parameter type to intptr_t 2016-09-21 21:22:19 +02:00
jean-pierre charras 0e32cc14c2 bitmap_png/CMakeLists.txt: make creation of log files optional in "MAINTAIN_PNGS" mode (because they are most of time useless)
image.svg: fix a convert to png issue (certainly to a bug in Inkscape).
2016-09-21 19:52:46 +02:00
Niki Guldbrand d618bfbae0 cleanup CMakeLists.txt for bitmaps 2016-09-21 19:52:46 +02:00
Cirilo Bernardo d3771d53ef Updated VRML exporter and fixed some VRML related bugs 2016-09-21 09:31:52 -04:00
Maciej Suminski 65821328d2 Fix a crash when dragging a via attached to a locked track (PNS)
Fixes: lp:1625835
* https://bugs.launchpad.net/kicad/+bug/1625835
2016-09-21 14:47:14 +02:00
decimad ee3d75f273 Add coroutine call invocation context to identify the main stack frame.
Run the text draw-tool on the main stack frame.

Fixes: lp:1547282
* https://bugs.launchpad.net/kicad/+bug/1547282
2016-09-21 11:56:40 +02:00
jean-pierre charras d42fd751f9 Gerbview print: print now the Gerber filename, the number of pages to print, and a page number 2016-09-21 11:34:18 +02:00
Ian Roth ec3109472a Correct page numbers on pcbnew multipage print 2016-09-21 09:04:05 +02:00
Dick Hollenbeck 1edaa773d3 Fix minor SWIG issues due to git rebase issues. 2016-09-20 21:52:48 -04:00
Dick Hollenbeck 1718ac1083 More SWIG improvements.
SWIG support for BOARD_ITEM_CONTAINER.
Split board.i into smaller included *.i files.
Add depencies on these smaller *.i files to CMakeLists.txt
2016-09-20 21:48:44 -04:00
Chris Pavlina c57fd7ccbf Fix signed/unsigned comparison warning in PNS::LINE::ClipVertexRange 2016-09-20 14:26:16 -04:00
Dick Hollenbeck d957670034 Add more HANDLE_EXCEPTIONS(), board.i refactoring. 2016-09-20 12:00:17 -04:00
Dick Hollenbeck 64232ce10c Comment out kiway from python preliminary work. 2016-09-20 12:00:09 -04:00
Dick Hollenbeck 7311f07eaf SWIG Improvements
*) Extend SWIG support deeper into the BOARD class.
*) Move swig *.i files into a directory identified for SWIG, in preparation
   for a parallel universe involving Phoenix's SIP.
*) Move swig files which will be common to both eeschema and pcbnew into
   common/swig.
*) Sketch out a "common" python module, and plan on dovetailing that into a
   libkicad_shared.{dll,so}
*) Add common/swig/ki_exceptions.i and define a macro HANDLE_EXCEPTIONS()
   which is to be applied to any function which needs C++ to python
   exception translation.
*) Move the test for SWIG tool into top level CMakeLists.txt file for use
   in all python modules beyond pcbnew, i.e. eeschema and common.
*) Add SWIG_MODULE_pcbnew_EXTRA_DEPS which generates a better Makefile, one
   which rebuilds the swig generated *.cxx file when one of its dependencies
   change.
*) Re-architect the board.i file so that it can be split into multiple *.i
   files easily.
*) Make some KIWAY from python progress, in preparation for Modular KiCad
   phase III.
2016-09-20 11:59:43 -04:00
Dick Hollenbeck 964b5a1830 Split IO_ERROR out of richio.* and store Problem() and Where() separately 2016-09-20 11:56:23 -04:00
Dick Hollenbeck 9ad49dc2d1 Split IO_ERROR out of richio.* and store Problem() and Where() separately 2016-09-20 11:56:18 -04:00
Dick Hollenbeck 9761c881e2 .gitignore build-* and *~ files 2016-09-20 11:56:06 -04:00
jean-pierre charras 3f104448df Rename libedit_icon to icon_libedit, bo be consistent with other icon names. 2016-09-20 13:23:17 +02:00
Maciej Suminski 4bb16afc9e Fixed text placement tool in FP editor
Fixes: lp:1625304
* https://bugs.launchpad.net/kicad/+bug/1625304
2016-09-20 10:19:33 +02:00
Fabrizio Tappero bf4e50945a New icons for Eeschema and Pcbnew 2016-09-20 09:56:16 +02:00
jean-pierre charras 1051732580 DIALOG_SPICE_MODEL_BASE: cosmetic enhancements (mainly better look of spice units table in Passive notebook page) 2016-09-19 18:48:07 +02:00
Maciej Suminski 61e415bdb9 Deboostified ratsnest model in GAL 2016-09-19 17:25:31 +02:00
Simon Wells a2116ae070 Removed wxPaintDC from EDA_DRAW_PANEL_GAL::onPaint() 2016-09-19 15:17:18 +02:00
jean-pierre charras 6edee2ae1d Prepare Plot Gerber file to include advanced aperture and net attributes.
This option is not yet activated because the net attributes are not yet fully fixed by Ucamco, in Gerber file format specifications.
(To activate it, see dialog_plot.cpp, line 43)
2016-09-19 13:01:36 +02:00
Maciej Suminski 7f9380af26 Update the status panel after every commit. 2016-09-19 12:08:29 +02:00
Maciej Suminski 4ffd3c8511 Fix ratsnest after running DRC
Fixes: lp:1624000
* https://bugs.launchpad.net/kicad/+bug/1624000
2016-09-19 12:08:29 +02:00
Wayne Stambaugh 679eef1c43 Eeschema: fix build errors and warnings.
Fix build error when KICAD_USE_SCH_IO_MANAGER=OFF due to const issues with
LIB_PART ctor.

Fix unused variable build warning in legacy schematic plugin.
2016-09-17 20:18:03 -04:00
Wayne Stambaugh 225f0d8917 Update build KiCad from source documentation.
Add note about KICAD_BUILD_VERSION and KICAD_REPO_NAME CMake configuration
variables.

Fix incorrect path for OSX patch command.

Add new OSX patches to OSX build instructions.

Fix missing ngspice url.
2016-09-17 15:49:20 -04:00
Wayne Stambaugh 3ae240ea46 Eeschema: add save code to legacy symbol library plugin.
Make LIB_PART copy constructor take a const LIB_PART reference.

Add SaveSymbol to legacy symbol library plugin.

Add removeAlias to legacy symbol library cache.

Add AddSymbol to legacy symbol library cache.
2016-09-17 14:45:01 -04:00
Simon Wells 6117713f33 Add wxwidgets patch for unicode pasteboard.
Based on upstream https://github.com/wxWidgets/wxWidgets/commit/
73fca4c37d1ee2e9e495aaa68442cdfcb4243b52

Fixes: lp:1559103
2016-09-17 13:20:00 -04:00
Collin Anderson f5f0ab094f wxWidgets OSX Sierra 10.12 SDK patch.
OSX Sierra has removed QuickTime entirely (because Apple needs to break
at least one thing every major OS revision).  This prevents wxWidgets
from compiling at all, and as of right now, there is only a workaround,
but a true upstream fix will require rewriting portions of wx to use
AVKit, which is more or less the replacement for QuickTime, instead.

KiCad doesn't use any parts of wx involved, so the work around seems to
be fine for us.  I am using the latest commit of KiCad on 10.12 as I write
this, with this patch applied, and I'm not having any problems (at least
new ones anyway).

The workaround is this patch (which is not a direct copy of the upstream
fix, which simply removes the include entirely.  I made it where if this
patch gets applied, it won't effect anything except when being built
against the 10.12 SDK).  Additionally, wxWidgets configure must be given
the --disable-mediactrl flag.  This is a temporary workaround, but as far
as I know, KiCad doesn't use that control?
2016-09-17 13:11:29 -04:00
jean-pierre charras 0719f8d214 Fixes: lp:1624659 (fix some issues in countries which are not using a point as decimal separator)
https://bugs.launchpad.net/kicad/+bug/1624659
Small enhancement in dialog_spice_model_base.cpp: add comments about spice values notation.
2016-09-17 18:34:44 +02:00
Collin Anderson e5064231f9 Make OSX patch style consistent. 2016-09-17 12:19:45 -04:00
Werner Almesberger 01054ae49a Make pagelayout_default.kicad_wks match defaultPageLayout
The pagelayout_default.kicad_wks template differs slightly from
common/page_layout/page_layout_default_description.cpp:defaultPageLayout

Not sure if this is intentional or a bug. In any case, here is a
patch that changes pagelayout_default.kicad_wks to match
defaultPageLayout.

This patch is based on the previous one that added missing
parentheses.
2016-09-17 12:05:41 -04:00
Werner Almesberger 9a7eee9b8a Add missing parentheses in page layout templates
The default and logo page layout templates are missing some opening
parentheses. Eeschema's parser accepts them anyway, but it tripped
my s-expr parser.

The gost templates and the built-in default in
common/page_layout/page_layout_default_description.cpp
are both correct.
2016-09-17 12:03:53 -04:00
jean-pierre charras f3d4f7322b Simulator dialogs: Fix incorrect handling of Validate(), which was called for all widgets by the default wxID_OK button handler. It is now called only for the active page of these dialogs (as wanted in code), therefore only for used widgets.
Note: strangely, this issue was noticed only on Windows, not on Linux.
2016-09-17 14:38:34 +02:00
jean-pierre charras 48f916bd63 Kicad manger: add .cir netlist files to the list of files to show in project tree.
Simulator: open/save worbook file dialog: the dialog opens the current project folder by default.
2016-09-17 09:34:16 +02:00
Niki Guldbrand e8b244486a Remove unused stanalone build in bitmaps_png
* Remove support for building the Bitmap lib standalone,
  which has been broken since the switch from svn.

Signed-off-by: Niki Guldbrand <niki.guldbrand@gmail.com>
2016-09-16 16:47:34 -04:00
Nick Østergaard 6767ea7bbf Update the REAMDE.txt to reflect the current structure
The old changelog was archived together with the others in
Documentation/changelogs.
2016-09-16 16:43:19 -04:00
Niki Guldbrand b5237bc154 Further cleanup post switch to git.
* Remove the obsolete bzr rules file.

Signed-off-by: Niki Guldbrand <niki.guldbrand@gmail.com>
2016-09-16 16:41:26 -04:00
jean-pierre charras cd94da7972 Spice simulator and netlist generation: use only netnames (outdated option "use net numbers as net names removed" removed)
netlist generation: remove option "replace IC and U ref by X" (broken option).
All component refs are now prefixed by the Spice_Primitive field value.
Therefore the netlist used by Kicad ngsipce simulator and the spice netlist generated from dialog are the same.
(note: like previously, forbidden chars like ( and ) are replaced by _ in netnames)
2016-09-16 20:36:19 +02:00
Niki Guldbrand c689c8cc3f Remove redundant data in defines.
* Using CMAKE_INSTALL_PREFIX in KICAD_* install paths is redundant,
  because they are allready relative to CMAKE_INSTALL_PREFIX when no
  absolute path is given.
  Using an absolute path makes it harder to change the install
  path on the fly, without either rebuilding, or manually editing
  CMakeCache.txt

Signed-off-by: Niki Guldbrand <niki.guldbrand@gmail.com>
2016-09-16 09:09:56 -04:00
Simon Richter 6689c7e75e Include header instead of full source 2016-09-16 09:29:44 +02:00
Maciej Suminski 48c3f577a9 Do not include ratsnest_viewitem.cpp in two CMakeLists. 2016-09-15 22:04:07 +02:00
Maciej Suminski 5e9b2247eb Fixed SWIG interface
Now Add()/Remove() methods are provided via BOARD_ITEM_CONTAINER
interface.
2016-09-15 16:14:38 +02:00
Nick Østergaard 881ebe59c5 Remove now obsolete bzr check 2016-09-15 08:33:17 -04:00
Maciej Suminski 8590809c7a Selection tool fix to enable selecting overlapping items
Fixes: lp:1499022
* https://bugs.launchpad.net/kicad/+bug/1499022
2016-09-15 13:25:08 +02:00
José Ignacio Romero 83ed3c933e Add KICAD_INSTALL_DEMOS CMake option
It is ON by default, determines wether to install the bundled demos
and examples.
2016-09-14 19:57:35 -04:00
Wayne Stambaugh e7e165d68a Remove unused Bazaar and Subversion cmake files. 2016-09-14 19:45:32 -04:00
jp-charras 89a9b9177f Fixes: lp:1622164 (pl-editor does not accept both '.' and ',' as floating point separator in countries which use ',' as separator)
https://bugs.launchpad.net/kicad/+bug/1622164
2016-09-14 18:53:24 +02:00
Tomasz Wlostowski 104a066268 Faster layer visibility switching in GAL
Fixes: lp:1623055
* https://bugs.launchpad.net/kicad/+bug/1623055
2016-09-14 11:58:10 +02:00
decimad f78721b451 Multichannel Signed Distance Field text rendering for OpenGL GAL 2016-09-14 10:00:49 +02:00
jp-charras 1b62fdae92 Fixes: lp:1623060 (EEschema page orientation is not retrieved when compiled with KICAD_USE_SCH_IO_MANAGER=ON)
https://bugs.launchpad.net/kicad/+bug/1623060
2016-09-13 19:48:43 +02:00
Maciej Suminski 516510774c Fixed ratsnest for nodes surrounded with zones 2016-09-13 17:13:42 +02:00
Maciej Suminski b00ca19f41 Deboostified ratsnest algorithm. 2016-09-13 14:58:33 +02:00
Maciej Suminski 64f04ab3e6 Merge branch 'undobuffer_refactor'
- BOARD_COMMIT class.
Wrapper around undo buffer to simplify storing changes. Also performs
all the necessary updates (ratsnest, view) once anything changes. A good
entry point to introduce an observer interface.

- Removed BOARD_ITEM::Copy(), switched to C++ copy constructors and
operator=.

- BOARD_ITEM_CONTAINER interface.
A generic interface for adding & removing items, base class for MODULE
and BOARD.

- Removed UR_MODEDIT.
Module editor now uses the same UR_* flags as the layout editor. Now,
together with BOARD_COMMIT is the way to unify undo handling code in
tools (no more ugly 'if(m_editModules) {...} else {...}').

- Common code for handling undo buffer in the layout & module editor.
board_undo_redo.cpp and modedit_undo_redo.cpp are merged to
undo_redo.cpp. A lot of redundant code removed.
2016-09-13 10:08:15 +02:00
Maciej Suminski 17806b58f6 Fixed unused variable warnings 2016-09-13 10:06:49 +02:00
Maciej Suminski 03f4a89521 More descriptive method names for RN_NODE 2016-09-13 10:06:25 +02:00
Maciej Suminski 02cfab4266 Display a message when a locked component is not removed 2016-09-12 13:45:57 +02:00
Maciej Suminski c52a9d850b Converted netlist updater to use BOARD_COMMIT
Fixes: lp:1579910
* https://bugs.launchpad.net/kicad/+bug/1579910
2016-09-12 13:45:57 +02:00
Maciej Suminski 3425624510 Compile_Ratsnest() refreshes track labels 2016-09-12 13:45:57 +02:00
Maciej Suminski 3bcbe0dfbd GAL ratsnest code cleanup 2016-09-12 13:45:57 +02:00
Maciej Suminski 0cc2c87ef8 Removed BOARD::AppendNet()
It is handled by BOARD::Add() now.
2016-09-12 13:45:57 +02:00
Maciej Suminski 77f74646af Auto update ratsnest data on net change 2016-09-12 13:45:57 +02:00
Maciej Suminski d33672cce7 Added missing break 2016-09-12 13:45:57 +02:00
Maciej Suminski 828f28ecca Ratsnest Add()/Remove()/Update() return true on success 2016-09-12 13:45:57 +02:00
Maciej Suminski 790b6eaeb9 Fixed ratsnest updates on undo/redo 2016-09-12 13:45:57 +02:00
Maciej Suminski 694aa7ff5b Handle pad autonumbering when the number set is empty. 2016-09-12 13:45:57 +02:00
Maciej Suminski 6481ff75c9 Changed one of COMMIT::Stage() methods to COMMIT::Modified() 2016-09-12 13:45:57 +02:00
Maciej Suminski 267f01fa69 Code formatting (BOARD_NETLIST_UPDATER) 2016-09-12 13:45:57 +02:00
Maciej Suminski 029e275aa0 Unselect modified component before replacing by the FP editor. 2016-09-12 13:45:57 +02:00
Maciej Suminski b0b64ac964 Fixed freeze after updating a footprint using the FP editor. 2016-09-12 13:45:57 +02:00
Maciej Suminski edf64afa3e Fixed freezes after appending a board. 2016-09-12 13:45:57 +02:00
Maciej Suminski 65b1225231 Added CHT_DONE flag to COMMIT::Stage to skip add/remove step 2016-09-12 13:45:57 +02:00
Maciej Suminski 6701b80f77 Converted global deletion, global text size setting & module exchange to BOARD_COMMIT. 2016-09-12 13:45:57 +02:00
Maciej Suminski 91ea4242ca Fixed freeze after adding a module 2016-09-12 13:45:57 +02:00
Maciej Suminski 303a6928ab Changed pointEditorUpdate to editModifiedSelection. 2016-09-12 13:45:57 +02:00
Maciej Suminski ad1111748e Removed 'undo inhibit' in EDIT_TOOL 2016-09-12 13:45:57 +02:00
Maciej Suminski 86895822b7 BOARD_COMMIT retracts changes in reversed order 2016-09-12 13:45:57 +02:00
Maciej Suminski 5a1f52bf30 Modified tools to use BOARD_COMMIT. 2016-09-12 13:45:57 +02:00
Maciej Suminski 5c0605f6dc Mute a few warnings 2016-09-12 11:50:06 +02:00
Maciej Suminski 32c4bec31c Implemented BOARD_COMMIT::Revert() 2016-09-12 11:50:06 +02:00
Maciej Suminski 39d5cd2aca Unified BOARD::Duplicate() 2016-09-12 11:50:06 +02:00
Maciej Suminski 74d53e517c VIEW_GROUP objects redraw itself after a change 2016-09-12 11:50:06 +02:00
Maciej Suminski 86b906463f Fixed an assert in 'Create array' dialog 2016-09-12 11:50:06 +02:00
Maciej Suminski acd7214586 Moved commit.h to 'include' directory 2016-09-12 11:50:06 +02:00
Maciej Suminski c4be379b31 Modified properties dialog to take advantage of BOARD_COMMIT class. 2016-09-12 11:50:06 +02:00
Maciej Suminski 38177b70b9 Comments for COMMIT class 2016-09-12 11:50:06 +02:00
Maciej Suminski 08d15a9961 BOARD_COMMIT::Revert() marked as not tested 2016-09-12 11:50:06 +02:00
Maciej Suminski f1b37109e3 BOARD_COMMIT code cleaning
Moved a few conditionals to scopes where they can be executed.
Simpler way to create ITEM_PICKERs.
2016-09-12 11:50:06 +02:00
Maciej Suminski c7ce82a4bf BOARD_COMMIT creates only one copy of a modified module 2016-09-12 11:50:06 +02:00
Maciej Suminski 992ca6e7c7 Fixed removal function in BOARD_COMMIT. 2016-09-12 11:50:06 +02:00
Maciej Suminski 2ab7196035 Reenabled and corrected BOARD_COMMIT::Revert(). 2016-09-12 11:50:06 +02:00
Maciej Suminski 497fb31ae0 BOARD_COMMIT can be constructed using a PCB_BASE_FRAME*. 2016-09-12 11:50:06 +02:00
Maciej Suminski b25c407576 Rebuild the old ratsnest model only if GAL is inactive. 2016-09-12 11:50:06 +02:00
Maciej Suminski 940765f4b3 COMMIT class: removed m_committed flag, added clear() and Empty() methods. 2016-09-12 11:50:06 +02:00
Maciej Suminski b815ea7865 Removed remaining m_editModules flags. 2016-09-12 11:50:06 +02:00
Maciej Suminski b8350f037b COMMIT: Added an interface to store items that already have a copy created. 2016-09-12 11:50:06 +02:00
Maciej Suminski 0223425d30 COMMIT: changed BOOST_FOREACH to for. 2016-09-12 11:50:06 +02:00
Maciej Suminski 9861b35707 EDIT_TOOL::hoverSelection() works with current selection. 2016-09-12 11:50:06 +02:00
Maciej Suminski dac7c5aa1f Store parent object when creating a COMMIT. 2016-09-12 11:50:06 +02:00
Maciej Suminski b661993427 Removed SELECTION_TOOL::EditModules()
as there is already PCB_TOOL::SetEditModules() and
SELECTION_TOOL::m_editModules shadows PCB_TOOL::m_editModules.
2016-09-12 11:50:06 +02:00
Tomasz Wlostowski a5b7a7ca0a Changed DuplicateAndAddItem() to parametrized Duplicate(). 2016-09-12 11:50:06 +02:00
Tomasz Wlostowski 1924507001 Added a PCB_TOOL subclass. 2016-09-12 11:50:06 +02:00
Tomasz Wlostowski 9588a7974c Added classes COMMIT & BOARD_COMMIT. 2016-09-12 11:50:06 +02:00
Maciej Suminski ff6bdeee4b Removed a number 'if(m_editModules)' sections from pcbnew tools. 2016-09-12 11:50:06 +02:00
Maciej Suminski c78faec247 SetLastEditTime() upon creating UR_CHANGED entry in undo buffer. 2016-09-12 11:50:06 +02:00
Maciej Suminski 0bf553b06c Recompute local coordinates when an object is added to MODULE. 2016-09-12 11:50:06 +02:00
Maciej Suminski b5bfa14057 Removed unused EDA_ITEM::m_Image field. 2016-09-12 11:50:06 +02:00
Maciej Suminski a5d32bbd63 Moved method descriptions from .cpp to .h. 2016-09-12 11:50:06 +02:00
Maciej Suminski 1dd43d1d98 Unified undo buffer handling code for PCB & module editor.
Replaced UR_MODEDIT with UR_CHANGED.
2016-09-12 11:50:06 +02:00
Maciej Suminski b0a191ce3d Refactored TestForExistingItem() 2016-09-12 11:50:06 +02:00
Maciej Suminski b897c5f290 BOARD_ITEM_CONTAINER class. 2016-09-12 11:50:06 +02:00
Maciej Suminski 09e0311d4e Replaced Copy() method with operator=. Removed Copy() where default copy ctor was enough. 2016-09-12 11:50:06 +02:00
Maciej Suminski 2c08ff1d59 Switched to default copy ctor and/or operator= for BOARD, BOARD_CONNECTED_ITEM, DRAWSEGMENT & EDGE_MODULE. 2016-09-12 11:50:06 +02:00
Maciej Suminski ec4531948f Move all SetParent() calls to a single location in BOARD::Add(). 2016-09-12 11:50:06 +02:00
Maciej Suminski f95628c132 Switched to default constructor and operator= for EDA_TEXT. 2016-09-12 11:50:06 +02:00
Ian Roth 7ad2f37391 Add %L formatter to worksheets to print layer name. 2016-09-10 14:23:59 -04:00
Eldar Khayrullin 7edb6c2d13 Fix style of gost page layouts in accordance with GOST 2.104-2006.
Fixes reverted commit 16d03fd
2016-09-10 12:28:33 -04:00
Chris Pavlina ad83a68be7 Revert "Fix style of gost page layouts in accordance with GOST 2.104-2006."
This reverts commit 16d03fdd8a.
2016-09-10 11:32:20 -04:00
Eldar Khayrullin 16d03fdd8a Fix style of gost page layouts in accordance with GOST 2.104-2006. 2016-09-10 11:30:59 -04:00
jp-charras 5710681f7e Fixes: lp:1622184 (pl-editor doesn't save text thickness when it is not the default value)
https://bugs.launchpad.net/kicad/+bug/1622184
2016-09-10 17:16:48 +02:00
Chris Pavlina 7318238daa Update version string formatting after git migration
It is no longer necessary (or sensible) to include a simulated bzr
revision number, and we can reliably get a branch name now. Therefore,
the new version strings look like:

(2016-08-26 revision 67230ac)-master
 |                   |        |
 |                   |        branch name, "HEAD" if not on a branch,
 |                   |          or "unknown" if no .git present
 |                   |
 |                   abbreviated commit hash, or no-git if no .git
 |                     present
 |
 date of commit, or date of build if no .git present

Signed-off-by: Chris Pavlina <pavlina.chris@gmail.com>
2016-09-09 20:19:54 -04:00
jp-charras cc3a93b2d7 Fixes: lp:1621956 (pl-editor: button 'Show title block in edit mode' does nothing)
https://bugs.launchpad.net/kicad/+bug/1621956
2016-09-09 20:29:21 +02:00
Maciej Suminski e25630b7ac UI policy update
Added a note about Mark's wxFormBuilder repository and
'internationalize' checkbox in wxFB.
2016-09-09 09:38:56 -04:00
Dick Hollenbeck 2adfb09d0e Pcbnew: display unconnected net count in DRC dialog. 2016-09-08 14:17:37 -04:00
Tomasz Włostowski 0b8ab2f73d router: fixed incorrect clearance computation in highlight collisions mode.
Fixes: lp:1621186

https://bugs.launchpad.net/kicad/+bug/1621186
2016-09-08 10:30:02 -04:00
Chris Pavlina 21b76d0837 eeschema: short-circuit disambiguation for {sheet pin, sheet} 2016-09-08 08:31:09 -04:00
jp-charras c8cf78398b Gerbview: fix a crash when reading polygons with arcs.
Fix a very minor other issue (due to a minor bug in wx 3.1)
Displays the full graphic layer name of the selected item in message panel (instead of just the graphic layer number)
2016-09-07 10:28:16 +02:00
José Ignacio Romero cd976d36b7 Use a symmetrical clip plane for the orthographic projection 2016-09-07 01:12:01 -04:00
José Ignacio Romero df40159ce7 Pixel perfect panning for the 3D viewer
Use the correct math to unproject the mouse movement from screen space
to the Z=0 plane on the camera space. This handles both perspective
and orthographic projection at any window size or zoom level.
2016-09-06 20:10:51 -04:00
Tomasz Wlostowski 03d372a0ec Fixed an assertion triggered upon line simplification (PNS). 2016-09-06 16:40:40 +02:00
Maciej Suminski f1e2a2c4c1 Corrected debug information display call. Removed an unused variable. 2016-09-06 16:27:35 +02:00
decimad 94aaa47583 Add Remove overloads for specific item types, split removal into index-handling and lifetime-handling (not 100% correct yet, since the index is defactor lifetime-owner, it will be later.) 2016-09-06 16:06:06 +02:00
decimad 94fae5d6a1 fix eager dynamic allocation in PNS::NODE::addLine
move implementation into PNS::NODE::Add since lines will never be part of the index itself
2016-09-06 16:06:06 +02:00
decimad 96a3145543 use unique_ptr at client <-> pns-router border, to document the pns router is taking ownership
add overloads for NODE::Add( ... ) taking pointers to specific item types (retain old private add-Functions, they will come in handy later)
LINE overloads now take by reference, to document their special treatment.
updated code throughout affected by these changes
2016-09-06 16:06:06 +02:00
decimad 2aef1a4568 use unique_ptr to document ownership (PNS::LINE_PLACER) 2016-09-06 16:06:06 +02:00
decimad 4770be0920 Make the segment-ref container a true member of PNS::LINE
improve const correctness
return segment container by ref
change client code accordingly
2016-09-06 16:06:06 +02:00
decimad 2faca77adf use unique_ptr to document ownership (PNS::ROUTER) 2016-09-06 16:06:06 +02:00
decimad 6c749e0ba8 Remove PNS_ prefix from most types inside namespace PNS 2016-09-06 16:06:06 +02:00
decimad 4cf44d9725 Rename pns item kind constants in preparation for renaming pns classes 2016-09-06 16:06:06 +02:00
decimad de6281e977 Move PNS router code into namespace PNS
update copyright messages
2016-09-06 16:06:06 +02:00
Chris Pavlina 378def4734 3D viewer: suggest correct extension when saving image
Fixes: lp:1620102
* https://bugs.launchpad.net/kicad/+bug/1620102
2016-09-06 01:15:59 -04:00
Chris Pavlina 20aca7d7bb Fix direction of ctrl+scroll in 3D viewer
Fixes: lp:1620453
* https://bugs.launchpad.net/kicad/+bug/1620453
2016-09-06 00:48:27 -04:00
Nick Østergaard caafcde585 Add KICAD_ prefix to build switches
KICAD_ prefix was added to the USE_OCE and USE_SCH_IO_MANAGER build
switches together with a small description to the devdocs from
compiling.md.
2016-09-05 08:46:01 -04:00
jp-charras b63f2f81b7 Fixes: lp:1619436
https://bugs.launchpad.net/kicad/+bug/1619436
Eeschema crashes when selecting a text editor from the REC dialog. (Linux Only)
It happens only if a text editor was never selected in Kicad.
2016-09-05 09:02:15 +02:00
Chris Pavlina 9740d5e433 Fix nonstandard, unsigned OpenMP loop counter
OpenMP does not yet permit unsigned loop counters. Most compilers seem
to allow them anyway, but a few have been seen to complain.

Mistake introduced in:
    commit 82ed0fde32
    Author: Chris Pavlina <pavlina.chris@gmail.com>
    Date:   Sun Aug 28 02:05:49 2016 -0400

    Fix shared data access in raytracer, tidy up render loop
2016-09-04 21:41:09 -04:00
Nick Østergaard 76f78bb48b Remove unused version info
USE_FP_LIB_TABLE is not used anywhere in the code when grepping
2016-09-04 19:14:26 -04:00
Nick Østergaard c784d45ed7 Add new development build swtiches to version info
Add:
* KICAD_USE_SCH_IO_MANAGER
* KICAD_USE_OCE
2016-09-04 19:13:05 -04:00
Jon Neal 049e9909ac Updated the compiling instructions to remove bzr and talk about the OCE flag. 2016-09-04 18:42:11 -04:00
Jon Neal 918f5514f8 Updated INSTALL.txt to list new dependncies. Fixed a dead link to documentation as well. 2016-09-04 18:34:29 -04:00
Wayne Stambaugh 24f6c4be21 Eeschema: add code to plugin manager to load a symbol from a library. 2016-09-03 14:28:17 -04:00
Wayne Stambaugh cbcb3b896b Fix incorrect string translation macros.
* Replace _T() with _() for translatable strings.

* Don't translate debug messages.

* Don't translate copyright symbol.
2016-09-03 12:10:49 -04:00
Wayne Stambaugh f477cc958c Eeschema: PART_LIB object clean up.
* Rename redundant function PART_LIB::GetEntry() to PART_LIB::GetAlias() which
  is more descriptive and move the GetAlias() function which was nothing more
  than a call to GetEntry().
2016-09-02 19:40:18 -04:00
Wayne Stambaugh 38e7debdec Merge Cirilo's OCE plugin branch. 2016-09-01 16:36:45 -04:00
Chris Pavlina 4b6d28333e Revert "Memoize SHAPE_LINE_CHAIN bounding box computation"
This reverts commit 30566de69a, which
caused some issues in PNS.
2016-09-01 12:09:06 -04:00
Maciej Suminski fcedef836a Revert "Do not use double component primitives in Spice netlist exporter"
This commit creates more issues than resolves. It could happen that
there are components with different reference types (e.g. U1 and IC1)
that would be later converted to X1, causing a conflict.
2016-08-31 11:51:17 +02:00
Wayne Stambaugh 9287b42648 Revert commit 67230ac8e7. 2016-08-30 09:04:25 -04:00
Maciej Suminski 81e015036e Fixes for drawing color labels in simulator's signal list 2016-08-30 14:25:59 +02:00
Maciej Suminski f954abae4e Comments for NETLIST_EXPORTER_PSPICE 2016-08-30 14:25:59 +02:00
Maciej Suminski 67573f15be Do not use double component primitives in Spice netlist exporter
Fixes: lp:1617768
* https://bugs.launchpad.net/kicad/+bug/1617768
2016-08-30 14:25:56 +02:00
Johannes Maibaum b87bac22c7 Simulator: Fix probe and tune cursors on OSX. 2016-08-30 10:48:40 +02:00
jp-charras 69e4231303 Sch editor and Simulator: close the simulator frame when the schematic editor is closed, to avoid crash, due to the fact the simulator can try to access to a no more existing frame.. 2016-08-29 19:47:08 +02:00
jp-charras 26b1c732de Simulator: add simulator icon, and colored icons to identify more easily traces in trace list and cursor list. 2016-08-29 11:39:54 +02:00
jp-charras 440f8c8b69 Fix an issue in DRC min via drill value, created in git commit 3a92db4312 2016-08-28 21:26:51 +02:00
Chris Pavlina 82ed0fde32 Fix shared data access in raytracer, tidy up render loop
Render loop lost track of which blocks had been rendered due to a
synchronization issue. Specifically, std::vector<bool> is special-cased
as a bitfield and so is pretty much guaranteed not to be atomic unless
synchronized externally.

Also:

- Clean up types of a few variables
- Clean up openmp sharing type of variables (may result in better
  optimization)
- Replace shared rendered block count with an openmp reduction (results
  in fewer locks)

Fixes: lp:1608289
* https://bugs.launchpad.net/kicad/+bug/1608289
2016-08-28 02:13:55 -04:00
Niki Guldbrand 67230ac8e7 Keep Source tree clean
* Move all generated files to the build tree during build so the source
  tree is kept clean.

Signed-off-by: Niki Guldbrand <niki.guldbrand@gmail.com>
2016-08-26 17:25:12 -04:00
Niki Guldbrand 80b52c8a5d Cleanup after switch to Git
* Remove the .gitconfig file, it's only purpose was to load the
  ignore file from bzr which has now been renamed to .gitignore.

Signed-off-by: Niki Guldbrand <niki.guldbrand@gmail.com>
2016-08-26 07:15:53 -04:00
jp-charras 36ff4b5e93 Merge branch 'master' of git+ssh://git.launchpad.net/kicad 2016-08-25 09:37:20 +02:00
jp-charras 9d5300b284 Fix: Pcbnew net class editor is chopping off net class names
Fixes: lp:1616599
* https://bugs.launchpad.net/kicad/+bug/1616599
2016-08-25 09:35:35 +02:00
Maciej Suminski ca499b80e1 Fixed wxLogTrace() calls in PNS
Fixes: lp:1616702
* https://bugs.launchpad.net/kicad/+bug/1616702
2016-08-25 09:24:55 +02:00
Simon Richter 91e953868a DRC: Test all segments
The DRC also runs per-segment tests, not just segment-segment, so the last
segment needs to be tested as well, with an empty list of segments to test
against.
2016-08-24 22:17:39 -04:00
Simon Richter 3a92db4312 DRC: Add test for via drill size
This test is only run when the via size itself is acceptable, to avoid
bigger changes to the codebase.
2016-08-24 22:17:21 -04:00
Simon Richter 260b0f6b5f Via properties: apply microvia settings to microvias 2016-08-24 22:16:21 -04:00
Jon Neal 532a5fb827 Small grammar fix 2016-08-24 16:18:04 -04:00
jp-charras fdd434244c dialog footprint properties: better tool-tips 2016-08-24 18:20:20 +02:00
jp-charras d0fbd32bee dialog edit footprint properties: Generate an error message if a parameter is incorrect.
(previously when happens, no message but the dialog cannot be closed)
2016-08-24 17:18:51 +02:00
jp-charras 4a3cb050ed Fix incorrect management of C locale in vrml plugin 2016-08-24 14:37:30 +02:00
Wayne Stambaugh e1ab68638f Renamed .bzrignore to .gitignore. 2016-08-22 14:50:23 -04:00
Maciej Suminski 30e3097484 Findngspice.cmake: Refined build instructions 2016-08-22 16:08:45 +02:00
Maciej Suminski cf537023c9 Findngspice: add a message explaining the current libngspice status 2016-08-22 14:39:35 +02:00
Cirilo Bernardo b656a8180a Added 3D plugin for OCE; this plugin is activated by -DUSE_OCE=ON 2016-08-22 15:50:38 +10:00
jean-pierre charras 7e3aedda82 Slightly modify the way DIALOG_SIM_SETTINGS m_settingsDlg is created in SIM_PLOT_FRAME frame: for an obscure reason, if it is created in ctor SIM_PLOT_FRAME, m_settingsDlg has an annoying issue on Windows: when shown, the parent SIM_PLOT_FRAME is sent to the background. When created outside the ctor, this issue is gone. 2016-08-20 19:51:33 +02:00
jean-pierre charras 2456db3817 Simulator: Make a few strings translatable. 2016-08-20 17:37:51 +02:00
jean-pierre charras 13cfe74956 Simulator dialogs: fix minimal sizes and best sizes. 2016-08-20 17:25:51 +02:00
jean-pierre charras c0b1e4cd38 Do not allow spaces in component name (value field) in component library editor, in dialogs (Edit field, Create component).
In component libraries, a space in name breaks the library, and is not allowed.
2016-08-19 18:42:39 +02:00
Maciej Suminski 7ea120c2a1 Spice model editor by default looks for libraries in the project directory when there is no library assigned 2016-08-19 17:33:26 +02:00
Maciej Suminski e1d20dd6e3 NETLIST_EXPORTER_PSPICE skips removed pins when processing a list of sorted pins.
NETLIST_EXPORTER marks removed duplicates by setting them to NULL in m_SortedComponentPinList vector.
2016-08-19 17:32:30 +02:00
jean-pierre charras ea59ce40e1 sch_legacy_plugin.cpp: fix compil warnings about incorrect return type. 2016-08-19 17:31:46 +02:00
Maciej Suminski 42f6cf33a1 Unbind REPORTER from NGSPICE before deleting 2016-08-19 16:39:46 +02:00
Maciej Suminski fe30985742 Do not delete the NGSPICE singleton 2016-08-19 16:33:31 +02:00
Maciej Suminski 2a6b8f153b NGSPICE as a singleton
One cannot call ngSpice_Init() twice without unloading the dll. When calling
ngSpice_Init, we pass a pointer to a NGSPICE instance and thus it cannot be changed.
When any of the callback function is called with a stale pointer everything crashes.
2016-08-19 15:51:19 +02:00
Wayne Stambaugh bcfce68daa Fix debug build warning due to improper debug macro. 2016-08-19 08:53:06 -04:00
jean-pierre charras 9f46d83175 Gerbview: locate item now does not take in account not visible layers. Remove an unused file
3d viewer: Remove a few ToUTF8() bad  usage (replaced by GetData() )
2016-08-19 09:45:59 +02:00
Wayne Stambaugh eaa7f3f114 Eeschema: implement schematic I/O plugin symbol library parser.
* Write SCH_LEGACY_PLUGIN_CACHE object for handling the legacy symbol library
  file format.

* Write legacy symbol library file parser.

* Write code to transfer cache to PART_LIB object so existing library save
  code can be used for round trip testing.  This is temporary until Eeschema
  is updated to use the plugin for library management rather than PART_LIB.

* Add LIB_XXXX object helper functions where there was no way to set the member
  variables of an object.

* Give the cache object friend status to some object where there are incredibly
  byzantine ways of setting text in LIB_XXXX objects.
2016-08-18 19:23:10 -04:00
Maciej Suminski cac571c056 Initialize ngspice only once 2016-08-18 18:10:00 +02:00
Maciej Suminski ad3c2ac4ea NGSPICE_NETLIST_EXPORTER: Display a message if there is a missing library. Wrap library file names in quotes. 2016-08-18 18:06:26 +02:00
Maciej Suminski 7f5bce3772 More robust condition for checking sufficient space in CACHED_CONTAINER
Having enough space is not enough, we need a continuous block of memory.
2016-08-18 17:18:13 +02:00
Maciej Suminski 630d5e04fe Ratsnest NODE stores its parents in a set instead of a list
It happens that the same parent is assigned multiple times, but then removed once, causing ratsnest artifacts.
2016-08-18 17:17:52 +02:00
Wayne Stambaugh 5f2099f0d2 Add simulation demo folder to install target list. 2016-08-17 15:11:43 -04:00
Maciej Suminski 78050c05e2 Changed PNS logging routine to wxLogTrace 2016-08-17 16:00:21 +02:00
Maciej Suminski 9f0b42cb35 pns: fixed a few memleaks & conditional jumps depending on uninitalized variables 2016-08-17 15:09:48 +02:00
jean-pierre charras 7909de6127 Gerbview: better management of d_codes list in toolbars. 2016-08-17 10:19:10 +02:00
jean-pierre charras 3f1a90c8a4 3D viewer; Fix a few incorrect use of ToUTF8() in log and error messages. Only noticeable when messages contain non ASCII7 chars. 2016-08-17 09:37:51 +02:00
Chris Pavlina 910cafe72e FUTURE_FORMAT_ERROR: don't nest errors unnecessarily 2016-08-16 22:02:05 -04:00
Simon Richter bfb6e0bbb2 Convert remaining occurences of stri[n]cmp to str[n]casecmp.
This also reverses the substitution logic if strcasecmp is missing (config.h.cmake)
2016-08-16 10:27:09 +02:00
jean-pierre charras f1226afc89 Gerbview: support of %TA.AperFunction (aperture attribute) and better support of %TO (currently work in progress) object attribute. 2016-08-16 12:56:20 +02:00
Maciej Suminski 2f4c9b7263 Do not mark wxMathPlot docs as the main Doxygen page 2016-08-16 09:49:39 +02:00
jean-pierre charras 01d3c72dda Cosmetic enhancement: add a dismiss icon to clarification menu "title" (the "title" is also the close menu command) 2016-08-15 20:22:54 +02:00
Maciej Suminski 293849256e Corrected the kicad_pcb file format revision to the new standard 2016-08-15 17:55:36 +02:00
Maciej Suminski 7e94e5282a Changed PNS debug output to use wxLogTrace 2016-08-15 17:16:54 +02:00
Maciej Suminski 41b75f0105 Added a missing header in netlist_exporter_spice.h 2016-08-15 17:16:54 +02:00
Maciej Suminski 0ef866ee74 Code formatting 2016-08-15 17:16:53 +02:00
Tomasz Wlostowski f0adbd757c router: added missing files 2016-08-15 17:16:51 +02:00
Tomasz Wlostowski a53ea81794 P&S: factor out Kicad-dependend PNS_ROUTER::SnapToItem() to the PNS_TOOL_BASE class 2016-08-15 17:16:51 +02:00
Tomasz Wlostowski 4d134e5522 fix direction-depending DP tuning glitch 2016-08-15 17:16:51 +02:00
Tomasz Wlostowski b52eb441a1 router: fix compilation warnings 2016-08-15 17:16:50 +02:00
Tomasz Wlostowski 456c02c800 router: multiple fixes - fixed crash when trying to drag a locked via - prompt when the user attempts to drag a locked via/segment - removed remains of PICKED_ITEMS_LIST from the PNS_ROUTER class 2016-08-15 17:16:50 +02:00
Tomasz Wlostowski 2f3950e991 added missing boost headers 2016-08-15 17:16:50 +02:00
Tomasz Wlostowski e5524832a9 pcbnew: added diff pair gap & width to Design Rules dialog & PCB file format. 2016-08-15 17:16:49 +02:00
Tomasz Wlostowski bcf7990bf9 P&S: support for 45-degree style length tuning meanders 2016-08-15 17:16:49 +02:00
Tomasz Wlostowski a2ac1cd087 P&S: cleaner placement of DP segments/vias. Speed improvements too. 2016-08-15 17:16:49 +02:00
Tomasz Wlostowski 4cbb0aebfd P&S: support for custom visitor objects in PNS_NODE::QueryColliding() 2016-08-15 17:16:49 +02:00
Tomasz Wlostowski 2b32b6f72e P&S: support for trace & via locking 2016-08-15 17:16:48 +02:00
Christian Gagneraud 7e0caf7abe [pns] Make the placer algo draw debugging stuff by relying on a new PNS_DEBUG_DECORATOR, this removes a reversed dependency b/w PNS_ROUTER and PNS_ALGO Tom: some rework of the patch 2016-08-15 17:16:48 +02:00
Christian Gagneraud e9a2cb0642 [pns] Remove unnecessary includes of KiCad colors.h 2016-08-15 17:16:48 +02:00
Tomasz Wlostowski 0700178d07 P&S: enable delete & backspace shortcuts while router is active 2016-08-15 17:16:47 +02:00
Tomasz Wlostowski 9c8bdcc894 P&S refactor: removed most of Kicad-dependent code from PNS internal classes 2016-08-15 17:16:47 +02:00
Tomasz Wlostowski df50a10510 VIEW: replace boost with std 2016-08-15 17:16:45 +02:00
Maciej Suminski 43d93682a2 Fix locale in NGSPICE methods using LOCALE_IO instead of setlocale.
More information: https://lists.launchpad.net/kicad-developers/msg25763.html
2016-08-15 15:52:07 +02:00
jean-pierre charras 00b9ac7cc3 Findngspice.cmake: add missing search paths for ngspice default install on Windows. 2016-08-15 15:27:24 +02:00
Maciej Suminski 6e4d6c445c Add NGSPICE_ROOT_DIR parameter for libngspice CMake script 2016-08-15 14:39:26 +02:00
Maciej Suminski 75f8b20493 libngspice is linked at compile time 2016-08-15 13:52:13 +02:00
Maciej Suminski 9714ece53f Initialize bestStep (wxMathPlot) 2016-08-15 10:53:36 +02:00
Simon Richter eec632a651 Remove definition of log10(double) in wxMathPlot widget 2016-08-15 10:19:42 +02:00
jean-pierre charras 5ed19b6e82 Dialogs for simulator: cosmetic enhancements, make them translatable and resizable. Remove 2 printf used in debug. 2016-08-15 09:53:15 +02:00
jean-pierre charras cc2b3583cd Fix incorrect configs in simulation demos. 2016-08-13 16:46:06 +02:00
Maciej Suminski 3204b14254 Updated the r5 road map (integrated simulator) 2016-08-12 16:58:39 +02:00
Maciej Suminski a6cdf536b9 Added KICAD_SPICE option description in compiling.md 2016-08-12 16:00:35 +02:00
Maciej Suminski 02c404ab10 Removed unnecessary *.orig files for dialogs 2016-08-12 15:58:36 +02:00
Maciej Suminski 497b2a9442 CMake module for libngspice 2016-08-12 15:56:51 +02:00
jean-pierre charras 6e5628ceaf Avoid simulator crash if the simulation was not run, when using most of main menu commands, due to a null pointer not tested. 2016-08-12 15:36:43 +02:00
Maciej Suminski 8a8dc5fbbb Added a comment to fixes_alias git config file 2016-08-12 11:47:07 +02:00
Maciej Suminski 6c467a5041 Added a helper git config file to simplify marking bugfixes in commits
To enable the config file run (in the root source directory):
git config --add include.path "$(pwd)/helpers/git/fixes_alias"

Then after commiting a change, you can decorate the commit with appropriate lines by:
git fixes 123456
2016-08-12 11:26:15 +02:00
jean-pierre charras dd395a6854 Fix deprecated and shadowed var compil warnings 2016-08-12 11:00:58 +02:00
jean-pierre charras 42f9be4019 uncrustify mathplot.cpp, make debug strings not translatable, and remove not compilable debug lines (due to changes in internal code). No actual change in code. 2016-08-12 10:10:33 +02:00
Wayne Stambaugh a4570f74bb Pcbnew: fix several auto save file issues.
* When Pcbnew is launched in the stand alone mode with no board file command
  line option, the project path is set to the current working directory.  The
  user may not have write access to the current working directory which would
  cause the auto save to generate an error.  If the user does not have write
  access to the current working directory, set the path to a platform specific
  temporary path that the user has write permission.

* When Pcbnew is launched in the stand alone mode with no board file command
  line option, the default BOARD object has no file name.  Set the file name
  to "noname.kicad_pcb" to fix incorrect auto save file name and set the path
  to the user's platform specific document folder.

* Delete orphaned auto save files when closing without saving due to broken
  auto save file generation logic which prepended the file name with "$" rather
  than "_autosave-".

* Fixes: lp:1596382
2016-08-11 15:13:47 -04:00
Chris Pavlina 30566de69a Memoize SHAPE_LINE_CHAIN bounding box computation
For a specific project+system combination, this gives a 38% speedup on
the pcbnew side of netlist sync.
2016-08-11 09:34:58 -04:00
Maciej Suminski 5b2f375ffb ngspice simulator 2016-08-11 15:04:55 +02:00
Maciej Suminski 0315499137 Added a missing library 2016-08-11 14:43:25 +02:00
Maciej Suminski e4c7b4af4f Corrected simulation demos 2016-08-11 14:42:22 +02:00
Maciej Suminski 18e99fa30f Fixed a crash with certain shared library versions 2016-08-11 14:42:21 +02:00
Maciej Suminski 6b3584ce9b fxup system ngspice.h 2016-08-11 14:42:19 +02:00
Maciej Suminski 6bfdfd5226 Look for libraries in the project path 2016-08-11 14:42:19 +02:00
Maciej Suminski 0cb1e80e00 Activate eeschema on tune/probe 2016-08-11 14:42:19 +02:00
Maciej Suminski dfb5c6bfdd Do not update values if simulation is rerun Otherwise sometimes the signal list might be cleared and a new list is not yet available, resulting in loss of signals and cursors. 2016-08-11 14:42:19 +02:00
Maciej Suminski d15eef06f9 Removed redundant debugging info 2016-08-11 14:42:18 +02:00
Maciej Suminski 2c29133c57 Use system ngspice.h file 2016-08-11 14:42:18 +02:00
Maciej Suminski 557f9270c7 wxMathPlot basic code formatting 2016-08-11 14:42:18 +02:00
Maciej Suminski 0667b7ba63 Fixed ngspice freeze when there is an error in the simulated netlist Does not work with current ngspice head, it has to be compiled from the official master branch. 2016-08-11 14:42:18 +02:00
Maciej Suminski 8227cd6d80 Do not recreate the simulator every time simulation is run 2016-08-11 14:42:17 +02:00
Maciej Suminski eeeb3e0a9a Simulator code formatting and clean up 2016-08-11 14:42:17 +02:00
Maciej Suminski 957c6ec417 Removed hard limit for ngspice netlist 2016-08-11 14:42:17 +02:00
Maciej Suminski 0a6390701d NGSPICE uses a more convenient function to generate DLL name 2016-08-11 14:42:16 +02:00
Maciej Suminski 46ecfd8139 Resized simulator dialogs 2016-08-11 14:42:16 +02:00
Johannes Maibaum c78462c4f5 sim: Modifications to compile the simulator on OSX. 2016-08-11 14:42:15 +02:00
Maciej Suminski c9a1b45666 Fixed probe & tune cursors under Windows. 2016-08-11 14:42:15 +02:00
jp charras b2f60009a6 wxWidgets 3.1/Win7 fixes 2016-08-11 14:42:15 +02:00
Tomasz Wlostowski 80d8dd7205 sim: default to decade frequency sweep for ac analysis 2016-08-11 14:42:15 +02:00
Tomasz Wlostowski 1930cd4d66 sim: display labels on current scale when only currents are added to transient plot 2016-08-11 14:42:14 +02:00
Maciej Suminski e452992a6c Cursor centering fix 2016-08-11 14:42:14 +02:00
Maciej Suminski 2b041425e5 Resized Spice model dialog 2016-08-11 14:42:14 +02:00
Maciej Suminski ca36f15fee Temporary disable cursor centering 2016-08-11 14:42:14 +02:00
Maciej Suminski 6d7a7a3233 KICAD_SPICE CMake flag 2016-08-11 14:42:13 +02:00
Maciej Suminski 22f5bceda0 Removed obsolete sim demo folder. 2016-08-11 14:42:13 +02:00
Maciej Suminski 2c576afdf3 Fixed menu entries 2016-08-11 14:42:13 +02:00
Maciej Suminski ca13dc93b1 Support for simulation workbooks 2016-08-11 14:42:12 +02:00
Maciej Suminski 67e283c3af Removed 'Lock aspect' from wxMathPlot widget context menu 2016-08-11 14:42:12 +02:00
Maciej Suminski 7b81516b61 Fixed SIM_PLOT_FRAME::CurrentPlot() 2016-08-11 14:42:12 +02:00
Tomasz Wlostowski 4ecc17385d sim: more examples 2016-08-11 14:42:12 +02:00
Tomasz Wlostowski b20f941bd0 sim: hopefully final version of plot axis unit/suffix handling. 2016-08-11 14:42:10 +02:00
Maciej Suminski 01d18bad97 Save simulation command directive for every plot 2016-08-11 14:42:10 +02:00
Maciej Suminski 02e4252fcd A few fixes for DIALOG_SIM_SETTINGS 2016-08-11 14:42:10 +02:00
Maciej Suminski fb56420654 Do not store Spice vector names, but regenerate them 2016-08-11 14:42:10 +02:00
Maciej Suminski ed8f555331 Remove plots that are invalid after component removal 2016-08-11 14:42:09 +02:00
Maciej Suminski 672fd76995 Remove tuners for components that were removed 2016-08-11 14:42:09 +02:00
Maciej Suminski 06287e4986 Display an error message for unannotated schematics 2016-08-11 14:42:09 +02:00
Maciej Suminski 741ae10a97 Improved Spice model dialog for sources Now user can specify both DC/AC & transient analysis specifications at once. 2016-08-11 14:42:09 +02:00
Maciej Suminski 53d772989a Store relative library path if possible 2016-08-11 14:42:08 +02:00
Maciej Suminski 39caddd22b Parsing sim command directives 2016-08-11 14:42:08 +02:00
Maciej Suminski 63bdb3995e Fixes for limited view panning 2016-08-11 14:42:08 +02:00
Maciej Suminski dbf0fd6156 Better normalization rules for SPICE_VALUE 2016-08-11 14:42:07 +02:00
Maciej Suminski bf758dce3e Tuners are common for all plots 2016-08-11 14:42:07 +02:00
Maciej Suminski 5772938a71 New cursor shows up in the center, can be dragged by its axis 2016-08-11 14:42:07 +02:00
Maciej Suminski 2f8f92cf0a Closing tabs with middle button click I could not find a way to make tab close button work in wxWidgets.. 2016-08-11 14:42:07 +02:00
Maciej Suminski fccf71aadd Change 'Run Simulation' button icon when simulation is running 2016-08-11 14:42:06 +02:00
Maciej Suminski 8306cd3b9b Fixed tuners layout after a tuner is removed 2016-08-11 14:42:06 +02:00
Maciej Suminski 2740556505 Fix for Spice library parser 2016-08-11 14:42:06 +02:00
Tomasz Wlostowski cf9abef23a demos: some simulation examples [wip] 2016-08-11 14:42:06 +02:00
Tomasz Wlostowski e691565fe3 sim: updated label generation code to match changes in the mathplot api 2016-08-11 14:42:04 +02:00
Tomasz Wlostowski e9609fe19d mathplot: removed some warnings, fixes to labelling code 2016-08-11 14:42:04 +02:00
Maciej Suminski 7d268d2608 Reset scales upon simulation relaunch 2016-08-11 14:42:04 +02:00
Maciej Suminski 9d8b40b93d Reset scales when a plot is removed 2016-08-11 14:42:03 +02:00
Maciej Suminski ba3ce9b566 Fixed tuner autoplacement 2016-08-11 14:42:03 +02:00
Maciej Suminski bc433764fe Fixed layout proportions 2016-08-11 14:42:02 +02:00
Tomasz Wlostowski f4033f776f mathplot: fix freeze in scale ticks calculation 2016-08-11 14:42:02 +02:00
Tomasz Wlostowski 36297f84c3 sim: further locale hacks, fixed plot/welcome message sizing 2016-08-11 14:42:02 +02:00
Tomasz Wlostowski d0e1f2e412 mathplot: silence debugging messages 2016-08-11 14:42:01 +02:00
Tomasz Wlostowski 8e4ae1968f sim: working on improved UX [wip] 2016-08-11 14:42:01 +02:00
Tomasz Wlostowski 2bcd8af25c sim: fix trailing zero removal 2016-08-11 14:42:01 +02:00
Tomasz Wlostowski bba57097b7 sim: use C locale for SPICE simulation. Added error callback 2016-08-11 14:42:01 +02:00
Tomasz Wlostowski 1cb7f665fb sim: tuner slider now located in a nested wxPanel 2016-08-11 14:42:00 +02:00
Tomasz Wlostowski 8c14f2f6b1 sim: working on UX 2016-08-11 14:42:00 +02:00
Tomasz Wlostowski ec1b8be528 sim: fixed build errors & locale issues 2016-08-11 14:41:58 +02:00
Maciej Suminski 7406aad8ea Display current plots using the current axis 2016-08-11 14:41:57 +02:00
Maciej Suminski 5c32e35d27 Minor fixes to wxMathPlot 2016-08-11 14:41:56 +02:00
Maciej Suminski ce59b282d3 Display both axis names in the cursor list 2016-08-11 14:41:56 +02:00
Maciej Suminski 6c53aba680 Validators for Spice model dialog 2016-08-11 14:41:56 +02:00
Maciej Suminski 973a3d7bcb Fixed a crash when a signal was removed 2016-08-11 14:41:56 +02:00
Maciej Suminski 07b451f4b1 Do not draw cursors outside margins 2016-08-11 14:41:55 +02:00
Maciej Suminski cdf758b173 Automatically update cursor coordinates 2016-08-11 14:41:55 +02:00
Maciej Suminski b25781814d Fixed cursors 2016-08-11 14:41:55 +02:00
Maciej Suminski 65a0327e85 Better normalization rules for SPICE_VALUE 2016-08-11 14:41:55 +02:00
Maciej Suminski 65c7520544 Bulletproof Simulation settings dialog 2016-08-11 14:41:54 +02:00
Maciej Suminski 16fec4d73e Strip comas from a Spice value 2016-08-11 14:41:54 +02:00
Maciej Suminski 920cf09ac1 Fixed plot for DC sweep analysis 2016-08-11 14:41:53 +02:00
Maciej Suminski 38810930ec Removed redundant TRACE_* classes 2016-08-11 14:41:53 +02:00
Maciej Suminski dfeb5385f3 Disable current signals in all analyses but transient 2016-08-11 14:41:53 +02:00
Maciej Suminski 806b862a5e Corrected Spice vector name for voltages 2016-08-11 14:41:53 +02:00
Maciej Suminski 114e3638e7 Renamed tabs in Spice model dialog 2016-08-11 14:41:52 +02:00
Maciej Suminski 5fdc32b79a AC analysis plots using linear frequency scale 2016-08-11 14:41:52 +02:00
Maciej Suminski 324d27711a Hide OP & noise analysis, scale settings for AC in settings dialog 2016-08-11 14:41:52 +02:00
Maciej Suminski 0f993ba98c Current probing 2016-08-11 14:41:52 +02:00
Maciej Suminski 6e05d1656b Bugfix for NETLIST_EXPORTER_PSPICE::GetSpiceField() 2016-08-11 14:41:51 +02:00
Maciej Suminski caef84d622 SPICE_SIMULATOR::GetXAxis() 2016-08-11 14:41:51 +02:00
Maciej Suminski 27a7a9b1a5 Spice fields enum values renamed from SPICE_* to SF_* 2016-08-11 14:41:51 +02:00
Maciej Suminski 3ebc2494a7 Minor fix in NETLIST_EXPOTER_PSPICE 2016-08-11 14:41:51 +02:00
Maciej Suminski cf28e843ba Fix for crash when AC simulation is relaunched 2016-08-11 14:41:50 +02:00
Maciej Suminski e5604fee1c SPICE_VALUE bugfix 2016-08-11 14:41:50 +02:00
Maciej Suminski ef45cd696d Refresh plots after simulation is relaunched 2016-08-11 14:41:50 +02:00
Tomasz Wlostowski e8d6a42e1a simulator: working on magnitude/phase plots 2016-08-11 14:41:49 +02:00
Tomasz Wlostowski e5bf70996b eeschema: migrate SIM_PLOT_PANEL to improved wxMathPlot [wip] 2016-08-11 14:41:49 +02:00
Tomasz Wlostowski b9e31f6d3a mathplot: further improvements for simulator [wip] 2016-08-11 14:41:49 +02:00
Tomasz Wlostowski 30c87527da mathplot: slave scale locking [wip] 2016-08-11 14:41:48 +02:00
Tomasz Wlostowski d2f4d5c2fb mathplot: various improvements, added log scale [wip] 2016-08-11 14:41:48 +02:00
Maciej Suminski d869771f04 Display an error message if ngspice DLL is missing 2016-08-11 14:41:48 +02:00
Maciej Suminski 132e30081b Disabled assert for unknown Spice primitives 2016-08-11 14:41:47 +02:00
Maciej Suminski a717194b1e Enable tuner for RLC components only 2016-08-11 14:41:45 +02:00
Maciej Suminski 92a3e405c2 Tuner tool. 2016-08-11 14:41:45 +02:00
Maciej Suminski fead9ca831 TUNER_SLIDER widget 2016-08-11 14:41:44 +02:00
Maciej Suminski 4f9a418694 Moved SPICE_VALUE to a separate source file 2016-08-11 14:41:43 +02:00
Maciej Suminski f62a6425a3 Changed the simulator code license to GPLv3+ 2016-08-11 14:41:43 +02:00
Maciej Suminski 51f0564119 Signals are added using a separate dialog 2016-08-11 14:41:42 +02:00
Maciej Suminski b897af7eb9 Added a few checks for SIM_PLOT_FRAME to improve robustness 2016-08-11 14:41:41 +02:00
Maciej Suminski 3999ff1973 Resized DIALOG_SIM_SETTINGS 2016-08-11 14:41:41 +02:00
Maciej Suminski 6bfe6342fc Simulator fixes for Windows 2016-08-11 14:41:41 +02:00
Maciej Suminski 9acdedcb85 Improved library management in simulator Now it also gathers information from Spice_Lib_File fields 2016-08-11 14:41:40 +02:00
Maciej Suminski 1a6e048afc Pressing Enter accepts changes in Simulation settings dialog 2016-08-11 14:41:40 +02:00
Maciej Suminski 246a43baf0 Spice model editor dialog 2016-08-11 14:41:40 +02:00
Maciej Suminski 3e2061158e SIM_PLOT_FRAME: Do not update plots if the just run a different type of simulation 2016-08-11 14:41:39 +02:00
Maciej Suminski 4dc62e061b SPICE_VALUE class to handle Spice value expressions 2016-08-11 14:41:39 +02:00
Maciej Suminski 428e82ec1a Removed TODO file 2016-08-11 14:41:38 +02:00
Maciej Suminski 63e8e17cce Added missing class declaration in sch_component.h 2016-08-11 14:41:38 +02:00
Maciej Suminski 3a9dcca32f Enum SPICE_FIELD 2016-08-11 14:41:38 +02:00
Maciej Suminski 01f40e258c More elegant way for checking Spice_Netlist_Enabled value 2016-08-11 14:41:37 +02:00
Maciej Suminski 1c74e27366 NETLIST_EXPORTER_PSPICE fix 2016-08-11 14:41:37 +02:00
Maciej Suminski 06463252d7 wxMathPlot: Limited zooming and panning 2016-08-11 14:41:37 +02:00
Maciej Suminski f634cff206 wxMathPlot: Removed mouse help related functions 2016-08-11 14:41:36 +02:00
Maciej Suminski fd08f45bd2 Corrected bounding box calculation in mpLayer 2016-08-11 14:41:36 +02:00
Maciej Suminski a83d4802f9 Load Spice directives from schematics when Sim settings dialog is launched 2016-08-11 14:41:36 +02:00
Maciej Suminski 78526ee913 Additional options for netlist exporter (fix passive values, library include paths) 2016-08-11 14:41:36 +02:00
Maciej Suminski 822f436231 Removed unused DIALOG_SIMULATE_PLOT 2016-08-11 14:41:35 +02:00
Maciej Suminski 6580a355ab Strip 'stdout' & 'stderr' from ngspice log 2016-08-11 14:41:35 +02:00
Maciej Suminski 90b6112c5d Rearranged SIM_PLOT_FRAME, changed console log from wxRichTextCtrl to wxTextCtrl 2016-08-11 14:41:35 +02:00
Maciej Suminski e90fcaa6d9 New type of simulation opens a new plot 2016-08-11 14:41:35 +02:00
Maciej Suminski fe92630f16 Fixes for DC sweep directive generated by Simulator settings dialog 2016-08-11 14:41:34 +02:00
Maciej Suminski ab8c88f10b SIM_TYPE enum 2016-08-11 14:41:34 +02:00
Maciej Suminski ee1adcd92c Fix for noise directive generated by Simulation settings dialog 2016-08-11 14:41:32 +02:00
Maciej Suminski 0da13052dd SPICE_SIMULATOR interface allows to obtain different types of plots (mag, phase, real, imag) 2016-08-11 14:41:31 +02:00
Maciej Suminski 183fb24112 Fixed string for transient simulation directive 2016-08-11 14:41:31 +02:00
Maciej Suminski c5227b7279 Fix: use correct node numbers in noise simulation directive 2016-08-11 14:41:31 +02:00
Maciej Suminski 3c909e2c32 Allow typing zeroes in Simulation settings dialog 2016-08-11 14:41:31 +02:00
Maciej Suminski d055692cf3 Renamed 'Simulate' to 'Simulator' in menu 2016-08-11 14:41:30 +02:00
Maciej Suminski 2b1784cfc6 Simulation settings combo boxes are filled with net/power source choices 2016-08-11 14:41:30 +02:00
Maciej Suminski 95ca3914ce Fields in simulation settings dialog are treated as invalid when empty 2016-08-11 14:41:29 +02:00
Maciej Suminski 96dcee81fe Modified Spice netlist exporter to run in two passes Now it creates a list of Spice items, so they can be used by other objects, instead of directly dumping them. 2016-08-11 14:41:29 +02:00
Maciej Suminski a2b16ae640 Initial 'Simulation settings' dialog 2016-08-11 14:41:29 +02:00
Maciej Suminski 17294aaf6a Simulation plot CSV & PNG export 2016-08-11 14:41:28 +02:00
Maciej Suminski 1d4fe279db Menu entries to toggle legend & coordinates 2016-08-11 14:41:27 +02:00
Maciej Suminski a35e324c3f Mouse controls in simulation plot made coherent with the rest of KiCad 2016-08-11 14:41:27 +02:00
Maciej Suminski 8c138312fb Cursors are updated on request instead of using update UI events Previously CPU was busy updating the list of cursors even though nothing was changing. 2016-08-11 14:41:27 +02:00
Maciej Suminski e364cfdbac Renamed wxEVT_SIM* events to EVT_SIM* 2016-08-11 14:41:27 +02:00
Maciej Suminski fa4ba69661 Simplified SIM_PLOT_FRAME layout Removed unnecessary panels & sizers, changed wxAuiNotebook to wxNotebook 2016-08-11 14:41:26 +02:00
Maciej Suminski 433f934dc1 Simulation frame displays a list of cursors and their values 2016-08-11 14:41:26 +02:00
Maciej Suminski c4e67c088d wxMathPlot: Fixed a method name (Set->Get), GetName() returns a const reference 2016-08-11 14:41:26 +02:00
Maciej Suminski 9c65d0d281 wxMathPlot: fixed crash when one of its dimensions == 0 2016-08-11 14:41:26 +02:00
Maciej Suminski f3fabeb9fb Right click context menu for signals (including adding cursors) 2016-08-11 14:41:25 +02:00
Maciej Suminski d5ce31dc8e mathplot.h code formatting 2016-08-11 14:41:25 +02:00
Maciej Suminski 88adcc894a SIM_PLOT_FRAME::CurrentPlot() made public 2016-08-11 14:41:25 +02:00
Maciej Suminski cd25e62052 CURSOR does not take mpWindow* in constructor 2016-08-11 14:41:24 +02:00
Maciej Suminski 0b0885f6cd Removed 'Parameters' listbox, expanded 'Signals' list 2016-08-11 14:41:24 +02:00
Maciej Suminski 8b61bb4acc Signals toggling in SIM_PLOT_PANEL 2016-08-11 14:41:24 +02:00
Maciej Suminski ba99dfdabf CURSOR class for simulation plot 2016-08-11 14:41:22 +02:00
Maciej Suminski 24bccb00d6 Menu event handlers for simulation plot frame 2016-08-11 14:41:22 +02:00
Maciej Suminski 51906625ee Replaced sim plotting widget with wxMathPlot 2016-08-11 14:41:21 +02:00
Maciej Suminski 951d16c655 Fixed Spice netlist export options and added a few new flags 2016-08-11 14:41:20 +02:00
Maciej Suminski 5795a2dbf3 Fixed Spice netlist exporter 2016-08-11 14:41:20 +02:00
Maciej Suminski 68e3daec6e Removed probe-related stuff from NETLIST_EXPORTER_PSPICE 2016-08-11 14:41:20 +02:00
Maciej Suminski 50977be7b1 Added TODO 2016-08-11 14:41:20 +02:00
Maciej Suminski 9f3324bac7 Changed the way ngspice is executed Previously it was run in a wxThread, but it did not allow to issue commands while the simulation is running. If you check ngspice shared library source code, then you will discover "bg_*" commands that executes commands in background, so the simulator still can be controlled. 2016-08-11 14:41:19 +02:00
Maciej Suminski 544da3feda Handle 'Simulate' button label in idle event handler 2016-08-11 14:41:19 +02:00
Maciej Suminski aea29fc730 Update already plotted signals upon simulation run 2016-08-11 14:41:18 +02:00
Maciej Suminski 38042ac9e0 NGSPICE class minor cleanup 2016-08-11 14:41:17 +02:00
Maciej Suminski 8fdb9e8307 SIM_PLOT_FRAME::NewPlot() -> SIM_PLOT_FRAME::NewPlotPanel() 2016-08-11 14:41:17 +02:00
Maciej Suminski 8a6e6f2d36 Do not add a trace if it is already plotted 2016-08-11 14:41:16 +02:00
Maciej Suminski cb463f48b1 Add a signal on double click 2016-08-11 14:41:16 +02:00
Maciej Suminski 0d764741f9 Simulation commands moved from eeschema menu to SIM_PLOT_FRAME buttons 2016-08-11 14:41:16 +02:00
Maciej Suminski 751a335503 Minor SIM_PLOT_FRAME redesign 2016-08-11 14:41:16 +02:00
Maciej Suminski 2b1d2d7bd1 Fixed Kiway problems in SIM_PLOT_FRAME 2016-08-11 14:41:15 +02:00
Maciej Suminski 549a96da0b License for KIWAY_HOLDER 2016-08-11 14:41:15 +02:00
Maciej Suminski d5acd7575d Updated demo schematics for simulation 2016-08-11 14:41:15 +02:00
Maciej Suminski 40224f48fb Minor simulation plot style changes 2016-08-11 14:41:14 +02:00
Maciej Suminski 781a12222c Fixed simulation plot legend 2016-08-11 14:41:14 +02:00
Maciej Suminski 0261a0e59c Axis autorange 2016-08-11 14:41:14 +02:00
Maciej Suminski 91d1f7135b SIM_PLOT_PAINTER class 2016-08-11 14:41:12 +02:00
Maciej Suminski ae5424c44a Probe cursor (TODO: has to be discussed) 2016-08-11 14:41:12 +02:00
Maciej Suminski ac17165947 Initial version of simulator probe tool 2016-08-11 14:41:11 +02:00
Maciej Suminski aa3e251cdd Sim plots get consecutive numbers 2016-08-11 14:41:11 +02:00
Maciej Suminski 112cf074f6 Heuristics to correct passive component values 2016-08-11 14:41:11 +02:00
Maciej Suminski a4868a0e5a Minor fixes to debug output 2016-08-11 14:41:10 +02:00
Maciej Suminski b6eab191d0 Added a button to add Spice fields to a schematic component 2016-08-11 14:41:10 +02:00
Maciej Suminski 0d8c095215 Fill the signal list box when a simulation is finished 2016-08-11 14:41:10 +02:00
Maciej Suminski 171e649313 Fixed type names (NET_INDEX_MAP & PROBE_LIST) 2016-08-11 14:41:10 +02:00
Maciej Suminski 402a438339 NETLIST_EXPORTER_PSPICE adjusts paths for .include directives 2016-08-11 14:41:09 +02:00
Maciej Suminski 75b0e3e0a2 Missing include in reporter.h 2016-08-11 14:41:07 +02:00
Maciej Suminski 9ef2cb94bf Simulation executes in a separate thread 2016-08-11 14:41:07 +02:00
Maciej Suminski e72b54a6e0 Code cleanup 2016-08-11 14:41:07 +02:00
Maciej Suminski 9e2485ea97 SPICE_SIMULATOR: Code formatting & clean up 2016-08-11 14:41:07 +02:00
Maciej Suminski 9748b65a6d str[n]icmp -> str[n]casecmp 2016-08-11 14:41:06 +02:00
Maciej Suminski b4d9e7ee99 Fixed asserts in DIALOG_LIB_EDIT_TEXT_BASE. 2016-08-11 14:41:04 +02:00
Maciej Suminski 9dc681b198 Build fixes (for mathgl2) 2016-08-11 14:41:04 +02:00
Tomasz Wlostowski 7b05dc2a13 Fbp files for simulator 2016-08-11 14:41:04 +02:00
Tomasz Wlostowski bfb08fb7c4 test schematic added 2016-08-11 14:41:03 +02:00
Tomasz Wlostowski 095af6e77a wip 2016-08-11 14:41:01 +02:00
Tomasz Wlostowski f1f69979e6 ngspice: something starts to work 2016-08-11 14:41:01 +02:00
Tomasz Wlostowski 2dd53b6a43 spice wip 2016-08-11 14:40:57 +02:00
Jon Neal 0bf4a6447d Add SWIG 3.0 to the list of INSTALL.txt dependencies. 2016-08-10 17:05:16 -04:00
Maciej Suminski 0aad86435f Adjust iterator after erasing an element 2016-08-10 12:17:56 +02:00
John Beard b6edf613dd Fix missing '=' in .gitconfig file. 2016-08-08 13:38:54 -04:00
Chris Pavlina e5a5f9552b Fix RS274X Unicode decoding 2016-08-08 13:21:27 -04:00
Maciej Suminski cdc951d0a3 Fixed a crash when dragging a line was interrupted
Crash was caused by removing an element from m_activeTools list, causing other iterators to be invalidated.
2016-08-08 17:20:02 +02:00
Maciej Suminski c6e4f67589 Fixed cached container data corruption on resize (OpenGL GAL) 2016-08-08 14:18:25 +02:00
Maciej Suminski 9f5f0ab31b Minor OpenGL GAL code changes 2016-08-08 14:17:40 +02:00
jean-pierre charras 7bc8cb56e0 Fix bug: Impossible to rescale 3D models 2016-08-05 21:30:23 +02:00
Michael Steinberg 86496d3141 Pcbnew: fix dangling board reference crash in GAL. (fixes lp:1584489) 2016-08-05 13:45:14 -04:00
jean-pierre charras 498c8ce61d Fix issue: When left-clicking on the "window frame" (blue top area on Windows) (Any editor), the window jumps to bottom half of the screen, if a context menu is currently opened (could be Windows specific) 2016-08-05 16:10:45 +02:00
Tomasz Wlostowski 91a3b3d396 fixed polygon filleting glitch for colinear outline segments 2016-08-05 11:44:36 +02:00
Cirilo Bernardo 8fdd6b1627 Fix 3D model file name parsing bug. (fixes lp:1609122) 2016-08-03 13:39:39 -04:00
Maciej Suminski c9a41be774 Added licence for the GAL bitmap font 2016-08-03 17:02:43 +02:00
decimad 8dcf040a4e Fix segfault on BOARDs without tracks 2016-08-03 10:20:52 +02:00
decimad 18b7dbf4d1 Refactor coroutine to improve readability and removed unnecessary heap allocations. Added documentation/links to various boost doc revisions. 2016-08-02 11:39:39 +02:00
decimad 532634abf2 fix reentrant tool state crash 2016-08-02 10:34:27 +02:00
Thomas Pointhuber e6129ca684 remove F.SilkS from default Through-hole and NPTH pads 2016-08-01 18:52:54 -04:00
jean-pierre charras 984146c37d Gerbview: better support of advanced X2 attributes. 2016-08-01 19:47:35 +02:00
jean-pierre charras 84cfef1de9 Minor change for drill files names: when separate PTH and NPTH drill files are generated, PTH drill file has its name finishing by "-PTH" (similar to the NPTH drill file name) 2016-08-01 16:29:15 +02:00
jean-pierre charras 3ca757b653 Eeschema, new legay plugin reader: ensure component flags (mainly used in edition) are cleared after loading from file. 2016-08-01 09:11:31 +02:00
jean-pierre charras e15ad9350f Fix issue from rev 6994 "Run DRC" from plot dialog crashes on Linux. 2016-07-28 14:07:35 +02:00
jean-pierre charras ff246f6365 Gerbview: Add %TO (Netlist attribute) support in X2 format. Fix a bug in a not previously very used method. 2016-07-27 15:27:19 +02:00
jean-pierre charras 62bf20271b Pcbnew, dialog plot: add a button (Run DRC) to run the DRC from the plot dialog. 2016-07-27 14:53:45 +02:00
jean-pierre charras f029047a97 Uncrustify cbbox_ray.cpp to avoid a lot of warnings on gcc 6.1 2016-07-27 14:52:04 +02:00
Wayne Stambaugh 9c5e872a4f Eeschema: fix complex hierarchy file bug. (fixes lp:1605872)
* Add project path to sheet file name and extension so the test to see if a
  file is loaded by another sheet works correctly.
2016-07-24 20:52:40 -04:00
jean-pierre charras 146a78a8fb Very minor fixes: Uncrustify a few files and rename a shadowed var. 2016-07-22 08:59:17 +02:00
Wayne Stambaugh 78e4787297 Eeschema: more schematic part library plugin prep work.
* Remove unused sort and make upper case options from PART_LIB::GetEntryNames()
  and PART_LIB::GetEntryTypePowerNames() since they were never used anywhere in
  the code.  All comparisons are case sensitive and the array of names is always
  sorted.
2016-07-20 14:11:14 -04:00
jean-pierre charras 03e5208c5b Fix: footprint libraries wizard fails with personal GitHub accounts (now uses https://api.github.com/users/xxx instead of https://api.github.com/orgs/xxx to retrieve the list of .pretty footprint libraries) 2016-07-20 10:24:24 +02:00
jean-pierre charras 3389529643 Kicad project manager: when creating a new project, creates a better empty .sch file compatible with the new schematic legacy file parser. 2016-07-20 09:05:42 +02:00
Dick Hollenbeck 7434e68876 Pcbnew: improved track scripting support. 2016-07-19 16:34:09 -04:00
jean-pierre charras e10242a0a9 Minor changes in dialogs: use wxWidgets default event handlers for wxID_CANCEL and wxID_OK buttons 2016-07-19 19:44:28 +02:00
Mrio Luzeiro d8eab321f7 3D Viewer: complete refactor of the 3D viewer.
* Split and rewrite the preview window and canvas.
* Create a new class for handling the board information.
* Adds new render targets: openGL, legacy, and ray tracing.
* Render targets take full advantage of the new 3D plugins system and 3D cache
  for a fast 3D model loading.
* Faster board loading.
* New OpenGL render is faster than the old one.
* New ray tracing render target with a post processing shader.
* Use of new 3D plugins (WRL, X3D, STEP and IGES) and 3D model caching.
* Preview of 3D model while browsing the file name.
* 3D preview of the footprint while adding / align 3D shapes.
* Render of 3D models according to attributes: Normal, Normal+Insert, Virtual.
* Pivot rotation centered in one point over the PCB board.
* Shortcuts keys improved for XYZ orientation..
* Animated camera.
2016-07-19 13:35:25 -04:00
jean-pierre charras fd42d76e2f refinements in dialogs and OSX Cancel button fix. Dialog_pad_properties, pad viewer in GAL mode: better size of the drawing area. The scrollbars are now usable. 2016-07-19 11:16:16 +02:00
Dick Hollenbeck e24990146d Pcbnew: major swig fix.
* Switched hashtables.h over to std::undordered_map from boost version.

* Added new macros DECL_VEC_FOR_SWIG() and DECL_MAP_FOR_SWIG() in macros.h.
  These along with future DECL_HASH_FOR_SWIG() unify the declaration to swig
  and C++ so that the resultant type name is common in both languages, and
  the types AGREE.

* Fixed swigging of NETINFO_ITEM and NETINFO_LIST via magic.

* Newly exposed (python wrapped) are: D_PADS, TRACKS (was TRACK_PTRS),
  NETNAME_MAP, NETCODE_MAP, wxString (without constructor purposely, read
  comment in wx.i), MARKERS, ZONE_CONTAINERS, NETCLASSPTR, KICAD_T types.

* std::vector<SOMETHING*> tends to end up named SOMETHINGS in C++ and python.
  Having the name consistent between like types is helpful, and between
  languages.  std::map<> ends up as SOMETHING_MAP.

* NETINFO_LIST::m_netNames and NETINFO_LIST::m_netCodes are now std::map
  instead of hashtables, because swig does not yet support std::unordered_map.

* You can now get to any netclass or net info.   NETNAMES_MAP and NETCODES_MAP
  are traversable basically the same as a python dictionary using a python
  string (not wsString) as the key!  The wxString typemap converts python
  string to wxString before the lookup happens.  Iteration also works.
2016-07-18 13:23:09 -04:00
jean-pierre charras 01100a57e5 refinements in dialogs and OSX Cancel button fix 2016-07-18 18:28:02 +02:00
jean-pierre charras defac5272b refinemenst in dialogs and OSX Cancel button fix 2016-07-18 17:54:41 +02:00
jean-pierre charras f83a76a970 Eeschema: dialogs: incorrect sizes fixes and osx copy text fix 2016-07-18 09:04:13 +02:00
jean-pierre charras 7253ba28df Eeschema: dlg size fixes and osx fixes 2016-07-16 13:25:07 +02:00
jean-pierre charras 3cea754d90 Eeschema: dlg size fixes and osx fixes 2016-07-16 12:54:55 +02:00
jean-pierre charras 23dcb37ad9 more about dlg size fixes and osx fixes 2016-07-15 19:58:55 +02:00
jean-pierre charras d84f793fea more about dlg sizes and osx fixes 2016-07-15 12:05:13 +02:00
jean-pierre charras ee40137de7 more about dlg size fixes and osx fixes 2016-07-14 19:30:25 +02:00
jean-pierre charras 98bc4d3ba1 Fix dialog size issues (some widgets have a incorrect size when initialized inside a TransferToWindow() method because the SetSizeHints() method was called before the init) and fix OS X copy/close bug in a few dialogs. 2016-07-14 16:25:35 +02:00
jean-pierre charras 1d1453edbe zone_filling_algorithm.cpp: fix missing closing parenthesis. Remove useless compare function. 2016-07-14 10:22:23 +02:00
jean-pierre charras b7955001c1 zone_filling_algorithm.cpp: a small code cleanup, fix incorrect return type in a few methods, and add better comments. 2016-07-14 09:27:32 +02:00
Wayne Stambaugh 959450beed Eeschema: component library plugin prep work.
* Remove unused functions in the PART_LIB and PART_LIBS objects.
2016-07-13 16:36:16 -04:00
Dick Hollenbeck c2b8a4ee43 Move from class INSPECTOR as the EDA_ITEM::Visit() callback interface to a std::function
callback.  This improves conciseness and encourages use of Visit() due to the lower cost
of entry in C++.
2016-07-12 15:05:54 -04:00
Wayne Stambaugh 98ad5096b0 Eeschema: add saving schematic files to schematic plugin.
* Add SCH_PLUGIN::Save() for current file format and code for saving all
  SCH_XXX objects.

* Add function to SCH_FIELD to get the position of the field in the component
  not the position added to the component position which is what GetPosition()
  does.  This was required because saving the component field expects position
  of the field sans the position of the component.

* Remove public members from BITMAP_BASE object and fix all associated
  code.

* Fix the never ending coding policy violations found making these changes.
2016-07-11 15:48:46 -04:00
jean-pierre charras 34469c1d9c Pcbnew, legacy mode: used spread_footprints to place new footprints after reading a netlist, like in GAL mode.
However they are put inside the "best" area, and not put inside a moving block, like in GAL, due to limitations of legacy mode.
2016-07-11 09:48:51 +02:00
Jon Neal 095063dbd9 Remove code since minimum wxwidgets version is 3.0.0.
This issue was fixed in 2.9.2 according to
https://lists.launchpad.net/kicad-developers/msg06421.html
2016-07-10 23:10:03 -04:00
Jon Neal 1293d04a7a Fix a bunch of misspellings of length. 2016-07-10 23:09:18 -04:00
Wayne Stambaugh 3bdca9a821 Eeschema: schematic I/O manager bug fixes.
* Create a new dummy root sheet and screen when the schematic fails to load
  which was causing Eeschema to crash.

* Remove conversion from UTF8 to wxString left over from a previous change
  which hopefully will fix an OSX build error.

* Fix parsing of text objects to handle version 1 schematic files.

* Fix parsing of component fields to handle version 1 schematic files.

* Don't throw a parse error when a version 1 schematic file doesn't end with
  $EndSCHEMATC.
2016-07-07 09:09:32 -04:00
Wayne Stambaugh 61e886e956 Eeschema: fix bug in release builds.
* Change debug message macro from wxASSERT to wxCHECK so that the primary
  object token name gets called instead of compiled away on release builds.
2016-07-06 09:52:47 -04:00
Wayne Stambaugh 4ed346ea64 Eeschema: initial schematic I/O plugin.
* Factor out PROPERTIES object from the PCB plugin code and move it into
  common so it can be used by both the Pcbnew and Eeschema plugins.

* Add schematic I/O plugin manager for loading and saving schematic and
  component library files.

* Add initial attempt at a parser for current schematic file format.  This
  parser will be infinitely more strict than the current parser which is very
  forgiving in what it parses.

* Make minor changes to the base bitmap class to support the new parser.

* Add find root sheet support to sheet object to allow fetching the root
  sheet from any sheet in the stack.
2016-07-06 05:22:56 -04:00
decimad 78bc3c65de use a guarded stack for coroutines in boost version 1.61 2016-07-05 18:02:50 +02:00
jean-pierre charras 05f849a746 Pcbnew: fix potential issue (crash) when loading board files with a missing net section (like created by Gerbview) due to an initialization made to late. 2016-07-05 17:01:41 +02:00
Wayne Stambaugh df99b4068d Update stable release 5 road map.
* Remove tasks that are not going to be completed by FOSDEM 2017 release
  (hopefully) announcement.

* Update item task lists to reflects changes discussed at CERN meeting.

* Update item status to reflect the current state of the tasks.

* Add a few new changes that are slated for release.

* Revise the generic road map by deleting complete items and adding new items
  discussed at CERN meeting.

* Remove unused definition from config.h.cmake.
2016-07-05 10:06:23 -04:00
Michael Steinberg 06d4894fdb boost::context fixes to make it compatible with boost 1.61 2016-07-05 00:14:32 +02:00
jean-pierre charras e7bbe27e36 Fix double call of TransfertDataToWindows in 4 dialogs (fix a bug I created in rev 6962). Make change working on KDE. 2016-07-04 18:22:18 +02:00
jean-pierre charras e6e77de4fa Fix double call of TransfertDataToWindows in 4 dialogs. make change working on KDE. 2016-07-04 17:47:48 +02:00
jean-pierre charras ed7c57f19f Fix double call of TransfertDataToWindows in dialog_print_for_modedit.cpp 2016-07-04 17:19:59 +02:00
jean-pierre charras 474e0936cb Fix double call of TransfertDataToWindows in 3 dialogs. 2016-07-04 17:17:09 +02:00
Maciej Suminski 33e7fe6211 Fix a crash caused by invalid iterator (thanks to Michael Steinberg)
TOOL_MANAGER::finishTool() caused iterator to become invalid when an element was removed from the m_activeTools deque.
2016-07-04 16:12:21 +02:00
jean-pierre charras 4a20f376a3 Move call of SetSizeHints in a few dialogs form the dlg ctor to a wxInitDialogEvent event, because some widgets sizes are not fully initialized before this event is fired.
It is especially true in some Window Managers like KDE, but can be true in any WM, when initializations are made by TransferDataToWindow() method, called by the default wxInitDialogEvent handler.
2016-07-02 18:32:03 +02:00
jean-pierre charras 1ab1dca46c Try to fix initial widgets size calculations on KDE, when using notebooks in dialogs 2016-07-02 16:13:10 +02:00
jean-pierre charras 1fbb84fd98 Move call of SetSizeHints in dialogs in a wxInitDialogEvent event, because some widgets sizes are not fully initialized before this event.
It is especially true in some Window Managers like KDE, but can be true in any WM, when initializations are mage by TransferDataToWindow() method.
2016-07-02 14:44:36 +02:00
jean-pierre charras 0eea3cffcf DIALOG_SHIM: add void FinishDialogSettings() method which calls the usual methods at end of a dialog, to ensure proper size and position, the first time the dialog is called.
Fix an incorrect size of dialog_pcb_text_properties (due to the fact the dialog was not really initialized when its min size was calculated)
2016-07-02 11:35:52 +02:00
Simon Richter 6614e5ef5d Eeschema: rewrite loop conditions in SCH_SCREEN::SchematicCleanUp().
* These are a tiny bit more readable and do not depend on all branches to
  correctly advance the loop variable.
2016-06-30 11:15:46 -04:00
Simon Richter ea6ef51649 CMake: add FindSWIG.cmake from CMake 3.5 for swig 3.0 support.
* The FindSWIG.cmake shipped with CMake 3.0 does not yet look for the
  "cmake3.0" binary, this was added shortly after the 3.0 release.

* This file can be removed once the minimum CMake version is 3.1 or greater.
2016-06-30 11:03:09 -04:00
Simon Richter 1b2fd6a382 Replace BOOST_FOREACH with C++11 range based for. 2016-06-29 16:07:55 -04:00
Simon Richter da5699de0a Replace boost::shared_ptr with std::shared_ptr. 2016-06-29 11:09:55 -04:00
Simon Richter 1cb9260972 3D Viewer: drop extra copy ctors from IFSG_NODE.
* This is unnecessary.  Explicitly specifying the regular copy ctor will
  inhibit any generated versions.
2016-06-29 09:52:48 -04:00
Dick Hollenbeck 5fa8aa3660 Increase cache validity period in nginx.conf
This revised nginx.conf holds the cache for one week, truly.  For some reason there are
two tuning knobs required to make one adjustment (cache duration).  Without this fix the
cache was only held for 10 minutes.  The most important change is the "inactive=1w" which
as I implied, is the *second* reference to one week.  Sorry for this oversight.

Nginx can be run on something as simple as a raspberry PI.  I run it on a network file
server attached to my desktop via copper ethernet.  By caching the footprint libraries
from github, I can load all github libraries in about 2.5 seconds, making github the
fastest plugin of any kind.
2016-06-29 12:25:28 +02:00
Michael Steinberg fde12ebd25 Replace boost::function and boost::bind with their std:: counterparts 2016-06-29 12:23:11 +02:00
https://launchpad.net/~dmitrodem-gmail cef8b388a5 Fix pcb_calculator bug: fails to synthesize microstrip line, due to a not removed change which should have been removed after a test. 2016-06-28 17:35:50 +02:00
Simon Richter 527c0eff8e Eeschema: ERC dialog code improvements.
* Rename the "net", "lastNet" and "nextNet" variables to "item", "lastItem"
  and "nextItem", respectively, because these refer to netlist items, not
  nets.
* This adds a suffix "Idx" to the indexes into the list, and introduces local
  copies of the pointers to the objects we are looking at, in order to have a
  shorter way of addressing them.
* The ERC code depends on netlist items to be sorted by net code, so verify
  that in debug builds. While this condition is stricter than necessary, it
  should still hold with the current code, and provide a good canary if a
  change to the sorting code might break ERC.
2016-06-28 08:52:22 -04:00
Simon Richter 10c8dae794 Eeschema: improve merging of overlapping SCH_LINEs.
* Use std::min and std::max to determine the overlapping line end points.
2016-06-27 19:54:46 -04:00
Simon Richter 4bf72be9e4 Eeschema: minor improvements to SCH_LINE::MergeOverlap() function.
* Do not statically initialize candidates vector.
* Preset candidates vector allocation size since it is always the same.
2016-06-27 14:17:39 -04:00
Simon Wells 236f5369ef CMake: remove Curl dependency when github plugin build is disabled. 2016-06-27 09:10:28 -04:00
jean-pierre charras 9a0d346afa Minor update: pic_programmer demo: use current (updated) components instead of old ones in schematic and board. 2016-06-26 16:43:18 +02:00
jean-pierre charras 58ddb0fd37 PolyLine.cpp: NormalizeAreaOutlines now removes null segments.
* CPolyLine::Chamfer (and CPolyLine::Fillet) :  removes null segments before calculating modified outlines.
  It fixes some incorrect outlines after chamfer or fillet due to null segments creating overflow during calculations.
* CPolyLine::Chamfer : code cleaning (avoid useless double to integer and integer to double conversions).
2016-06-26 16:39:15 +02:00
Dick Hollenbeck e47f0df068 Cleanups
* coding standard fixes
* library part not library component (no such thing as a library component)
* string concatenation fix
* and an inline harmless debug/dump function
2016-06-24 12:55:54 +02:00
Cirilo Bernhardo c11b0cef99 3D Viewer: change 3D model cache path.
* Use platform cache path insted of the KiCad configuration path to write the
  3D model cache.
* OSX: ${HOME}/Library/Caches/kicad/3d
* Linux: ${XDG_CACHE_HOME}/kicad/3d or ${HOME}/.cache/kicad/3d
* Windows: AppData\Local\kicad\3d
2016-06-21 14:02:04 -04:00
Dan Cross f5fa6a2148 Fix broken swig import script when using swig >= 3.0.10. 2016-06-20 09:32:59 -04:00
jean-pierre charras e27f90a14f Fix display issue and potential display issue in print dialogs in Pcbnew.
These issues are due to a minor change in automatically generated files by recent versions of wxFormBuilder.
2016-06-19 21:10:50 +02:00
jean-pierre charras 83504c2b29 Pcbnew: Rework on print dialogs. 2016-06-19 20:29:13 +02:00
jean-pierre charras 5a00c7823c Gerbview: Read excellon files: fix incorrect handling of G85 command. 2016-06-19 11:53:40 +02:00
jean-pierre charras 68f0503586 Fix Pcbnew bug: print dialog: layers not listed in dialog (Linux specific) 2016-06-18 17:47:05 +02:00
jean-pierre charras dbd9b5e49e Gerbview: minor code cleanup. 2016-06-18 11:37:36 +02:00
jean-pierre charras 85f45eb302 Gerbview: code cleanup (mainly remove g_GERBER_List global variable) 2016-06-17 20:01:59 +02:00
jean-pierre charras a907e50424 Gerbview: code cleanup (mainly remove g_GERBER_List global variable) 2016-06-17 20:00:29 +02:00
jean-pierre charras 7fd30e6dc0 Fix a (minor) issue in Kicad manager: when the schematic editor or the board editor are run from the project tree frame to edit files of the current project, editors are opened on the background. 2016-06-17 19:58:14 +02:00
jean-pierre charras 0862ac28d0 Dialog DRC: fix a minor bug created in rev 6936: the report file was always created, regardless the option selected in the check box.
Enhancement: the browse file dialog nows open the project folder by default.
2016-06-17 08:24:54 +02:00
Wayne Stambaugh 66f8a0c1b5 KiCad: fix segfault bug when switching from remote to local project.
* Deleting the wxFileSystemWatcher when switching from a remote project to
  a local project caused KiCad to segfault.  Switching from a local project
  to a remote project did not cause KiCad to crash.  The fix was to clear all
  of the file system watcher paths instead of deleting and creating a new file
  system watcher object between project changes.  The object still crashes on
  exit when deleted in the main window dtor.  Allocating the file system
  watcher object on the stack instead of on the heap did not make any difference.
2016-06-16 08:38:31 -04:00
jean-pierre charras 3f2b15711c Fix bug: DRC report to File crashes Pcbnew, if the file cannot be created (for instance if the CWD is not writable, or if the path does not exist)
Fix also an other issue: if the file path is not entered, the file is now created in the current project directory.
2016-06-15 19:00:30 +02:00
jean-pierre charras 7abf006c80 Very minor fix: fix shadowed local vars. 2016-06-15 10:27:24 +02:00
jean-pierre charras 947c73f23b Gerbview: try to fix a crash (hard to reproduce) which someting happens when closing gerbview. Fix incorrect calculation of bounding boxes. 2016-06-15 10:26:41 +02:00
Maciej Suminski 7ff3dd0807 Make sure GL canvas is visible upon destruction in Module properties dialogs. 2016-06-14 12:08:35 +02:00
Maciej Suminski b82ccc3b4e Reverted 6912 with minor changes (LockCtx requires to specify canvas that locks a context). 2016-06-13 16:43:33 +02:00
Wayne Stambaugh 571206aa07 Remove unused and unmaintained OSX build scripts. 2016-06-13 15:49:01 -04:00
jean-pierre charras c4b22b55a0 Bug fix: When using the %Y variable placeholder in a worksheet template, the %Y variable content overwrite the whole string. 2016-06-13 21:02:10 +02:00
jean-pierre charras 1e7b0f83d9 Fix script fix_swig_imports.py to work with swig version 3.09 2016-06-13 19:50:29 +02:00
Cirilo Bernardo 9b2dba2b1b 3D Viewer: fix swapped VRML material colors.
* Fix a bug in the VRML2 parser which exchanged the blue and green components
  of the ambient lighting.
2016-06-13 12:50:42 -04:00
jean-pierre charras 1c838ba92f Slightly modify a declaration to make compil compatible with gcc 4.8.4, used in Ubuntu 14.04 LTS (the latest LTS currently available), and to avoid many bug reports. 2016-06-13 14:19:47 +02:00
jean-pierre charras 688fb5caaa Minor enhancements in dlg_3d_pathconfig (better look, but not perfect). Also fix an issue: the minimal dialog size was not always calculated. 2016-06-13 12:41:27 +02:00
Maciej Suminski 57d4e8d51d Fixed OpenGL crash on canvas switch. 2016-06-13 09:35:36 +02:00
Cirilo Bernardo b09f079ab4 3D file name resolver improvements.
* Add a Help button and text to the 3D alias configuration dialog
* Display KISYS3DMOD and internally defined KiCad path env vars
* Add a button to bring up the "Configure Paths" (env vars) dialog
* Remove the file name mapping feature from the resolver; this results in
  the resolver always using the current definition rather than a possibly
  outdated cache value.
2016-06-12 18:46:00 -04:00
Chris Pavlina 5285962775 Remove option to not show footprint ratsnest when moving
This option only exists in legacy, with no real plan to port it to GAL. Nobody
seems to use this; there isn't really much of a point to it. Bye!
2016-06-11 22:34:07 -04:00
Chris Pavlina 81144c2476 Move hotkey list from Preferences menu to Help menu 2016-06-11 21:22:13 -04:00
Chris Pavlina 9eef653625 Remove legacy option to zoom to selection on middle mouse button
This feature was not reliably available: neither pl_editor nor GAL supported
it. It has been replaced over the past few commits with a new zoom-to-selection
tool available in all applications and modes.
2016-06-11 19:37:43 -04:00
Chris Pavlina 92e3c4a45c Fix missing zoom-to-selection hotkey branch in pl_editor 2016-06-11 11:49:55 -04:00
Chris Pavlina 8c81e53c03 Refactor DRAW_LIST configuration in pl_editor block code 2016-06-11 11:49:46 -04:00
Chris Pavlina abf22695c8 Replace unnecessary global in pl_editor block code 2016-06-11 11:27:12 -04:00
Chris Pavlina d49ecb1b91 Add zoom-to-selection and block move to pl_editor 2016-06-11 09:51:05 -04:00
Chris Pavlina c13f80bb49 Remove unneeded compile option KICAD_KEEPCASE
Libraries have been 100% case-sensitive for a while now; there is no longer a
need to keep this option around. This will change nothing except for any
stragglers still manually specifying this old option.
2016-06-10 23:15:02 -04:00
Wayne Stambaugh 588d4c33a0 Set minumum SWIG version to 3.0 for C++11 support. 2016-06-10 14:08:35 -04:00
Wayne Stambaugh 21595f48d3 KiCad: fix crash when kiface libraries are missing. (fixes lp:1577786)
* An assumption was made that wxDynamicLibrary.Load() would always result in
  a wxLogSystemError on failure which was not always true.  The code now throws
  an exception which is caught by KiCad and an error message is displayed.  In
  the case where the wxLogSystemError is shown, there will be an annoying two
  error messages but that is better than a crash.
2016-06-10 13:47:19 -04:00
Maciej Suminski b7ec4ea160 Corrected the last instance check in OPENGL_GAL. 2016-06-10 17:07:12 +02:00
Maciej Suminski 5850b1ced0 GL_CONTEXT_MANAGER: Call SetCurrent() only when a different context is used. 2016-06-10 17:06:54 +02:00
Simon Richter 5ce4abd0ac Use size_t for sizes and offsets. 2016-06-10 17:06:00 +02:00
Simon Richter eb45f02138 Avoid pointer truncation in debug message 2016-06-10 11:06:47 +02:00
Chris Pavlina 26607f8ab9 Add zoom-to-selection tool to gerbview 2016-06-10 07:08:16 -04:00
Mário Luzeiro f25d12f571 Footprint 3D properties dialog panel: fixes a bug on the offset of 3D Settings (Footprint) (the value range of the offset parameters were not set so it was not able to enter values <-10)
Also make some small layout changes on the orientation parameters in order to make it vertical smaller.
2016-06-09 14:27:58 +02:00
Maciej Suminski aa9681e979 GL_CONTEXT_MANAGER: Call SetCurrent() only when a different context is used. 2016-06-09 13:44:59 +02:00
jean-pierre charras 71af77b5f3 Legacy mode ( all apps): Pan with mouse middle button: fix an unwanted displacement of the drawings (half width of scroll bars) when starting the pan (due to a parameter (new reference position of scroll bars in IU) which was stored with an incorrect value)
Minor enhancement during pan: the mouse cursor shape is modified.
2016-06-09 10:45:27 +02:00
jean-pierre charras cdf2b6950e Legacy mode: Pan with mouse middle button fix an unwanted displacement of the drawings (half width of scroll bars) when starting the pan (due to a parameter (new reference position of scroll bars in IU) which was stored with an incorrect value)
Minor enhancement during pan: the mouse cursor shape is modified.
2016-06-09 10:43:32 +02:00
Cirilo Bernardo e0a7f0041a Better 3D filename resolution 2016-06-09 07:48:49 +02:00
Chris Pavlina 8c01318141 Add zoom-to-selection tool 2016-06-08 07:19:53 -04:00
Chris Pavlina ce3ccec528 Fix incorrect scaling in scrollbar fix (r6895, 35883bb)
...how did this ever look like it worked?
2016-06-08 06:26:39 -04:00
Simon Richter 2928cb7419 Replace unshared boost::shared_array with std::unique_ptr 2016-06-08 09:43:07 +02:00
José Ignacio d78a68356f Add mime package for gerber and excellon files 2016-06-08 09:41:36 +02:00
jean-pierre charras 37deba60c3 Fix shadowed vars (in microstrip.cpp) and deprecated compil warnings. 2016-06-08 09:28:19 +02:00
jean-pierre charras cd30be3fd9 Pcb calculatpor: Minor enhancements in main frame. 2016-06-08 09:25:43 +02:00
Simon Richter 715eddf68b Code cleanup: remove dead code, add comment. 2016-06-08 08:32:01 +02:00
Simon Richter 080d7f1024 Add missing dependency github_plugin -> pcbcommon. 2016-06-07 21:38:58 -04:00
Simon Richter 961fe1abe8 Eeschema: fix spelling "propageNetCode" -> "propagateNetCode" 2016-06-07 21:07:49 -04:00
Chris Pavlina 35883bb74b Account for scrollbars when centering 2016-06-07 20:28:11 -04:00
Wayne Stambaugh a628af7728 Remove unused and unmaintained build and packaging files. 2016-06-07 14:33:05 -04:00
jean-pierre charras 11c369ee1b Fix minor compil warnings (deprecated warnings and shadowed local vars warnings) 2016-06-07 17:33:12 +02:00
Chris Pavlina e3d2ba5244 Update copyright header template to reflect current usage 2016-06-07 11:05:35 -04:00
Maciej Suminski cef45c0297 Hide all related layers when footprint rendering is disabled. 2016-06-07 15:07:47 +02:00
Maciej Suminski 553899b79b PNS: Do not create an undo buffer entry when there is nothing to save. 2016-06-07 14:42:42 +02:00
Maciej Suminski 71aade6b51 Fixed a few warnings (mostly gcc6 -Wmisleading-indent). 2016-06-07 14:42:42 +02:00
Maciej Suminski 3fcae6b120 Fixes for OpenGL resources handling. 2016-06-07 14:42:42 +02:00
jean-pierre charras f4525875f1 Pcbnew: fix bug : footprint editor: shape offset was ignored when placing new pads. Was also ignored in global pad change in fp editor and board editor. 2016-06-07 10:02:19 +02:00
Chris Pavlina d682e4d7fa Change default via dimensions to 0.8/0.4 2016-06-06 20:23:58 -04:00
jean-pierre charras f311230874 Gerbview: when running gerbview from a command line, if a filename is given, and if it is a .drl file, it is loaded as drill file (instead of a gerber file, which generate an error message).
Code refactor: remove useless class members,  and move read gerber file and read excellon file from gerbview frame to the corresponding classes
2016-06-05 14:26:39 +02:00
jean-pierre charras 6d1e904334 Code cleanup: Remove outdated decimils to/from iu defines and conversion functions (decimils are no more in use since a long time).
Remove convert_from_iu.h file, only used for one define, and containing brokenand duplicate defines. Only convert_to_biu.h is now used.
2016-06-05 13:49:25 +02:00
jean-pierre charras 2b459acfe9 Fix incorrect handling of Aperture Macros, especially when using exposure OFF in macros.
Aperture macro shapes are now drawn using polygons.
2016-06-03 18:42:24 +02:00
Maciej Suminski b4ad18a3ea Do not rebuild shaders on each OPENGL_GAL construction. 2016-06-03 15:46:13 +02:00
Maciej Suminski b83c148e10 Delete OpenGL context on GLCanvas subclasses destruction. 2016-06-03 15:46:13 +02:00
Maciej Suminski 68b6da57c0 Removed OPENGL_GAL::instanceCounter. 2016-06-03 15:46:12 +02:00
Maciej Suminski 94a460080e Added missing code for C3D_MODEL_VIEWER to use GL_CONTEXT_MANAGER. 2016-06-03 15:46:12 +02:00
Maciej Suminski 01f32dd52c GL_CONTEXT_MANAGER class to avoid unexpected GL context switches. 2016-06-03 15:46:12 +02:00
Maciej Suminski 4f7bb4c0f7 Simplified error checking in OPENGL_GAL test. 2016-06-03 15:46:11 +02:00
jean-pierre charras 3e2cae946c Corrected wxDC objects used by EDA_DRAW_PANEL_GAL & OPENGL_GAL. 2016-06-03 15:46:11 +02:00
Cirilo Bernardo dbef1d41c5 Remove dead code (Coverity CID 149046) 2016-06-03 06:30:47 -04:00
jean-pierre charras 55a44f3cfc Gerbview: rename a file with a better name. Add a test file to test aperture macros which include a negative object (currently incorrectly displayed by Gerbview) 2016-06-03 09:05:25 +02:00
jean-pierre charras 185dc2bbdf fix an incorrect filename (incorrect case) which created compil issue on Linux. 2016-06-03 08:49:55 +02:00
jean-pierre charras 93e61e7a2e Minors fixes: dialog_print_using_printer.cpp: fix a Coverity warning and very minor coding style issue. xsl scripts: add bom2grouped_csv.xsl (from a contributor) and fix minor issues. 2016-06-03 08:32:24 +02:00
jean-pierre charras 368bd1477b Gerbview: serious code cleanup (with the serious help of Mark Roszko's work on Gerbview) 2016-06-02 11:30:39 +02:00
Wayne Stambaugh 0ccd3bb3c2 Remove deleted plugin file bom_cvs.xsl from install list. 2016-06-01 20:34:24 -04:00
Wayne Stambaugh 42b659efe1 Fix build error on non-debug builds. 2016-06-01 16:58:27 -04:00
jean-pierre charras 0a6245e5cc Remove not working bom_cvs.xsl file. Fix minor compil warnings in x3dmodelparser.cpp. 2016-06-01 18:42:01 +02:00
jean-pierre charras dc4882c4bd Pcbnew: Fix incorrect order of linked files, which can create issues (not defined symbols) at link stage. 2016-06-01 18:40:18 +02:00
jean-pierre charras a4658ab6be Fix a few compil warnings (not used vars, shadowed local vars) 2016-06-01 14:22:05 +02:00
jean-pierre charras 96e55de90d Code cleanup: remove dead code (some removed methods were broken), and update or add comments. 2016-06-01 11:31:40 +02:00
jean-pierre charras e2cc78b2b5 Code cleanup: remove dead code (some removed methods were broken), and update or add comments. 2016-06-01 11:28:07 +02:00
Marco Ciampa 09dc517d3c Add Italian desktop file translations 2016-05-30 15:33:32 -04:00
Simon Wells 4b5a4c0d36 Display correct page count in print dialog 2016-05-30 11:44:49 -04:00
Simon Wells 457b021101 Fix bug: printed duplicate pages when Single Page selected
https://bugs.launchpad.net/kicad/+bug/1523065
2016-05-30 11:25:40 -04:00
José Ignacio Romero 7c1f5f617b Clean up the applications/*.desktop files.
Put all keys in consistent order and remove/fix bogus mime types, some
assigned to programs that don't even open files. Those files could use
some TLC from translators to provide translated names and tooltips, I
preserved some of the french that was already in the files.
2016-05-30 08:52:56 -04:00
José Ignacio Romero 36d98dab2d Add script for generating icons under resources/linux/mime/icons
Quick and dirty script gathers the original SVG icons from the
bitmaps_png folder and generates bitmaps at several sizes named
according to the mime type or application name. To get the names, the
script reads the kicad-kicad.xml mime package and the application
.desktop files, reconciling both to make sure all defined types have
proper associations.
2016-05-30 08:37:58 -04:00
José Ignacio Romero 5eb869b691 Fix hicolor icons.
This renames (well, actually regenerates from the originals) all the
icons installed on Linux to match the correct mime type names, and
adds all the missing icons in some sizes.
2016-05-30 08:36:47 -04:00
José Ignacio Romero 2b00008109 Remove mimelnk files
Mimelnk files are not used by anything since KDE 3. Clean this up to
reduce confusion.
2016-05-30 08:33:19 -04:00
José Ignacio Romero bf62997f3c Fix pcbnew extension and mimetype in MIME XML package file
This file registers the file extensions used by kicad and their
corresponding mimetypes. Before this change the file was refering to
the old .brd extension and the wrong mime type. The file was also
renamed to kicad-kicad.xml to conform to the XDG spec which expects a
vendor-product pair as the package name.
2016-05-30 08:32:05 -04:00
Chris Pavlina e8dba1c14b Remove unnecessary and possibly problematic optimization
https://bugs.launchpad.net/kicad/+bug/1280897
2016-05-30 08:26:39 -04:00
Chris Pavlina a27ad2beca Remove old packaging files 2016-05-30 07:14:55 -04:00
Cirilo Bernardo 34f223a707 Fix FP Editor : Invalid Filename Err.msg message wheb trying to edit a 3D filename 2016-05-30 10:22:19 +02:00
Simon Richter 48ad75719c Remove redundant old copy of cimage class (3d-viewer/CImage.cpp and 3d-viewer/CImage.h) 2016-05-30 08:31:32 +02:00
José Ignacio Romero 5832e37177 GAL: Fix offset problem in multiline text rendering
Commit BZR 6703 introduced a minor horizontal adjustment for stroke
text rendering in GAL, but the Translate() call was done before
calling Save(). So, when this function was called multiple times a
residual offset carried over to each subsequent line.

bzr 6703 = git 67982a4
2016-05-29 17:40:11 -04:00
jean-pierre charras 7872f1ec15 A few minor fixes for compil warnings (shadowed local variables and deprecated auto_ptr) 2016-05-29 17:03:58 +02:00
jean-pierre charras 1ae9175671 A few minor fixes for compil warnings (shadowed variables and deprecated auto_ptr) 2016-05-29 17:02:34 +02:00
jean-pierre charras ca0113ab65 Fix my previous commit: I committed the wrong file 2016-05-28 21:51:35 +02:00
jean-pierre charras b7f863dc4c Fix the commit 6838 (Fix non optimal position of net name and pad name in GAL mode), broken. 2016-05-28 21:46:13 +02:00
Simon Richter 3e5443166e Use wxIMPLEMENT_APP_CONSOLE for console apps 2016-05-28 13:14:35 -04:00
Cirilo Bernardo 8c116d1a21 Convert idf2vrml to use wxApp etc for option processing 2016-05-28 13:14:31 -04:00
Simon Richter 71bbddc30c Drop <libgen.h> and <unistd.h>, no longer needed 2016-05-28 13:11:30 -04:00
Simon Richter 7cee73e8e5 Narrow assumption on OpenSSL use 2016-05-28 13:11:24 -04:00
Simon Richter dca358076e Make sure KIFACE_GETTER linkage is consistent
This makes sure that the declaration is always the same within a single
module, so all users have the same idea of whether the symbol is imported.

In all dynamically linked objects, all users should be aware that the
symbol is imported, while in the statically linked bitmap2component
program, no import/export decorations should be used.
2016-05-28 13:10:06 -04:00
Simon Richter b9a6c4988f Avoid conflicting declaration for Pgm()
This function has two conflicting definitions in the "kicad" executable and
the other wrapper programs. As the kifaces can be loaded from either, this
silently assumes compatible data layout for the PGM_KICAD and PGM_BASE
types when passed by reference, which is valid only when the compiler is
aware of the cast.

If the return type is encoded in the symbol name (such as when using the
MSVC compiler), this also causes an error during linking, as the symbol
names no longer match.
2016-05-28 12:57:29 -04:00
Marvin Schmidt 92a3743590 Avoid C99 style compound statement 2016-05-28 12:57:24 -04:00
Simon Richter 5b3d1d72e8 Open namespace around definitions
While defining functions in another namespace is technically allowed as
long as the definition can be matched to a declaration, this can lead to
ambiguous resolutions, such as here (GAL vs KIGFX).
2016-05-28 12:57:19 -04:00
Simon Richter 96ec9db5d6 Add missing C++ stdlib headers
The GCC standard library headers often include other headers, which makes
some code compile that forgets to include several headers.
2016-05-28 12:46:29 -04:00
Simon Richter f7fdf43ea8 Use std::atomic for portable locale init counting 2016-05-28 12:46:22 -04:00
jean-pierre charras e795dafc4b Fix non optimal position of net name and pad name for pads with shape offset: the texts are now (like in legacy canvas) centered to the pad shape, not the pad position. 2016-05-28 12:53:29 +02:00
jean-pierre charras f1c9f284fd Dialog 3D path config: fix incorrect grid cells sizes when opening the dialog, and incorrect min size dialog. 2016-05-28 11:33:20 +02:00
jean-pierre charras 4441a4b4c7 Cvpcb: fix a focus issue (on OSX), when using arrow keys to scroll the footprint list box, if the footprint and 3D viewers are opened. 2016-05-27 18:15:16 +02:00
Maciej Suminski ade1d1fe74 Fixed display of 'b' letter in OpenGL canvas. 2016-05-27 14:44:44 +02:00
jean-pierre charras 2ff1403212 Gerbview: fix a crash when clicking on a gbr item not on active layer. 2016-05-27 11:27:28 +02:00
jean-pierre charras 5065961cf5 Gerbview: code refactoring:
* move gerber_file_image_list class to a separate file
* better BestZoom calculation, and fix incorrect size of wxTextCtrl showing info about gerber file format.
* remove useless file and dead code. Remove not used parameters in some classes (mainly in class_gerber_draw_item)
2016-05-27 10:34:10 +02:00
jean-pierre charras 4d82be5f0e Gerbview: more code refactoring: remove useless files. Fix a few issues or bugs. 2016-05-27 10:20:17 +02:00
jean-pierre charras 25c808b859 Gerbview: fiw a few issues in print dialog 2016-05-26 20:13:53 +02:00
jean-pierre charras 3c0859686b Gerbview: fix a stupid mistake I made in rev 6829 (crash when reading a gbr file). 3d path config dialog: make it resizable. 2016-05-26 18:58:32 +02:00
Maciej Suminski 25d526cbc6 Fixed a crash when GRLineArray is called with an empty vector. 2016-05-26 17:14:08 +02:00
jean-pierre charras 54b6f875a6 Gerbview: better BestZoom calculation 2016-05-26 14:42:27 +02:00
jean-pierre charras 130c6e3639 Gerbview: more code refactoring. 2016-05-26 13:57:43 +02:00
jean-pierre charras 3b379787bc Gerbview: move gerber_file_image_list to a separate file 2016-05-26 09:50:49 +02:00
jean-pierre charras 8c8a1238f1 Gerbview: more code cleanup. Rename class GERBER_IMAGE GERBER_FILE_IMAGE, because it handles the gerber image and the gerber file info. 2016-05-25 16:48:38 +02:00
jean-pierre charras 1c21410f1f Gerbview: code cleanup (with the help of Mark Roszko's work) 2016-05-25 11:45:55 +02:00
jean-pierre charras 75c551f305 Gerbview: accept embedded tool definition (i.e. select tool and define it in the same line, outside the header). A few minor other fixes. 2016-05-24 17:56:52 +02:00
jean-pierre charras ac734ab54b Gerbview: Avoid too long filenames in layer manager: the filename length is clamped to 30 chars. 2016-05-23 20:30:23 +02:00
jean-pierre charras dbb78db7ef Gerbview: Shows now in the Layer manager the filename of gerber or drill files loaded.
A fex minor compil warnng fixes
2016-05-23 17:47:16 +02:00
Maciej Suminski 2ded7bf82a Improved error handling for SHADER class. 2016-05-23 09:54:53 +02:00
Maciej Suminski 3ca7026aa0 More robust checks for OpenGL canvas visibility. 2016-05-20 12:06:08 +02:00
Maciej Suminski a30c8d7848 Coverity fixes. 2016-05-11 11:18:27 +02:00
Simon Wells 74d69b6a80 multiple monitor loses window when single monitor 2016-05-23 10:51:17 +02:00
jean-pierre charras bbe42d0f47 Fix very minor issues: compil warnings (mainly deprecated and shadowed vars warnings). 2016-05-22 19:39:20 +02:00
ejs-ejs f8ae428428 Add Lithuanian language to language list menu. 2016-05-22 12:31:08 +02:00
Alexander Lunev 42c47c7970 pcad2kicadpcb: fixed an issue with an uppercase fileUnits parameter. 2016-05-22 11:01:19 +02:00
Simon Wells a9d08a620e Hide OpenGL scrollbars on OS X to fix freeze
Fixes: https://bugs.launchpad.net/kicad/+bug/1553428
2016-05-21 19:38:47 -04:00
jean-pierre charras 1e0a72df0b Eeschema: fix a minor issue: when deleting a connection, the screen was not always redrawn, and the deleted objects were still shown, until the next screen redraw. 2016-05-20 10:09:08 +02:00
Cirilo Bernardo 47e2aab7de PATCH: segfault in VRML2 plugin
The attached patch fixes a segfault in the VRML2 plugin
which is caused by Shape entities with empty vertex
lists.
2016-05-19 21:12:07 -04:00
jean-pierre charras e2d4118470 Eechema, Component editor: Fix a bug in Pin properties dialog: a parameter used to draw the pin in preview canvas was incorrect, due to code change in draw pin. 2016-05-19 18:38:36 +02:00
Simon Wells 74611440b5 Fix mirrored graphics when moving SCH_BITMAP on OS X
Fixes: https://bugs.launchpad.net/kicad/+bug/1529163
2016-05-17 17:56:20 -04:00
Dick Hollenbeck daa0d391de Enhancement in eeschema: Footprint field immediately updated after footprint picking (from footprint viewer) in the eeschema LIB_PART or component text field properties editors 2016-05-17 20:02:49 +02:00
jean-pierre charras 620ccc5483 Try to fix a compil issue on OSX (no viable conversion from 'const wxString' to 'const wxChar *', in colors.cpp) 2016-05-17 09:10:15 +02:00
Dick Hollenbeck 0715504a9e remove support for in processing setting of ld library path 2016-05-16 21:04:20 +02:00
Dick Hollenbeck 544554086e Eeschema: make footprint and datasheet initially invisible, when creating a component 2016-05-16 20:59:35 +02:00
jean-pierre charras 74d3cfd688 Make color names translatable in color selection dialog. 2016-05-16 20:35:34 +02:00
Cirilo Bernardo 0ec15c9157 VRML plugin: VRML plugin. This patch modifies the behavior of the VRML name parser so that a name may be immediately succeeded by ] or }.
The previous behavior was to reject a valid name since the brace or bracket was considered an invalid character within a name.
2016-05-16 09:32:15 +02:00
Wayne Stambaugh 00b8624713 Fix missing links in ui-policy.md. 2016-05-13 13:09:28 -04:00
Chris Pavlina 0f407a756c Pull existing settings into Doxygen module 2016-05-12 15:45:47 -04:00
Chris Pavlina 84d3fbfd68 Remove MaxUndoItems, make devel option DevelMaxUndoItems
Begin documenting configuration keys in Doxygen
2016-05-12 12:51:32 -04:00
Chris Pavlina a488cb0142 Sanity-check loop bounds in SHAPE_LINE_CHAIN::Parse
Coverity CID: 128540
2016-05-11 23:28:08 -04:00
Chris Pavlina e782e463f4 Remove redundant NULL check
Coverity CID: 134088
2016-05-11 23:28:03 -04:00
Chris Pavlina ac3cd950b1 Fix ignored result of TransferDataToWindow in DIALOG_SHIM
Coverity CID: 147343
2016-05-11 23:27:57 -04:00
jean-pierre charras 0bd287b6d9 Pcbnew: Fix a very minor bug ( The "Move exactly..." sometimes truncates the saved parameter floating point values during a session) 2016-05-11 12:16:07 +02:00
jean-pierre charras e978a17ccd Fix minor bug in Modedit: Adding a new rounded rect pad to a footprint doesn't clone rectangle rounding 2016-05-11 10:54:44 +02:00
jean-pierre charras 6a7544a2ca Fix a few deprecated compil warnings in dialogs generated by wxformbuilder 2016-05-11 10:51:07 +02:00
Chris Pavlina 540275fe44 OS X: Disable full-screen cursor
This feature cannot work reliably for reasons explained in lp:1463505. Remove
the option on OS X builds and force cursor to the small one.

https://bugs.launchpad.net/kicad/+bug/1463505

> Bernhard Stegmaier (stegmaier) wrote on 2016-01-14:
>
> As far as I see from the code this is no bug but done on intention.
>
> The reason probably is that on OSX in the legacy canvas you don't have the
> XOR-drawing as on other platforms. To the best of my knowledge, this would
> mean that on every mouse move you would have to repaint the whole window just
> to get rid of the "old" cross.
>
> So, I would say this is a clear "won't fix".
> We could think of just removing/disabling the button in the legacy canvas.
2016-05-10 23:33:24 -04:00
Chris Pavlina 5904e4c942 Correct handling of unused parameter
Coverity: CID 143742
2016-05-10 23:25:53 -04:00
Chris Pavlina 05255cbae8 Clean up dodgy array dimension
Array is in pairs but has a single sentinel, trips up Coverity (CID 147346) and
does allow an out-of-bounds write if WX_GL_SAMPLES were ever removed from the
array.
2016-05-10 23:15:33 -04:00
Chris Pavlina ec67218b5a Remove unneeded 'new' and NULL check
Coverity CID: 143743
2016-05-10 22:36:44 -04:00
Chris Pavlina 7b5ab741bb Fix null dereference for certain bad PCB files
Coverity: CID 147344 Unchecked dynamic_cast

If a file that parses validly in Parse() but does not return a BOARD is loaded,
no exception will be thrown but the dynamic_cast will return NULL. This NULL
is tested by wxASSERT(), which does not actually halt anything (especially in
release builds), and then we proceed to board->SetFileName().

This can be demonstrated quickly by renaming a .kicad_mod to .kicad_pcb and
trying to load it. pcbnew will crash.
2016-05-10 22:36:39 -04:00
Chris Pavlina 445db7da58 Fix uninitialized fields
Coverity: CIDs 102698, 147347, 147349, 147350
2016-05-10 22:36:23 -04:00
Chris Pavlina 5044fc5799 Fix build error on some platforms from r6788
r6788 = git f9386fc
2016-05-10 18:57:10 -04:00
Chris Pavlina ba17a54c08 Remove "Dump zone geometry to files when filling"
The code to perform the dump has not been removed, but the GUI option and
global flag (ugh) have been.
2016-05-10 17:37:51 -04:00
Chris Pavlina e9a9a269b4 pcbnew legacy: remove option to hide via drill
Via drills are now shown in all cases, matching GAL behavior, and the option no
longer exists in the preferences dialog.
2016-05-10 16:47:37 -04:00
Chris Pavlina f9386fcbc0 Add support for PCB and footprint format versioning
Currently, kicad_pcb files have a (version ...) tag, but it is ignored. This
commit does the following:

1. Parse the version. If it's later than the last supported version, present an
alternative error message suggesting an upgrade if the file does not load
correctly. The version will be interpreted as an integer YYYYMMDD to suggest
a KiCad release date.

2. Accept a (version ...) tag also in kicad_mod files, but do not write them
yet. If no version tag is present in these files, assume the version to be that
of the current format version at the time of this commit.

This is meant to be merged to the 4.x stable series, and preps for KiCad 5
which will start emitting version tags also in footprints - users with what
will then be 'old stable' will not get a parse error when we introduce this for
footprints, and we can safely increment the format version later.
2016-05-10 15:07:35 -04:00
Maciej Suminski 35fe82739b Commented out 'override' keyword due to problems with older swig versions (see bug lp:1579042). 2016-05-10 14:35:36 +02:00
Maciej Suminski 7b669c1b03 Removed remaining traces of KICAD_SKIP_BOOST parameter. 2016-05-10 11:39:13 +02:00
jean-pierre charras 232c068bae Fix an issue in LOCALE_IO class, used to switch to/back locale "C" when reading/writing files: the back to locale was broken, and created issues in countries using the ',' as fp separator, especially when the non default language was used.
It was reported in many bugs.
2016-05-10 09:14:05 +02:00
jean-pierre charras ec096cc1d2 Fix an issue in LOCALE_IO class, used to switch to/back locale "C" when reading/writing files: the back to locale was broken, and created issues in countries using the ',' as fp separator, especially when the non default language was used.
It was reported in many bugs.
2016-05-10 09:11:09 +02:00
jean-pierre charras bfeb61abef Fix a few shadowed local variables and deprecated warnings in dialogs (using a very recent wxformbuilder version). 2016-05-10 08:56:03 +02:00
Maciej Suminski a42cb0ef8c OpenGL GAL: Set context in destructor when possible (under Linux the window has to be visible). 2016-05-09 18:00:34 +02:00
Maciej Suminski d8ca03b362 3D viewer: set right OpenGL context before freeing memory. 2016-05-09 17:59:59 +02:00
Maciej Suminski d9f4877c94 Fixed a crash when starting pcbnew with OpenGL GAL. 2016-05-09 17:23:01 +02:00
Maciej Suminski ad66af66af Highlight an item when context menu is displayed (GAL). 2016-05-09 10:41:11 +02:00
Maciej Suminski ce8f400645 Added menu for locking tracks & vias (GAL). 2016-05-09 10:29:06 +02:00
Maciej Suminski dd10c577ec Added SELECTION_CONDITIONS::OnlyTypes() variant that takes KICAD_T[]4 2016-05-04 18:35:20 +02:00
Maciej Suminski dfa963f31a Mark locked tracks with 'L' letter in status field. 2016-05-04 16:35:12 +02:00
jean-pierre charras 63decd70e6 Minor fixes: Fix a few shadowed local variables, and deprecated warnings is a few dialogs generated by wxFormbuilder (using a very recent wxFormbuilder version, after apr 25, 2016) 2016-05-06 17:15:30 +02:00
Collin Anderson 08b52131df Fix beep on hotkey press in OS X 2016-05-05 11:34:16 -04:00
Maciej Suminski 06637a17d6 Added 'Reset Grid Origin' hot key (GAL). 2016-05-04 14:59:14 +02:00
Maciej Suminski b735f57fa4 Refresh pads after enumeration in Footprint Editor. 2016-05-04 14:06:10 +02:00
Maciej Suminski f502c4cc77 Fixed stroke text initialization in PCB_PAINTER. 2016-05-04 12:18:25 +02:00
Maciej Suminski cca36d355a Remove unnecessary debug messages (OpenGL GAL). 2016-05-04 10:10:15 +02:00
Maciej Suminski 22c4e4d240 Set OpenGL context only when the parent window is visible. 2016-05-03 16:39:58 +02:00
Maciej Suminski 55976e39ef Fixed crash occuring when a vertex buffer is mapped in invalid OpenGL context. 2016-05-03 16:16:59 +02:00
Maciej Suminski a62d2b5412 Bigger net labels (GAL). 2016-05-03 15:15:08 +02:00
Maciej Suminski 25fa2bbbbd Fixed net names drawing in Cairo. 2016-05-03 14:40:47 +02:00
Maciej Suminski 8d952f35c6 Fixed text vertical alignment for bitmap font (OpenGL). 2016-05-03 11:58:48 +02:00
Maciej Suminski 2f874097ae Fixed a crash in pcbnew (GAL). 2016-05-02 16:15:26 +02:00
Maciej Suminski 09d2d5367a Store grid settings for GAL. 2016-05-02 16:15:25 +02:00
Maciej Suminski ed0b95d710 Added an option change grid style. Refactored DIALOG_SET_GRID. GAL can draw grid using lines or dots now. DIALOG_SET_GRID was refactored to use Transfer{From,To}Window() methods. 2016-05-02 16:15:24 +02:00
Maciej Suminski f3fae70fb2 Removed 'inline' keyword from virtual functions. 2016-05-02 16:15:24 +02:00
Maciej Suminski 58ed0c8cce Improved grid drawing routine (OpenGL). 2016-05-02 16:15:24 +02:00
Maciej Suminski 2f09e0ee40 Alternative version of CACHED_CONTAINER::defragmentResize() Certain GPUs do not support glCopyBufferSubData(), therefore there is an alternative version working with good, old memcpy(). 2016-05-02 16:15:24 +02:00
Maciej Suminski d23a508aa3 Fixed errors introduced to STROKE_FONT class. 2016-05-02 16:15:23 +02:00
Maciej Suminski 3e3ecccb2b A few more fixes related to the previous commit. 2016-05-02 16:15:23 +02:00
Maciej Suminski 6e881f51fd Changed bound buffers to improve compatibility (OpenGL GAL). 2016-05-02 16:15:23 +02:00
Maciej Suminski 0c4b6dabd3 Increased interglyph spacing to avoid artifacts when mipmapping is enabled. 2016-05-02 16:14:26 +02:00
Maciej Suminski fff3abc9a0 Support for overbars in bitmap fonts (OpenGL GAL). 2016-05-02 16:12:18 +02:00
Maciej Suminski c506d2b16c Set OpenGL context before freeing video resources. 2016-05-02 16:12:18 +02:00
Maciej Suminski 59fe8df269 Split bitmap text drawing routine into smaller functions (GAL). 2016-05-02 16:12:18 +02:00
Maciej Suminski a3a9641ae2 Disable invalidating buffer on CACHED_CONTAINER::Clear(). OpenGL context is not available when the method is called, so it does not work. 2016-05-02 16:12:18 +02:00
Maciej Suminski 031fbb4630 Avoid too frequent message panel updates. 2016-05-02 16:12:17 +02:00
Maciej Suminski 5a8adcdf52 Improved testing/profiling code for CACHED_CONTAINER. Switched from wxLogDebug to wxLogTrace. Adjusted CACHED_CONTAINER_TEST levels required for certain tests. Added a test to check used space in the container. 2016-05-02 16:12:17 +02:00
Maciej Suminski 54f3105cfb More changes to CACHED_CONTAINER. Removed m_itemSize field (error-prone, as it had to be synchronized with m_item->GetSize()) Fixed a bug in reallocate() method, changed a bit it is behaviour. VERTEX_ITEM is not stored in the item set if its size is 0. 2016-05-02 16:12:17 +02:00
Maciej Suminski deb578eadd Recognize a special case of completely filled/defragmented container when resizing. 2016-05-02 16:12:17 +02:00
Maciej Suminski a9c3a1730b Free chunks in CACHED_CONTAINER only if they are really not needed. 2016-05-02 16:12:16 +02:00
Maciej Suminski 702be4903f Vertices are stored in GPU memory (OpenGL GAL). 2016-05-02 16:12:16 +02:00
Maciej Suminski 01912aaabd Minor refactoring in CACHED_CONTAINER. 2016-05-02 16:12:16 +02:00
Maciej Suminski b32fdd97d9 Changed shading model to flat. 2016-05-02 16:12:15 +02:00
Maciej Suminski 52c698ab11 Fixed an included header (OpenGL GAL). 2016-05-02 16:12:14 +02:00
Maciej Suminski e2c8e07344 Enabled mipmapping for bitmap fonts. 2016-05-02 16:12:14 +02:00
Maciej Suminski 53ef29802f Switched bitmap font to higher resolution. 2016-05-02 16:11:39 +02:00
Maciej Suminski bacb2dd52a Adjusted required level of details for track labels to show. 2016-05-02 16:08:51 +02:00
Maciej Suminski 05a30b7591 Do not draw anything if vertex containers are empty. 2016-05-02 16:08:50 +02:00
Maciej Suminski 928d4e0404 SwapBuffers() contain an implicit glFlush() 2016-05-02 16:08:50 +02:00
Maciej Suminski fa6360a2ba Another way to select between dark/light netname labels. 2016-05-02 16:08:50 +02:00
Maciej Suminski bda3011519 Initial support for bitmap fonts (OpenGL GAL). 2016-05-02 16:04:45 +02:00
Maciej Suminski 431e343201 Switch to direct rendering before clearing the screen (OpenGL GAL). 2016-05-02 15:56:19 +02:00
Maciej Suminski 5ba84dda0a OpenGL capabilities test is run only once. 2016-05-02 15:56:19 +02:00
Maciej Suminski 82a63a8c2a Fixed the drawing order for selected items in OpenGL GAL. 2016-05-02 15:56:17 +02:00
Maciej Suminski 795fd28742 Set Stroke/Fill settings for stroke font in its Draw() function. 2016-05-02 15:56:17 +02:00
Maciej Suminski 36dd6eb6b3 GAL profiling output is enabled with WXTRACE env variable. 2016-05-02 15:56:17 +02:00
Maciej Suminski c0465e5519 Instance counter for OPENGL_GAL to avoid double freeing. 2016-05-02 15:56:16 +02:00
Maciej Suminski dbff9ad786 Improved error checking in GPU_MANAGER. 2016-05-02 15:56:16 +02:00
Maciej Suminski 4cca3bc368 Minor OPENGL_COMPOSITOR refactoring. 2016-05-02 15:56:16 +02:00
Maciej Suminski 1927f3a787 Unified way of checking OpenGL errors. 2016-05-02 15:56:14 +02:00
Maciej Suminski 2a276550eb Fixed SHADER::AddParameter() function. 2016-05-02 15:56:13 +02:00
Maciej Suminski b143ce6b0f Moved text settings from STROKE_FONT to GAL. 2016-05-02 15:56:12 +02:00
Maciej Suminski da312db7a4 Fixed a wxWidgets assertion. Newer wxWidgets (3.1) display a message saying that horizontal alignment flags are ignored with wxEXPAND. 2016-05-02 15:56:12 +02:00
Maciej Suminski f968556f9a Smoother autopanning. 2016-05-02 15:56:11 +02:00
Maciej Suminski 113e75c5c5 VERTEX_MANAGER functions return false in case of failure. 2016-05-02 15:56:11 +02:00
Maciej Suminski 4262915b38 Code formatting. 2016-05-02 15:56:10 +02:00
Maciej Suminski 0cfa360390 Added VERTEX_MANAGER::Reserve() function. 2016-05-02 15:56:10 +02:00
Matthew Petroff db54f3e7a7 Correct multiple UI spelling errors 2016-05-02 10:01:43 -04:00
jean-pierre charras e46f706d4b Add Set/GetOrientationDegrees and GetOrientationRadians for texts, pads and footprints to avoid internal units to usual angle units conversion in code (and avoid mistakes).
It should help if (or when) the internal angle unit used in kicad will be changed from 0.1 degree (a relic of code written for PCs without fpu) to degree ( a more natural unit).
2016-05-02 12:49:14 +02:00
unknown ce331b03e8 3D_cache/cmakelists.txt: Don't clear CMAKE_CXX_FLAGS compiler flags 2016-05-02 11:45:23 +02:00
Wayne Stambaugh 18c8f50b1d Component library editor field properties dialog improvements.
* Remove fixed dialog size setting to allow sizers to do thier job.
* General spacing and layout improvements.
2016-04-29 13:37:36 -04:00
Wayne Stambaugh 0a263d2f2b Fix value field editing bug in component library editor. (fixes lp:1576363)
* Allow editing value field for power components in the component library editor.
2016-04-29 12:01:09 -04:00
jean-pierre charras 8c76b92fa9 Fix a few shadowed local vars which make the code not so easy to analyze. 2016-04-29 13:10:31 +02:00
jean-pierre charras f532057d05 Fix incompatibility between basic_gal (which used angles in degrees in rotation) and other gal layers (which used radians in rotation). Rotation angles are now in radians.
Fix erroneous optimization in VECTOR2<T>::Rotate (which was made for angles in degrees): Angles are in radians, and only 0 rd rotation is skipped ( case very frequent, especially in eeschema)
2016-04-29 11:37:33 +02:00
jean-pierre charras b92ad6f5a8 Add CSV file format in pcbnew position files (and cleanup code) 2016-04-26 14:16:16 +02:00
jean-pierre charras 5da341d1fc Optimize VECTOR2::Rotation for 0, 90, 180 and -90 degrees by avoiding time consumming calculations. 2016-04-26 14:14:26 +02:00
jean-pierre charras c1f0ab91a2 Code cleaning and coding style fix. 2016-04-23 17:44:17 +02:00
Mikael Arguedas 5d6f8d1edc Eeschema: unify schematic and component library block mirror commands. 2016-04-22 10:15:16 -04:00
Wayne Stambaugh ce593f9784 Eeschema: fix broken component reference field in hierarchies. (fixes lp:1572812) 2016-04-22 09:29:47 -04:00
jean-pierre charras 53c031257d Fix a few shadowed local vars, and coding style issues. 2016-04-22 12:44:08 +02:00
unknown baa5f0ddfb Fix typos in dialogs. 2016-04-21 09:32:29 +02:00
jean-pierre charras d7f1400e44 Make strings only used in debug mode not translatable. 2016-04-21 09:19:08 +02:00
Wayne Stambaugh 2b6889bc7a Pcbnew: footprint text layer visibility improvements. (fixes lp:1527994)
* Always hide footprint text when the layer that the text resides is disabled
  in the layer manager.  There is no longer a difference between the value and
  reference text compared to other field text.
* The usual smattering of coding policy fixes and general code cleaning.
2016-04-20 11:28:44 -04:00
jean-pierre charras 67982a4851 stroke font: fine adjust of text horizontal position. edat_text: fix an issue in SetOrientation: the rotation angle is now constrained between -360 and +360 degrees.
It was previously not the case, and rotated texts outside this interval created issues in dialog_pcb_text_properties which have now validators.
2016-04-19 20:35:47 +02:00
Wayne Stambaugh 740f8f55d8 Developer documentation improvements.
* Convert user interface guidelines to markdown and add to the documentation
  created by Doxygen.

* Remove HOW_TO_CONTRIBUTE.txt.  This information is covered elsewhere.

* Remove wxWidgets_patch_notes.txt.
2016-04-19 10:30:32 -04:00
jean-pierre charras fde2cfee27 Minor changes: remove a few local shadowed local variables detected using " -Wshadow" gcc compil option ( No bug, just a better code readability ) and fix minor coding style issues. 2016-04-18 20:15:44 +02:00
Patrick Pereira b846a98199 Pcbnew: improve footprint edge plot logic. 2016-04-18 11:48:39 -04:00
Robert Antoni Buj Genlonch 8d8b357f45 Add Catalan translator to about dialog. 2016-04-18 11:26:56 -04:00
Wayne Stambaugh 46ff5a2580 Pcbnew: remove dead macro code. 2016-04-18 11:03:59 -04:00
Cirilo Bernardo 6120472d60 3D file name resolver improvements.
* Paths defined via pcbnew->Preferences->Configure Paths are now included in
  the 3D file browser's drop-down list except for KICAD_PTEMPLATES, KIGITHUB,
  KISYSMOD, any paths resembling a URL, and any non-existent paths. When an
  absolute path is shortened using one of these path aliases, let's say
  'KISYS3DMOD' then the name appears in the pcb file as "${KISYS3DMOD}/blah.wrl".
  If a user defines and actual environment variable with the same name, then
  that user defined variable will have precedence over the internally defined
  variable.

* Paths relative to the current project directory are no longer represented
  as "some/path/to/file.wrl".  For compatibility with previous KiCad versions
  it shall always be stored as ${KIPRJMOD}/some/path/to/file.wrl.

* Various restrictions on alias path values have been removed since the
  imposed restrictions could result in corrupted user data as aliases are
  silently dropped.

* Overall the patch should improve back-compatibility by providing a ${ENV_VAR}
  mechanism for supporting different model root directories and ensuring that
  paths relative to KIPRJMOD are expressed in a way that is compatible with
  earlier KiCad versions. This allows users more flexibility and the ability
  to work in a way that ensures 3D model files can be correctly resolved in
  earlier versions of KiCad. Users who do not care about back-compatibility
  may prefer to use the newer alias system.
2016-04-17 18:35:32 -04:00
jean-pierre charras 32fc9198c3 Minor fix: dialog_edit_component: Fix incorrect tool tip for the button which runs the footprint browser or the datasheet browser (previous was the same tooltip, regardless the purpose of this button), depending on the selected field. 2016-04-17 17:15:26 +02:00
Chris Pavlina ff3d22dcd9 Remove DIALOG_ORIENT_FOOTPRINTS 2016-04-17 10:11:14 -04:00
jean-pierre charras f0e2628e40 Very minor changes: remove a few local shadowed variables (mainly local variables having the same name in the same function) detected using " -Wshadow" gcc compil option ( No bug, just a better code readability ) 2016-04-16 11:57:42 +02:00
unknown 698197ec8d Eeschema: better position of texts (pin texts and labels), taking in account the line thickness. 2016-04-16 09:49:17 +02:00
jean-pierre charras bcd345c29f Fix issues in dialog drc: because it is not modal, DRC parameters and unit selection can be modified outside the dialog, still opened. Now, the new parameters are taken in account.
Fixa also a corner case which crashes Pcbnew: if the dialog is opened, and the board was  changed (reloaded, cleared),  pcbnew crashed because many pointers stored in dialog  become invalid. Now the dialog is just closed.
2016-04-15 20:15:22 +02:00
Robert Antoni Buj Gelonch e0a1bcac57 Add Catalan translator 2016-04-14 22:27:03 +02:00
jean-pierre charras 829fa97f3c Gerber files: ensure the "level polarity dark" is set in each file (this is the default, but ensuring that is better and can avoid issues when panneling files) 2016-04-14 09:32:35 +02:00
Chris Pavlina 36b53a50e9 Fix signedness in a couple comparisons (warning suppression) 2016-04-12 19:18:42 -04:00
Chris Pavlina 48573712e8 Exterminate another 0.1deg field 2016-04-12 19:18:33 -04:00
jean-pierre charras 95962cd2ba Very minor changes: minor coding style fixes, and remove a few local shadowed variables (mainly local variables having the same name in the same function) detected using " -Wshadow" gcc compil option ( No bug, just a better code readability ) 2016-04-12 17:50:42 +02:00
Wayne Stambaugh f239aee1ad Fix quasi-modal dialog mode in DIALOG_SHIM class.
* Add event handler to check all button clicks for default command event
  IDs and handle them appropriately by either calling EndQuasiModal() or
  passing the event up the event handler chain to allow the default dialog
  handlers to perform their magic.
* Add event handler to handle the close window event properly.
* Add scope brackets so the wxBusyCursor will stop being displayed when
  the footprint library loading is complete in CvPcb.
2016-04-11 19:39:43 -04:00
Chris Pavlina 9e3fd5b762 Nuke 0.1deg units in DIALOG_GRAPHIC_ITEM_PROPERTIES 2016-04-11 10:27:32 -04:00
Cirilo Bernardo 28d49b6589 fix race condition related to 3D cache and resolver
The attached patch fixes a segfault due to a race condition.
If a user starts eeschema with an empty sheet and clicks
the 'cvpcb' button, memory is corrupted and the program
segfaults. The issue appears to arise from multiple threads
accessing the 3D cache and resolver. This patch makes
relevant code thread-safe by using a wxCriticalSection.
2016-04-10 23:03:39 -04:00
Chris Pavlina 4d77388216 Clean up wxValidator window association
wxValidator::SetWindow was used too many times due to me being a dunderhead who
can't read the docs.
2016-04-10 18:28:06 -04:00
Chris Pavlina 8325d6fdf0 Eliminate 0.1deg units in DIALOG_PAD_PROPERTIES 2016-04-10 18:14:28 -04:00
Chris Pavlina 0a6583f902 Eliminate 0.1deg units in DIALOG_MODULE_BOARD_EDITOR 2016-04-10 08:59:23 -04:00
Chris Pavlina 4fe676753a dialog_edit_module_text: fix display bugs
Displayed angle should be clamped to -90..90, 0 should not be displayed as
blank text, and locale should be used for initial rendering.
2016-04-10 08:23:44 -04:00
jean-pierre charras f294834f4d dialog_pad_properties: Some fixes. Dialog_edit_module_text: fix an issue related to displayed texts, which were deleted and replaced by the unit symbol only, and the name of the parameter was therefore lost. 2016-04-10 12:40:31 +02:00
Chris Pavlina 3ac5fc41cc Refactor dialog_edit_module_text and nuke the 0.1 degrees 2016-04-09 16:17:19 -04:00
Chris Pavlina f12d87b800 Adjust spacing in dialog_edit_module_text 2016-04-09 10:32:46 -04:00
Patrick Pereira 342ba51e6d Allow arbitrary angles for footprint field texts 2016-04-08 19:18:44 -04:00
Wayne Stambaugh 5504c17787 CvPcb: remove footprint library load failure limit. (fixes lp:1553756)
* Remove the artificial footprint library read error limit to prevent
  potentially readable libraries from being loaded after the error limit
  is reached.
* Change error message dialog to an HTML dialog so that potentially large
  error messages can be displayed with scrolling and the ability to copy
  and paste the error message for bug reporting purposes.
* Add busy cursor when loading the footprint libraries so the user has some
  idea that something is happening while the footprint libraries are being
  loaded.
2016-04-08 12:45:11 -04:00
Wayne Stambaugh 0f89576f72 Eeschema: fix wxFileDialog assertion when importing component. (fixes lp:1558486)
* wxFileDialog ctor was setting the file name using the most recently used
  path which was incorrect.  Set the file path parameter to the most recently
  used path and the file name parameter to an empty string.
* Remove last used import path and use the application wide most recently
  path instead.
* Remove last used export path and use the application wide most recently
  path instead.
2016-04-08 09:05:07 -04:00
jean-pierre charras c146cc09eb Kicad: fix a crash when changing a project, if pcbnew was run and "Update PCB from Schematic" was run and Schematic editor never opened.
(In this case the schematic frame exists, but some members are not initialized as expected, and a crash happens when calling the schematic editor dtor)
Minor other fix: avoid multiple very similar strings to translate in 3d_filename_resolver.cpp
2016-04-08 14:11:05 +02:00
Cirilo Bernardo 973786d75d Fix 3D Coverity issue, other minor fixes
* CID 143740:  Null pointer dereferences  (NULL_RETURNS)
A few minor cut/paste and style issues in the 3D code are also fixed.
2016-04-07 18:54:14 -04:00
jean-pierre charras 5e41763d83 Fix a few Coverity warnings and typo is dialogs 2016-04-07 13:09:31 +02:00
jean-pierre charras 7f5c1f873d Pcbnew: Add rounded rectangle pad shape supoort. 2016-04-07 08:22:13 +02:00
Simon Richter a78a3f064e Drop dependency on <mm_malloc.h>
This appears to be unused.
2016-04-06 22:55:49 -04:00
Simon Richter 6a65341599 3D: Make file test more portable 2016-04-06 22:41:24 -04:00
Simon Richter 9f420e0e76 Fix condition for Windows-style DLL export 2016-04-06 22:41:07 -04:00
Mário Luzeiro ffc7740cc2 3D: fix bounding box assert and include order 2016-04-06 21:48:51 -04:00
Cirilo Bernardo c2a60d14d7 3D: fix issues reported by Coverity scan
*** CID 143752:  Incorrect expression  (USELESS_CALL)
*** CID 143751:  Incorrect expression  (UNUSED_VALUE)
*** CID 143749:  Uninitialized members  (UNINIT_CTOR)
*** CID 143748:  Uninitialized members  (UNINIT_CTOR)
*** CID 143747:  Uninitialized members  (UNINIT_CTOR)
*** CID 143746:  Uninitialized members  (UNINIT_CTOR)
*** CID 143745:  Uninitialized members  (UNINIT_CTOR)
*** CID 143744:  Uninitialized members  (UNINIT_CTOR)
*** CID 143740:  Null pointer dereferences  (NULL_RETURNS)
*** CID 143739:  Memory - corruptions  (MISMATCHED_ITERATOR)
*** CID 143735:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
*** CID 143734:  Error handling issues  (CHECKED_RETURN)
2016-04-06 21:41:52 -04:00
jean-pierre charras 4a838fb8c3 Pcbnew: Add rounded rect pad shape. 2016-04-06 20:15:49 +02:00
Cirilo Bernardo e1b308b3b1 fix segfault in python scripting caused by new 3D code
The attached patch ensures the S3D_MASTER class does not cause
a segfault in pcbnew when used from Python scripting.

The issue is due to an "extern KIWAY* TheKiway" which was exposed
to allow S3D_MASTER to use the new resolver to handle 3D filenames.
Unfortunately TheKiway cannot be assigned a value until a window is
created which implements Kiway. The change introduced by this
patch should not alter the behavior of S3D_MASTER compared to
the behavior before the 3D merge.

The extern variable is only there to support S3D_MASTER which in
turn is there to support the current 3DViewer. In the planned software
structure the rather complex S3D_MASTER class is replaced with
a simple struct which only holds the model name and position/
orientation/scale data as stored in the PCB file; since the replacement
does not perform filename resolution there is no need to expose the
Kiway. For example in Mario's branch we removed the extern and
S3D_MASTER class many months ago.
2016-04-05 20:32:50 -04:00
unknown 35e657806f Merge 3d_initial_merge branch 2016-04-05 19:57:38 +02:00
jean-pierre charras d18cdf1c53 merge 3d_initial_merge branch 2016-04-05 19:56:01 +02:00
Cirilo Bernardo 20b40aba1c Fixed bad delete/delete [] invocations and other warnings and errors as suggested by cppcheck 2016-04-05 20:32:22 +10:00
Wayne Stambaugh 30f5a7a7e1 Eeschema: fix field edit dialog power component warning bug.
* Prevent power component warning from being shown when edit normal component
  fields.
* Make text edit dialog size itself instead of using a fixed size.
* Improve the alignment and spacing in the text edit dialog.
2016-04-04 10:31:34 -04:00
Maciej Suminski 99e7e8c983 Disabled CACHED_CONTAINER freeing memory on GAL<->legacy switch. 2016-04-04 13:54:55 +02:00
jean-pierre charras 18cb83f5c7 OpenGL mode: Disable frequent (and not very usefull) memory deallocation/reallocation to avoid "out of memory" issue due to heap fragmentation (noticeable only with large boards).
Note: there is still this issue when switching back legacy mode  and to Opengl mode because the heap is still freed and reallocated.
2016-04-04 12:41:48 +02:00
Cirilo Bernardo 18bb852030 Removed incorrect special treatment of commas within VRML files 2016-04-03 10:56:41 +10:00
Cirilo Bernardo 2dfd8064d4 Fix filename resolution within VRML2 Inline{} 2016-04-03 10:55:22 +10:00
unknown b8a91c7a98 Enhancements in Create array tool (bad parameters detection and disable parms when not applicable) 2016-04-02 14:52:29 +02:00
Wayne Stambaugh 76d099b337 Eeschema: fix illegal field characters causing corrupt schematic files on Linux. (fixes lp:1529358)
* Refactor edit one field dialogs to use validators and transfer data to and
  from window functions.
* Add code to DIALOG_SHIM to handle validation and transfer functions since
  the base dialog class code is not called by EndQuasiModal().
* Add custom validator class for filtering field text control characters.
* Add new field validator to edit schematic component dialog field text
  control.
* Add new field validator to edit fields in library editor dialog field
  text control.
* Make a few LIB_PART member functions const.
2016-04-02 08:25:44 -04:00
unknown 78d96afe28 Eeschema: enhancement on Windows: adds a show console option for BOM plugin execution (needed for instance by python plugins which are run with pythonw) 2016-03-31 08:28:16 +02:00
Chris Pavlina fe53ec8c23 hotkeys: add defaults command to right-click menu
The new (eeschema, so far) hotkeys editor uses the right-click menu for the
reset command, so the reset-to-default function that was added in 6652
(git:0cd7476) was not accessible from eeschema.
2016-03-30 14:51:47 -04:00
Chris Pavlina 5ff3bbb96e eeschema: move part by a point on the grid (lp:1563587) 2016-03-30 14:19:32 -04:00
Chris Pavlina fd3835eb4f eeschema: fix component search result ranking 2016-03-30 10:23:37 -04:00
Chris Pavlina 67b4ba0225 eeschema: improve RemoveBacktracks() algorithm (lp:1562521)
Still isn't perfect, but removes an actual bug. It's still possible to get
weird things if you try hard, but they're not corrupt and don't trip
assertions. Consider a temporary fix.
2016-03-29 20:25:15 -04:00
jean-pierre charras 713e8d93f3 About dialog: small changes. EDA_HOTKEY class: better ctor. 2016-03-29 19:51:53 +02:00
unknown 0cd747668f Hotkeys Editor has now a "reset to default" button 2016-03-29 18:35:24 +02:00
jean-pierre charras 2efd31ef03 Fix a stupid bug I introduced in rev 6649 (eeschema: incorrect position of free texts in components) 2016-03-26 10:08:09 +01:00
jean-pierre charras a526984d9e Kicad about dialog: update links. remove dead link. 2016-03-25 18:05:25 +01:00
jean-pierre charras 426f7ebb2e Rework on class EDA_TEXT and related classes and draw text functions. More work: remove useless or duplicate code (from legacy graphic text plot functions). Move basic_gal code to separate files. 2016-03-25 09:33:45 +01:00
jean-pierre charras 92ce9c1193 Rework on class EDA_TEXT and related classes and draw text functions. More work: remove useless or duplicate code (from legacy graphic text plot functions). Move basic_gal code to separate files. 2016-03-25 09:26:11 +01:00
jean-pierre charras b7a60fb38e Eeschema: Fix issue in multiline text properties dialog editor: on wxWidgets 3.1, the enter key closes the dialog instead of inserting a new line in text.
Note: there is no issue on wxWidgets 3.0. So this issue is certainly due to some change in 3.1. (At least on Windows)
2016-03-24 14:19:31 +01:00
jean-pierre charras df1d10c824 Eeschema: Fix issue in multiline text properties dialog editor: on wxWidgets 3.1, the enter key closes the dialog instead of inserting a new line in text. 2016-03-24 13:28:50 +01:00
jean-pierre charras bc699c8d8f Rework on class EDA_TEXT and related classes and draw functions. More work. Eechema: in rotate texts: redraw the full screen to avoid garbage on screen. 2016-03-23 13:16:27 +01:00
jean-pierre charras b59a07128f Fix a compil issue on Jenkins 2016-03-23 09:27:12 +01:00
jean-pierre charras 30d72045e7 Rework on class EDA_TEXT and related classes and draw functions (Note: this is a work in progress):
* remove duplicate code between  draw functions and STROKE_FONT used in GAL. Use only  STROKE_FONT methods in draw, plot and test DRC function for texts. It remove slightly different shapes between GAL and other calculations.
* fix incorrect bounding box for texts with overbar. Especially noticeable for texts with overbar inside a copper zone in Pcbnew.
* fix a few minor other bugs related to graphic texts.
2016-03-23 08:41:47 +01:00
jean-pierre charras 8a753adc33 eeschema: Remove incorrect assert on Edit with Library Editor 2016-03-23 08:05:59 +01:00
Chris Pavlina db8c72cc9d Fix mistake in r6642 / git:bb9f1b0 2016-03-22 21:35:44 -04:00
Chris Pavlina bb9f1b00cd Fix graphics rendering on RTL systems (lp:1559545)
wx mirrors graphics by default on RTL systems; it is necessary to individually
set graphics canvases to LTR mode to avoid this.
2016-03-22 14:53:50 -04:00
Baranovskiy Konstantin f3ee0b8252 Pcbnew: prevent zone tool from switching to no tool when deleting zone corner. 2016-03-22 13:47:29 -04:00
Chris Pavlina d618585269 eeschema: fix printf format string 2016-03-22 11:17:02 -04:00
jean-pierre charras aea1f1be6d page layout reader: fix a minor issue in parseGraphic method. Update a old (incorrect) .kicad_wks file in demo. page_layout_writer.cpp: remove a few useless spaces in output files. 2016-03-22 10:46:18 +01:00
unknown b70f3c283d fix page_layout_default_description (missing parenthesis before the keyword "end" in a few lines) 2016-03-22 10:42:06 +01:00
Cirilo Bernardo 37ada5d04a Fix and improve IDF tools
The attached patch makes the following changes to the IDF
tool 'dxf2idf':

1. DXF units are now correctly scaled to mm
2. Polylines are now supported
3. LWPolylines are now supported
2016-03-21 22:53:32 -04:00
jean-pierre charras 99d18faca9 Change the way main editor frames are managed by Kicad: before this change, they had the Kicad manager frame as parent frame, and it creates a few issues:
- When the Kicad manager is iconized, all other child frames are iconized (normal wxWidgets behavior)
- For viewer frames in modal mode, there is a more annoying issue: they have the wxFLOAT_ON_PARENT frame style on unix, and wxSTAY_ON_TOP on Windows.
wxFLOAT_ON_PARENT frame style is incorrect (although on most WM it works) because the parent frame (Kicad manager Frame) is not the caller. It is usually a main editor frame.
It does not work on Windows (wx STAY_ON_TOP is used).
* Now each editor frame has a null parent.
Therefore iconizing the Kicad manager frame does not iconize other frames.
* Viewer frames have null parent in normal mode and the caller parent in modal mode (therefore wxFLOAT_ON_PARENT frame style is always and correctly used)
* References to opened/closed main frames are no more managed by the (complicated) kicad code. Instead of, a non critical and more easy to understand code just uses FindWindowByName to know if a main window exists or not.

These changes do not fix all issues about Kicad frames brought to the foreground or the background, but it fixes a few issues, and AFAIK do not add other issues.
2016-03-21 17:36:06 +01:00
Simon Richter 2d4845ddae Enable C++11 support. 2016-03-21 11:11:29 -04:00
Cirilo Bernardo 978268250e Removed temporary printout used for debug 2016-03-21 21:32:26 +11:00
Cirilo Bernardo e4b074f04f Added PolyLine support and units scaling to the dxf2idf tool 2016-03-21 18:48:35 +11:00
Cirilo Bernardo 80f8e74797 Make changes to GLM header includes as per suggestions by Mario Luzeiro 2016-03-21 18:39:25 +11:00
Cirilo Bernardo 44a75e6f69 Sync to main branch r6634 2016-03-21 13:38:47 +11:00
Cirilo Bernardo a4ba01f42d Various fixes to DXF import
The attached patch makes the following changes to import DXF:

1. correctly implements scaling based on DXF $INSUNITS -
at least where INSUNITS is sensible. I ignore units like miles,
gigameters, AU, lightyear, parsec ...

2. correctly implements LWPolylines, adding an ARC segment
rather than a line segment when bulge != 0.  A number of users
have been complaining about getting the wrong board shape
(chamfered corners rather than rounded corners) on DXF Import,
now they shouldn't complain.
2016-03-20 21:33:53 -04:00
Cirilo Bernardo 10c8a57c59 Fixed timestamp checking code to use canonical filename 2016-03-21 07:21:54 +11:00
jean-pierre charras 30f113c2de Remove a change which was committed by accident in rev 6632 2016-03-20 19:49:04 +01:00
jean-pierre charras 6e93672760 Icons: remove not used icons. 2016-03-20 18:52:15 +01:00
unknown 82b3744ddd fix very minor issue: Eeschema creating extra whitespace in .lib 2016-03-20 15:53:02 +01:00
Jon Neal 00f9dbd095 Change misspelled dxf conversion constant from member variable to static const like other conversion constants 2016-03-19 23:51:02 -04:00
Cirilo Bernardo aa16666d72 Added file modification check to model cache code 2016-03-20 11:45:55 +11:00
Chris Pavlina 60d93d024c pcbnew: don't pick up selection after unsuccessful Duplicate
Following rev 6627 (git 2777182), if a non-duplicatable item was the object of
a Duplicate action, the original item would be picked up, potentially
misleading the user into thinking something was actually duplicated.
2016-03-18 07:15:50 -04:00
Chris Pavlina fd1d7ecb6e pcbnew: fix Duplicate assertion in legacy also (lp:1558913)
Do not assert that the item to be duplicated can be duplicated, just don't
duplicate it. The user can trigger a Duplicate on items that aren't
duplicatable, like field texts - he'll figure out that they can't be duplicated
when they aren't, no need to deliver a scary warning and risk an abort.
2016-03-18 06:49:49 -04:00
Chris Pavlina 2777182a2c pcbnew: fix Duplicate assertion
Do not assert that the item to be duplicated can be duplicated, just don't
duplicate it. The user can trigger a Duplicate on items that aren't
duplicatable, like field texts - he'll figure out that they can't be duplicated
when they aren't, no need to deliver a scary warning and risk an abort.

TODO: Don't pick up the duplicated selection if none of the items in it were
actually duplicated, it's misleading.
2016-03-18 06:28:11 -04:00
Jon Neal d66cc0fedc Fix one click dialog footprint spreading picking up extra footprints. 2016-03-17 23:09:24 -04:00
dwilches 1c19699a7c Fix Preferred Editor dialog (lp: 1558353)
The functions involved in the problem were PGM_BASE::GetEditorName and
EDA_BASE_FRAME::OnSelectPreferredEditor:

1) OnSelectPreferredEditor showed a dialog to allow the user selecting the
editor, but before that called GetEditorName to get the name of the current
editor (to show as a default in the choose file dialog).

2) The problem was when there was no editor, GetEditorName showed its own
dialog.

3) So the user was seeing first the dialog from (2) and then the dialog from
(1).

4) As GetEditorName is used in many other places the solution I did was to add
to it an optional parameter that tells it what to do if no editor is set. To
avoid modifying other code that relies on the current behaviour, this parameter
has a default value that causes to show the dialog. But now when
OnSelectPreferredEditor calls it, it passes the parameter that causes it to
return an empty string if no editor was set.

5) Also, I found a second bug while doing it which allowed in the first dialog
to select an unexistent file (the dialog was missing the wxFD_FILE_MUST_EXIST
flag).

6) Lastly, to avoid having duplicated code (the one that showed the same dialog
and that configured the wildcard was in two methods) I created a single
function that now both functions call: PGM_BASE::AskUserForPreferredEditor.
This way we also will have consistency in the behaviour of both dialogs and
there is a single place where it needs to be modified.
2016-03-17 16:59:35 -04:00
Tomasz Włostowski aa5a1d1898 PCB updater: spread footprints after updating netlist 2016-03-16 23:05:08 -04:00
jean-pierre charras 5de85450b8 Pcbnew: Dialog list and select net: better dialog and make net selection to highlight a net working on GAL. 2016-03-16 15:14:00 +01:00
jean-pierre charras b116318df9 Eeschema: fix a stupid bug which prevents the netlister to output the right pin electrical type in netlist. 2016-03-15 12:29:16 +01:00
Cirilo Bernardo 491e0250c0 Suppress dialog pop-up when 3D file resolver does not find a file 2016-03-15 11:39:28 +11:00
Cirilo Bernardo a30151231f Fix invocation of glm::cross and glm::normalize 2016-03-15 11:38:55 +11:00
Wayne Stambaugh b7c974b2c4 MinGW64 build warning fixes.
* On MinGW64 and possibly other 64-bit platforms, time_t is defined as a long
  long unsigned integer but all of the scanf and printf format specifiers used
  to save and load the schematic files are %lX which is a long unsigned integer
  which causes compile warnings.  Add casts and temporary variables to eliminate
  the compile type warnings.
2016-03-14 14:20:19 -04:00
Cirilo Bernardo 968a18a859 Sync with main branch r6620 2016-03-14 19:00:24 +11:00
Cirilo Bernardo 30f9aba7c9 Work on SG consistency checks: fixed a number of bugs and improved integrity checking when writing cache files 2016-03-14 12:30:59 +11:00
jean-pierre charras 44fc6cb337 Fix issue: "Malformed footprint causes crash on load" (in fact, no crash: just an assert dialog is shown) 2016-03-13 16:39:18 +01:00
unknown 3ba4226cb2 pcbnew: fix exception when import pcad pcb with zero size pads: zero size pads are now just ignored. 2016-03-13 11:41:14 +01:00
Chris Pavlina b521c91a6b Display "Finished" message for eeschema ERC
pcbnew DRC displays this as well; a user pointed out that when there are no
errors, it can be hard to tell that ERC ran at all.
2016-03-11 19:23:44 -05:00
Simon Wells 145cd47d5c Move copy version information code to about dialog. 2016-03-11 11:40:24 -05:00
Nick Østergaard 61eb65f0e9 Documentation: add missing dependency to compiling with msys2. 2016-03-11 08:20:31 -05:00
jean-pierre charras 99e81aeb9c Fix incorrect (too small) bounding box EDA_TEXT, noticeable when chars like j or { are used in zone fill functions.
I tried to merge some constants used both in legacy mode and gal mode (which were, before this patch, separate constants).
There is still a serious work to avoid different calculation code for the same text in draw and plot functions.
Work in progress to merge these calculation functions.
2016-03-11 13:08:34 +01:00
Cirilo Bernardo 0085d1aea7 Fixed unsigned vs signed int comparisons 2016-03-11 09:37:39 +11:00
Cirilo Bernardo ec580cff50 Sync to main branch r6614 2016-03-11 09:37:12 +11:00
Chris Pavlina 3fd179cd10 pcbnew: remove dead legacy save code 2016-03-08 15:49:25 -05:00
Simon Wells ef3aa01e7d Minor internal spelling correction 2016-03-08 14:03:16 -05:00
jean-pierre charras b237d81b75 Create Array dialog: some fixes:
*  No initial copied object changed (this was a serious bug to modify these objects. Previous version modified references and other texts using a very stupid algorithm).
  It also fixes bug 1549231
* only new pads are numbered (therefore renumbering is used only in footprint editor)
*  remove not working and useless feature in circular array: now  only use number for pads (others options using alphabetical letters are removed: did not work corectly, and were useless)
* a more clear option is used to choose if the pads are numbered from a choosen value, or from the first avaible value
* Adding a warning messsage if a parameter is incorrect.
2016-03-07 08:13:06 +01:00
Wayne Stambaugh 92f5ab8589 Eeschema: SCH_SHEET_LIST improvements.
* Derive SCH_SHEET_LIST from std::vector rather than using internal array
  management.  Change all internal code to use iterators or array operator
  in loops.
* Allow creation of empty SCH_SHEET_LIST for external population for plotting
  and printing.
* Clean up print an plot code to take advantage of new SCH_SHEET_LIST behavior.
* Make BuildSheetList() public so list can be populated after creation.
* Update all instances of SCH_SHEET_LIST with the appropriate SCH_SHEET
  object on initialization.
* Create const and non-const version of SCH_SHEET_PATH::GetSheet().
2016-03-06 16:22:01 -05:00
jean-pierre charras 0d1395ee08 Fix coverity warnings:
CID 135848:  Memory - illegal accesses
CID 135846:  Class hierarchy inconsistencies
2016-03-06 09:31:00 +01:00
Chris Pavlina b9be9a4f57 Common: delete accidental dead branch (Coverity)
CID 135586 in widget_hotkey_list: logically dead code

This code was added accidentally; it is both dead and unnecessary, and so was
removed.
2016-03-05 23:13:25 -05:00
Cirilo Bernardo 317ec48e1b Sync with main branch r6608 2016-03-05 10:00:32 +11:00
jean-pierre charras ba038ac507 Pcbnew, File menu: break Open (board) into 2 menu items: Open (only for Kicad board files) and Import (only for non Kicad board files) 2016-03-04 19:48:08 +01:00
Cirilo Bernardo ae104a2b77 Sync to main branch r6607 2016-03-04 16:30:42 +11:00
jean-pierre charras 8dc0a33cc7 Remove a old useless font file (the Cyrillic fonte is, since a long time, in the current font file) 2016-03-03 18:51:38 +01:00
Cirilo Bernardo dbe54067f9 Reverted/reworked BoardEdtor_base and Modedit_base *.fbp files to wx3.5-RC1 version due to bug in -RC2 2016-03-02 13:36:24 +11:00
Cirilo Bernardo 862cd7e5a4 Fix event processing on C3D_MODEL_VIEWER to allow click-to-focus 2016-03-02 12:29:20 +11:00
Cirilo Bernardo 5e0e2538d0 Added comments to 3D Plugin CMake files regarding debugging output 2016-03-02 10:25:21 +11:00
Mário Luzerio d4655020f9 Fix zoom issue on MSWin (wxCanvas requires focus) 2016-03-02 07:50:32 +11:00
Bernhard Stegmaier 59f6a720f0 Fix touchpad scrolling on OSX. 2016-03-01 15:19:00 -05:00
unknown eea52027cc Use _WIN32 instead of __MINGW32__ in 2 conditional compilations which are Windows specific, not especially mingw32 specific. 2016-03-01 16:55:44 +01:00
Chris Pavlina c7fecfa69e Fix character encoding of two source files
These had quotes and dashes from Windows-1252, replaced with ASCII
2016-03-01 09:39:17 -05:00
jean-pierre charras 624c508dda Fix an issue relative to the env vars initializations on Linux: they are not initialized if the value contains any non ASCII7 char, and if the locale is not set.
The locale is now set before reading the env vars configuration.
2016-03-01 14:37:15 +01:00
Tomasz Wlostowski 0fa71d8d8f more accurate pushout force calculation for circle-segment collisions 2016-03-01 14:26:08 +01:00
Cirilo Bernardo d0a2080823 Merge with main branch r6601 2016-03-01 11:44:15 +11:00
Bernhard Stegmaier 5b0a250609 Fix compilation and install for OSX plus general code cleanup 2016-03-01 10:08:19 +11:00
Wayne Stambaugh bd800630be Pcbnew: prevent delete hot key from deleting locked footprints. (fixes lp:1538805) 2016-02-29 16:12:03 -05:00
Simon Wells 4d2a05856f Minor CMake configuration file fixes.
* Move add_directory()s in main CMakeList.txt after all find_package()
  macros are run so all flags in the main CMakeList.txt are propagated
  to the sub-folder CMakeList.txt files.
* Remove commented out include of config.h
* Make the link maps only build on linux as -${TO_LINKER},-cref
  -${TO_LINKER},-Map=blah just gives warnings on osx w/ clang
* Make the link maps only build with flag -DKICAD_MAKE_LINK_MAPS is
  defined during CMake configuration as they are highly specific.
* Moved the code for setting link maps into the main CMakeList.txt
  file to avoid duplication.
* Removed -D__ASSERTMACRO__ from osx as its no longer needed
* Removed a couple of other OSX only things that wouldn't work anyway
* Moved set (BU_CHMOD_BUNDLE_ITEMS) to the main CMakeList.txt as
  otherwise it would only work for the KiCad build not the other
  applications
* Made KICAD_SCRIPTING_MODULES enable KICAD_SCRIPTING as currently if
  you have modules enabled without the scripting base it will on build.
  This could be changed to a fatal error saying you need to also enable
  scripting but it seems unnecessary.
* Removed duplication of pcbnew.py install code under modules and
  scripting since you can't have modules without scripting now
2016-02-29 14:08:03 -05:00
jean-pierre charras 8522b0deb7 Rename enum TypeSheetLabel to PINSHEETLABEL_SHAPE (Better name, and in accordance with our coding style policy) 2016-02-28 19:16:59 +01:00
unknown 4b103baa3a Enum refactoring and shiny icons in dialog_lib_edit_pin_table 2016-02-28 18:33:29 +01:00
jean-pierre charras a0fd827986 Update potrace library from 1.12 to 1.13, due to a bug fix in 1.13 2016-02-28 18:04:51 +01:00
Simon Wells 8994bd1041 Remove redundant file
Function is provided by events_called_functions.cpp
2016-02-28 11:29:47 -05:00
Cirilo Bernardo 4d20f32fd0 Added 'Configure Paths' button to Footprint Properties editors 2016-02-28 10:17:58 +11:00
Wayne Stambaugh b7e56ae1cb Eeschema: SCH_SHEET_PATH refactor.
* Derive SCH_SHEET_PATH from std::vector< SCH_SHEET* > and remove unnecessary
  assignment operator and list management functions.
* Remove function BuildSheetPathInfoFromSheetPathValue() since it was
  effectively an assignment operation.
* Replace all calls to BuildSheetPathInfoFromSheetPathValue() with assignment
  operator.
* Replace list management functions with vector management functions.
* Fix a error message that wasn't translatable.
2016-02-27 14:35:45 -05:00
Eldar Khayrullin 89ea49ff14 Pcbnew: PCAD2KICAD text conversion improvements.
* Fix text justification.
* Fix caret return symbol.
* Fix size of proportional font.
2016-02-27 12:33:38 -05:00
Bernhard Stegmaier 04000883f3 Fix 3d-viewer regressions introduced by touchpad-panning for non-touchpad-panning.
* Fix broken horizontal scrolling with ctrl-wheel
* Restore previous step size
2016-02-26 17:19:22 -05:00
Cirilo Bernardo 0b18af3fdb Changed resolver failure message to use wxLogMessage instead of wxMessageBox 2016-02-26 15:18:59 +11:00
Cirilo Bernardo 37c85113ee Changed resolver failure message to use wxLogMessage instead of wxMessageBox 2016-02-26 15:16:55 +11:00
Cirilo Bernardo 097ac3a6b7 Changed resolver failure message to use wxLogMessage instead of wxMessageBox 2016-02-26 15:14:20 +11:00
jean-pierre charras a9427f8999 CvPcb: fix incorrect tool tip message. 2016-02-25 19:48:47 +01:00
jean-pierre charras 8c1b91255c Fix compil issue. 2016-02-25 15:38:08 +01:00
jean-pierre charras 53b52b08c9 CvPcb, filtering fp list by wildcard: Remove dialog to enter the filtering pattern. Use a wxTextCtrl permanently shown in toolbar. The fplist is updated immediately after editing the pattern. 2016-02-25 14:57:59 +01:00
jean-pierre charras 08e68fce44 Fix compil issue created in rev 6588. 2016-02-25 11:35:27 +01:00
jean-pierre charras a28b1cefc3 CvPcb: serious code cleanup (work in progress): Remove dead or outdated code. Fix a lot of coding style issues. Use better code in many places. No new features. 2016-02-25 10:52:29 +01:00
Cirilo Bernardo e7c32873ea Remove bad default behavior of adding current working dir to default search path 2016-02-25 14:31:59 +11:00
Cirilo Bernardo 611d5de179 Removed code stubs for WWWInline support in VRML1; the construct will not be supported 2016-02-25 13:30:21 +11:00
Cirilo Bernardo b2bdca4b7b Remove wxASSERT in new cbbox code which was a nuisance to the legacy 3DViewer 2016-02-25 09:52:00 +11:00
Simon Wells 1c0a0c4bfe Kicad: clean up include files. 2016-02-24 16:36:52 -05:00
Bernhard Stegmaier f8abe9c191 Add support for optional touchpad panning. 2016-02-24 14:53:02 -05:00
lukasz.iwaszkiewicz@gmail.com 0829446c86 Add CvPcb footprint search and filter by name. 2016-02-24 17:30:35 +01:00
jean-pierre charras 38b9fcd4c1 Remove outdated svg file. 2016-02-24 13:06:19 +01:00
unknown 11da247aa1 Fix issues in PCAD import of P-CAD ASCII files. 2016-02-24 12:56:40 +01:00
unknown 3d635bca01 Add QFN Footprint generator python script 2016-02-24 09:48:55 +01:00
jean-pierre charras cf09129387 Python interface: add methods to add or remove layers to/from a layer set. Usefull to modify the layer set of pads
Very minor other fixes.
2016-02-24 09:45:34 +01:00
Wayne Stambaugh bedf0b6aec Remove incorrect comment regarding wxWidgets bug report from class_bitmap_base.cpp. 2016-02-23 19:31:34 -05:00
Cirilo Bernardo 5306db0c98 Added missing include to 3d_plugin_manager 2016-02-24 07:26:58 +11:00
Cirilo Bernardo 4c809f0f13 Sync with main branch r6579 2016-02-23 18:31:54 +11:00
Cirilo Bernardo 9195451e12 Switched SG* classes and plugin loader logging code from stderr to wxLogTrace 2016-02-23 17:46:22 +11:00
Cirilo Bernardo d051a8f47e Changed IFSG* log reports from stderr/stdout to wxLogTrace 2016-02-23 16:28:41 +11:00
Cirilo Bernardo c98ebdb8f0 Changed 3d_cache log reporting from stderr/stdout to wxLogTrace 2016-02-23 14:33:24 +11:00
Cirilo Bernardo c5984b207b Changed IDF plugin debug log from stderr to wxLogTrace 2016-02-23 13:42:51 +11:00
Cirilo Bernardo b0a26f32ef Fixed bugs in VRML/X3D parser log code 2016-02-23 13:37:35 +11:00
Cirilo Bernardo d2a13efc12 Changed VRML2 parser debug output from stderr to wxLogTrace 2016-02-23 13:31:51 +11:00
Cirilo Bernardo 2f8c55cd99 Fixed segfault on getSHA1 (fopen result was not checked) 2016-02-23 11:38:58 +11:00
Cirilo Bernardo d6af042c64 Revert accidental change to VRML logging levels 2016-02-23 11:21:15 +11:00
Cirilo Bernardo 14178ee521 Change logging of X3D and VRML1 parsers from stderr to wxLogTrace 2016-02-23 11:20:34 +11:00
Nick Winters 8cb1f39ed5 OSX: fix bug caused by wxBitmap drawing 0 width or heigth bitmap. (fixes lp:1529159) 2016-02-22 16:23:17 -05:00
jean-pierre charras 60ac4f7ee3 Pcbnew: fix a crash when trying to export a footprint in a non writable directory, or if a non writable old file was existing. (Linux only. On Windows, the wxWidgets file dialog dectects this issue) 2016-02-22 15:38:35 +01:00
jean-pierre charras b30f1c69fb Remove unused files. 2016-02-22 15:35:46 +01:00
Cirilo Bernardo 0d14fd0f9b Fix scaling bug in vrml2_box.cpp 2016-02-22 20:00:23 +11:00
Cirilo Bernardo 684e41358a Added support for VRML2 Inline{} 2016-02-22 19:59:07 +11:00
Cirilo Bernardo af0ac955b9 Merge with main branch r6576 2016-02-22 19:58:32 +11:00
Cirilo Bernardo 970955d1a2 Improved non-compliant VRML1 model support by processing all top-level nodes (spec. mandates single top-level node which must be a grouping node) 2016-02-22 11:57:16 +11:00
Cirilo Bernardo 52e093087e Relaxed VRML1 parsing rules to support yet more non-compliant models 2016-02-22 09:42:47 +11:00
Cirilo Bernardo 5776037a70 Flush model data upon exit of Footprint Properties dialogs 2016-02-21 11:54:34 +11:00
unknown d7e2ffe8fb Update comments (ElectricPinType -> ELECTRICAL_PINTYPE) 2016-02-20 20:07:05 +01:00
unknown 79422f929e Update comments (ElectricPinType -> ELECTRICAL_PINTYPE) 2016-02-20 20:00:22 +01:00
Wayne Stambaugh 9685b3812d Eeschema: decouple SCH_SCREEN::SchematicCleanUp() from wxDC and EDA_DRAW_FRAME.
* Remove wxDC and EDA_DRAW_FRAME parameters from SCH_SCREEN::SchematicCleanUp()
  function call.
* Update all code that calls SCH_SCREEN::SchematicCleanUp() with wxDC and/or EDA_DRAW_FRAME
  parameters.
* Fix a display refresh bug when incrementally inserting bus entries created in my last commit.
  IsDanglingStateChanged() appears to be broke for bus entries.
2016-02-20 09:59:42 -05:00
jean-pierre charras c379df06bb Remove CK1202_V1.pcb sample file, actually not used in Kicad, due to its unclear copyright. The http link to this sample file is in files.txt. 2016-02-20 08:50:54 +01:00
Simon Richter e220a50958 Eeschema: minor dialog fixes.
* Fix parent of elements in wxSizers.
* Update old dialog with recent version of wxFormBuilder.
* Add wxALIGN_CENTER_VERTICAL flag to some dialogs.
* Update wxFormBuilder timestamp in generated sources.
2016-02-19 18:25:03 -05:00
Wayne Stambaugh ce9d9afed5 Fix bug in component library editor. (fixes lp:1547299)
* Use temporary storage of new pins to prevent corruption of the library part draw items
  list when adding alternater body style pins to existing component which caused segfault.
2016-02-19 16:29:56 -05:00
jean-pierre charras 37c26cba71 Eeschema: Do not use ElectricPinType for SheetLabel items. ERC does not use ElectricPinType to test sheet labels, which do net have an actual electrical type property
Replace ElectricPinType by ELECTRICAL_PINTYPE as enum name to be compliant with coding style.
Enforce ELECTRICAL_PINTYPE control in methods.
2016-02-19 17:51:23 +01:00
unknown 8a9c6f71b7 Make pin position and pin type columns sortable in dialog_lib_edit_pin_table. 2016-02-19 16:59:31 +01:00
Wayne Stambaugh 306b964b40 Eeschema: decouple SCH_SCREEN::TestDanglingEnds() from wxDC and EDA_DRAW_PANEL.
* Remove wxDC and EDA_DRAW_PANEL as parameters from function
  SCH_SCREEN::TestDanglingEnds().
* Change SCH_SCREEN::TestDanglingEnds() to return the connection change state
  rather than the dangling end status which wasn't used anywhere.
* Update all calls to SCH_SCREEN::TestDanglingEnds() to remove wxDC and
  EDA_DRAW_PANEL parameters and refresh connection indicators only if a
  connection state change occurred.
2016-02-19 10:41:32 -05:00
jean-pierre charras d1559b129d Pcbnew: fix 2 issues:
* File import: use case insensitive comparison to choose import plugin, from the file extension (It is not always in lower cases, especially on Windows.)
* onleftclick.cpp: fis a minor issue, which happens after switching form GAL to Legacy canvas: sometimes a board item is left selected from GAL, and creates false warning message in legacy.
2016-02-19 15:10:23 +01:00
unknown c2fd462dd6 Footprint generators in Python: add a rounding method to put a coordinate on a grid (PutOnGridMM and PutOnGridMils) . 2016-02-18 18:53:39 +01:00
unknown fb17b3fa17 Set SMD attribute in footprint python generators 2016-02-18 15:29:30 +01:00
jean-pierre charras ca5e66a57f Fix Bug #1545708 (global bus labels ignored). This is a very old bug. 2016-02-18 08:40:45 +01:00
Cirilo Bernardo 25a5db9092 Sync with main branch r6563 2016-02-18 13:15:44 +11:00
Simon Richter be2f79af28 FindwxWidgets.cmake: synchronize with upstream as far as sensible. 2016-02-17 18:50:21 -05:00
unknown 78d0cfc1a4 Fix Bug #1545668 (Pcbnew can't open P-CAD ASCII files) 2016-02-17 16:38:30 +01:00
Wayne Stambaugh 0ac8aad082 Revert Eeschema refactoring work due to broken handling of complex hierarchies. 2016-02-16 10:28:27 -05:00
Bernhard Stegmaier 5d25b4ef90 Disable FPS limiter for OSX (GAL). 2016-02-16 09:05:41 +01:00
Cirilo Bernardo f247b05b3e Merged Mario's fix to Material + per-vertex colors and transparency 2016-02-16 08:07:17 +11:00
Wayne Stambaugh 97949ffde9 Undo commit -r 6353. 2016-02-15 15:24:59 -05:00
Wayne Stambaugh 03bf559465 Undo commit -r 6368. 2016-02-15 15:22:45 -05:00
Wayne Stambaugh af2e19d7d9 Undo commit -r 6380. 2016-02-15 15:21:18 -05:00
Wayne Stambaugh 3d963166c7 Undo commit -r 6389. 2016-02-15 15:19:22 -05:00
Wayne Stambaugh 73dc53dc35 Undo commit -r 6413. 2016-02-15 15:18:32 -05:00
Wayne Stambaugh 4007317606 Undo commit -r 6428. 2016-02-15 15:17:51 -05:00
Wayne Stambaugh 1866b61a56 Undo commit -r 6457. 2016-02-15 15:16:54 -05:00
Wayne Stambaugh 8587488984 Undo commit -r 6595. 2016-02-15 15:15:51 -05:00
Wayne Stambaugh 27b587025d Undo commit -r 6506. 2016-02-15 15:14:48 -05:00
Wayne Stambaugh 5a5fffb349 Undo commit -r6509. 2016-02-15 15:14:07 -05:00
Wayne Stambaugh 663394749d Undo commit -r 6533. 2016-02-15 15:13:27 -05:00
Wayne Stambaugh 7b5823185a Undo commit -r 6535. 2016-02-15 15:12:42 -05:00
Wayne Stambaugh 9eda45a97e Undo commit -r 6539 2016-02-15 15:11:50 -05:00
Wayne Stambaugh ee23342e31 Undo commit -r6541. 2016-02-15 15:10:57 -05:00
Simon Richter 4ee956d77a FindwxWidgets.cmake: Remove extra newline 2016-02-15 18:50:49 +01:00
Simon Richter ff99b51b7d FindwxWidgets.cmake: Report failure of wx-config when looking for components 2016-02-15 18:50:49 +01:00
Simon Richter 4c29843813 FindwxWidgets.cmake: Use ENV foo rather than ENV{foo} 2016-02-15 18:50:49 +01:00
Simon Richter 9d08d93c26 FindwxWidgets.cmake: Add comment describing code block 2016-02-15 18:50:49 +01:00
Simon Richter 380bb37931 FindwxWidgets.cmake: Reformat documentation 2016-02-15 18:50:49 +01:00
Simon Richter c109abb87e FindwxWidgets.cmake: Do not explicitly declare FOUND_VAR, unnecessary 2016-02-15 18:50:49 +01:00
Simon Richter 801611fad8 FindwxWidgets.cmake: Drop nonsensical assignment
No idea where that came from, but it is almost certainly an error.
2016-02-15 18:50:48 +01:00
Simon Richter f7d8a412cf FindwxWidgets.cmake: Determine version even when not asked to 2016-02-15 18:50:48 +01:00
Simon Richter 029a3ba61e FindwxWidgets.cmake: Improve regex for version number matches 2016-02-15 18:50:48 +01:00
Simon Richter 2f1bbdc0f3 FindwxWidgets.cmake: Simplify MATCHES
Arbitrary characters at beginning and end of the line are implicitly allowed anyway
2016-02-15 18:50:48 +01:00
Simon Richter ea4c8c546f FindwxWidgets.cmake: Expect directory layout for MSVC 64 bit
On 64 bit MSVC, the DLLs and import libraries are placed in a directory
called vc_x64, to allow parallel installation of 32 and 64 bit wxWidgets.
2016-02-15 18:50:48 +01:00
Simon Richter 51a1588456 FindwxWidgets.cmake: documentation for variables 2016-02-15 18:50:48 +01:00
Simon Richter bbd0c539e9 FindwxWidgets.cmake: Look for versioned wx-config scripts 2016-02-15 18:50:48 +01:00
Simon Richter bc480a010b FindwxWidgets.cmake: Fix indentation 2016-02-15 18:50:48 +01:00
Simon Richter 38359272c4 FindwxWidgets.cmake: Show line number in debug output 2016-02-15 18:50:48 +01:00
Simon Richter 9ff394e72a FindwxWidgets.cmake: Treat CygWin as unix rather than undefined 2016-02-15 18:50:48 +01:00
Simon Richter b66a584a8a FindwxWidgets.cmake: Use lowercase for CMake builtins 2016-02-15 18:50:48 +01:00
Simon Richter 6a7fa8950c FindwxWidgets.cmake: Use uppercase for macro names 2016-02-15 18:50:47 +01:00
Simon Richter 78a0316a08 FindwxWidgets.cmake: Use uppercase for DBG_MSG macro 2016-02-15 18:50:47 +01:00
Simon Richter b7adcb3728 FindwxWidgets.cmake: drop a few dbg_msg invocations 2016-02-15 18:48:40 +01:00
Simon Richter 86d072b5d1 FindwxWidgets.cmake: Remove arguments from else() and end*()
To reduce differences with upstream FindwxWidgets.cmake, use their style of
ending blocks.
2016-02-15 18:48:40 +01:00
jean-pierre charras 5b1a5cbdce Eeschema: Files menu: better name and better comment for the Import sheet content from a project in the current sheep command. 2016-02-15 16:58:35 +01:00
jean-pierre charras 90d6e7568e Gerbview: fix Bug #1511654 (incorrect rendering of some filled polygons in some Gerber files) 2016-02-15 14:16:49 +01:00
jean-pierre charras 8931df339e Fix incorrect assertion failure in specctra export, when a footprint contains segments on edge.cut layer (Bug #1545546) 2016-02-15 09:55:10 +01:00
unknown aa6beaaba0 Python footprint generators: fix a typo and fix text size (accordance KLC 6.9) 2016-02-14 10:47:07 +01:00
Cirilo Bernardo a4861a0d64 Sync with main r6555 2016-02-14 09:16:40 +11:00
jean-pierre charras 7313b28e2a Cvpcb: minor change in menubar: change menu name "files" to "Save" (there is no more files to read or save). Pcbnew, pad properies editor: show Axis (pad origin) in GAL mode (it was already shown in legacy mode). 2016-02-13 16:34:52 +01:00
Chris Pavlina 168de616be Delete unused documentation 2016-02-12 15:48:24 -05:00
Rohan Agrawal 8785df0d80 Merge lp:~rohbotics/kicad/bug_1424003 into lp:kicad 2016-02-12 17:43:23 +01:00
unknown 15624ab1c3 Fix issue #1412628 (long text values truncated in pos file) and serious cleanup of gen_modules_placefile.cpp code. 2016-02-12 12:50:42 +01:00
Cirilo Bernardo 7ffa20a668 Fixed bug: X3D models not scaled to conform to legacy expectation 2016-02-12 16:58:12 +11:00
Rohan Agrawal 8d659b3e02 removed unnessacary curly braces 2016-02-11 19:26:03 -08:00
Rohan Agrawal 31a6a4adf0 Run fix_route until routing ended in EndTrack
Should fix Bug 1424003, by making making sure the routing is completed when endtrack is triggered.
2016-02-11 18:26:40 -08:00
Cirilo Bernardo 8e63862d7c Fixed coloring bugs related to uninitialized variable 2016-02-12 10:23:21 +11:00
jean-pierre charras 6c5b68a117 fix incorrect lang_sk.svg file. 2016-02-11 20:17:24 +01:00
jean-pierre charras d902c2716a Add Slovak entry in language menu. 2016-02-11 20:12:37 +01:00
unknown 450c2e4371 fix Tickness typo 2016-02-11 16:02:37 +01:00
jean-pierre charras 2284228c35 HPGL plot dialog: remove no more in use Pen Overlap parameter. Fix incorrect polygon fill by setting the hpgl pen thickness in hpgl file. Add filled circle (previously, a circle was never filled) 2016-02-11 13:14:46 +01:00
jean-pierre charras 5658ed9c8e Prepare rounded rect and custom shaped pads: add plot functions. It fixes also a pcbnew crash in HPGL mode when plotting trapezoidal pads. 2016-02-10 17:02:40 +01:00
Wayne Stambaugh a319c34188 Road map: add ERC improvements and revise object introspection. 2016-02-09 16:19:26 -05:00
unknown 4726f51ba0 Set the courtyard width to 0.05mm to comply with KLC in the following python footprint generators: bga,qfp,sdip and zip 2016-02-09 10:10:17 +01:00
jean-pierre charras 050bdbc772 Pcbnew: minor changes:
* Dialog copper zones: Always enable thermal shape settings, because even with no thermal, some pads can use thermal option in local pad settings.
* GAL mode: shows page limits in gray color, like in legacy mode, and according to comments in sources.
2016-02-09 09:23:24 +01:00
Tomasz Wlostowski 5349eb4179 fixed segfault in selection tool 2016-02-08 15:12:59 +01:00
jean-pierre charras 711607f152 Fix minor Bug #1542935 (No solder mask unless there is something on the layer) 2016-02-08 14:04:42 +01:00
Cirilo Bernardo 3c22f0f48f Bumped VRML plugin version number 2016-02-08 09:01:25 +11:00
Cirilo Bernardo 943c5d8ea8 Changed default creaseAngle from ~30deg (VRML spec) to ~42deg for prettier smoothing 2016-02-08 08:56:03 +11:00
Wayne Stambaugh 61454bf04c Eeschema: fix annotation bugs. (fixes lp:1542579)
* Ensure proper SCH_SHEET object page numbering which caused annotation to
  calculate incorrect reference designators when annotating by using page offsets.
* Added SetPageNumbers to SCH_SHEET for setting sheet page numbers after
  schematic is loaded.
2016-02-07 09:01:28 -05:00
Cirilo Bernardo 4edce46764 Fixed bug: ambient intensity RGB not correctly written/read 2016-02-07 08:52:42 +11:00
Cirilo Bernardo 99aba8f261 Changed handling of ambientIntensity; change of major version in SG* lib 2016-02-07 08:41:27 +11:00
Cirilo Bernardo 67832dbc74 Removed temporary debug info message 2016-02-06 13:28:59 +11:00
Cirilo Bernardo c180390a08 Converted WRLVEC2, WRLVEC3, WRLROTATION to GLM equivalents 2016-02-06 09:59:18 +11:00
Cirilo Bernardo f52744b29c Added back-pointers to referenced entities 2016-02-06 09:38:03 +11:00
Tom Andrews 4c7a61dd25 pcbnew: correct minor grammatical errors 2016-02-05 14:34:23 -05:00
Wayne Stambaugh cb13e57973 Eeschema: move find sheet by name from SCH_SHEET_PATH to SCH_SHEET.
* Move FindSheetByName() function from SCH_SHEEET_PATH to SCH_SHEET object
  and update calls to FindSheetByName() accordingly.
* Remove SCH_SHEET_PATH::FindSheet() which was unused.
* Add sorting option to SCH_SHEET::GetSheets().
2016-02-05 08:33:28 -05:00
Cirilo Bernardo b7a8661a03 Sync with main branch r6538 2016-02-05 16:15:51 +11:00
Cirilo Bernardo cd6b0fbef1 Added visualization of X3D models 2016-02-05 16:08:30 +11:00
Cirilo Bernardo ffa0775074 Added preliminary X3D parser with no visualization data 2016-02-05 15:32:52 +11:00
Dick Hollenbeck 7c637ea7be github fix and comment improvements:
* Fix a StrPrintf() %s count mismatch bug
* Better comments
* Use std::string::data() instead of a ref to the first char to get the str::string buffer  (should not change anything with GNU lib)
2016-02-04 17:49:20 +01:00
Cirilo Bernardo 68dde1f16f Fixed inappropriate model scale limitation in 3D Footprint Properties dialogs 2016-02-04 12:31:37 +11:00
Cirilo Bernardo 86635aeb23 Manually select changes from Mario Luzeiro's branch to fix model lighting in the preview window. 2016-02-04 12:16:19 +11:00
Wayne Stambaugh a9bf46a5de Documentation: add version 5 road map to developer documentation. 2016-02-03 19:12:24 -05:00
Maciej Suminski c16b66ce0c Ratsnest does not take into account non-copper pads (GAL). 2016-02-03 11:01:00 +01:00
Wayne Stambaugh 0ef1eee2c6 Eeschema: move recursion check from SCH_SHEET_PATH to SCH_SHEET.
* Add const and non-const version of GetRootSheet() to SCH_SHEET.
* Add GetSheetPaths() function to SCH_SHEET which behaves the same way
  as SCH_SHEET_LIST except it uses standard C++ containers and is a much
  simpler design.
2016-02-02 19:45:43 -05:00
Cirilo Bernardo bf3d2b252e Fixed VRML normals calculations 2016-02-03 11:44:48 +11:00
jean-pierre charras 50db57f4d5 Pcbnew: fix Bug #1540967 (zone keepout incorrectly created if previously a corner-smoothed copper zone was created). This option (non relevant for a zone keepout) is now cleared. 2016-02-02 21:32:11 +01:00
Wayne Stambaugh 783f818f19 Eeschema: fix segfault when drawing new sheet after deleting existing sheet with the same file. (fixes lp:1538510) 2016-02-02 11:54:54 -05:00
Cirilo Bernardo 06e766b8b2 Sync with main branch r6532 2016-02-02 17:25:14 +11:00
Cirilo Bernardo b987445676 Forced smoothed normals calculations for VMRML2 parser 2016-02-02 16:50:46 +11:00
Cirilo Bernardo ca9ada70a2 Deactivate SG* VRML output 2016-02-02 11:48:26 +11:00
Jon Neal 896bd3945d pcbnew: netlist import interactive edit fix
When importing a netlist with no changes, do not select the part under the
cursor.
2016-02-01 19:43:28 -05:00
Cirilo Bernardo 1f796ef494 Fixed normals calculations in wrlfacet 2016-02-02 11:23:15 +11:00
Andrew Zonenberg 41223a81d3 pcbnew: avoid unnecessary copy in RN_NET::processPads()
Saves >30% run time on ratsnest rebuild for high-fanout nets.
2016-02-01 18:13:30 -05:00
jean-pierre charras ce7ce77d80 Very minor fix: double shortcut key fix in dialog_schematic_find_base.cpp 2016-02-01 11:42:33 +01:00
Maciej Suminski 1e371a5172 Added files generated by pcb_calculator to .bzrignore. 2016-02-01 10:05:58 +01:00
Cirilo Bernardo eadb34e22e Remove accidental activation of SG->VRML debug write 2016-02-01 18:19:16 +11:00
Cirilo Bernardo 8fa9e28e85 Fixed inverted normals bug in wrlfacet 2016-02-01 18:09:19 +11:00
Cirilo Bernardo 55c7c61458 Initial introduction of improved VRML normals calculations; working on VRML1 2016-02-01 17:27:50 +11:00
Cirilo Bernardo 8dd744f635 Improved 3D cache manager's ability to replace outdated cache models 2016-01-31 13:21:12 +11:00
jean-pierre charras 351752f4e4 Fix Bug #1539889 (empty translated strings which create issues in translation tools)
Add a file deleted by accident in interf_u demo.
2016-01-30 14:14:58 +01:00
Cirilo Bernardo b1d35965f5 Relax VRML1 specifications conformance to support more non-conformant models 2016-01-30 13:50:17 +11:00
Tomasz Wlostowski ee3418e90b One-click PCB update improvements
- Fix repetitive undo/redo segfaults & assertions.
- Add Update menu entry on PCB side.
- Fix Python build error
- Add spread footprints after updating
2016-01-29 15:43:40 +01:00
Tomasz Wlostowski 689072c0e1 PCB updater: open PCBnew automagically, minor fixes to the dialog 2016-01-29 11:36:51 +01:00
Tomasz Wlostowski 570ba5e00a set up netlist footprint loader before attempting pcb update... 2016-01-29 11:31:26 +01:00
Tomasz Wlostowski 5ef6001e06 pcbnew: support for removing NETINFO_ITEMS from BOARD for proper netlist undo 2016-01-29 11:29:56 +01:00
Tomasz Wlostowski 867a0444bd eeschema: single click PCB update feature added 2016-01-29 11:24:39 +01:00
Tomasz Wlostowski 9e609acae3 made netlist entries and netlist update undoable 2016-01-29 11:21:13 +01:00
Maciej Suminski 1d39a2a44b Highlight net tool is not deactivated after a single use. 2016-01-29 10:56:29 +01:00
Cirilo Bernardo ece1291d93 Fixed SG* CMake control file to handle new sg_version.h file 2016-01-29 12:00:03 +11:00
Cirilo Bernardo dddc3d91e9 Cleaned up 3D SceneGraph API by removing references to wxString 2016-01-29 11:52:42 +11:00
Simon Richter 7e697e8ef7 GitHub plugin build configuration fixes.
* The github plugin includes the CURL headers indirectly, so these headers
  need to be in the include search path.
2016-01-28 12:30:55 -05:00
Simon Richter 23e8c3ebf3 Executable icon resource build configuration fixes.
* The resource setting for bitmap2component is too late in the CMakeLists.txt,
  and is being ignored. Bitmap2component does not have an icon resource on
  Windows.  Moving the entire section resolves the issue.
* The other programs only have the mingw special case listed, not the generic
  declaration for the resource file so added them.
2016-01-28 11:53:24 -05:00
jean-pierre charras 75b1df464d Pcbnew and Gerbview: layer manager: use double click to edit color (as usual to edit someting) and simple click (as previously) to select the layer. Reason: avoid opening the color dialog each time a new layer is selected.
Update interf_u demo to use recent library components..
2016-01-28 09:02:25 +01:00
jean-pierre charras 3a9cbbe0bb pagelayout editor: fix Bug #1538603 (pl_editor does not save custom text size if only one of the X or Y size value is not default) 2016-01-28 08:51:09 +01:00
Cirilo Bernardo 8264d393e8 Sync with main branch r6516 2016-01-28 17:14:36 +11:00
Cirilo Bernardo cd831d9a8a Removed include directives for wx/wx.h within 3D cache code 2016-01-28 17:12:41 +11:00
Chris Pavlina ac54b7d114 libedit: fix iterator off end of vector (lp:1537946) 2016-01-25 20:52:13 -05:00
Cirilo Bernardo 1028535561 Small improvements to 3D file selector UI 2016-01-26 11:50:01 +11:00
Andrew Zonenberg e91dab816c Pcbnew DRC: allow technical->copper pad overlap
This permits things like mask "pads" over copper pads for custom mask openings.
2016-01-25 19:33:40 -05:00
Cirilo Bernardo fc5556c811 Sync with main branch r6513 2016-01-26 10:35:16 +11:00
Wayne Stambaugh a23e7129d4 Remove GUI translation how to as it is now maintained in the KiCad I18N project on GitHub. 2016-01-25 16:57:52 -05:00
Chris Pavlina 39ad4ef7fc Hotkey editor: dynamically resize columns
This was done in OnSize(), but was not triggered when a hotkey was edited.
2016-01-25 11:17:52 -05:00
Chris Pavlina 76fb8ce8f9 Hotkey editor: Fix GTK assertion
Tried to set negative width when dialog sized too small
2016-01-25 11:17:43 -05:00
Maciej Suminski e51adaeefd Highlight a net when crossprobing with eeschema and highlight net tool is enabled. 2016-01-25 16:16:05 +01:00
Cirilo Bernardo 8efd3642bc Fixed bug which allowed empty filenames to be added to the model list 2016-01-25 17:10:08 +11:00
Cirilo Bernardo cb8ccb5882 Small UI improvements 2016-01-25 16:59:45 +11:00
Cirilo Bernardo cc906ec12e Removed deprecated header 2016-01-25 15:58:24 +11:00
Cirilo Bernardo 3eca3fe75d Implemented new 3D file selector with preview 2016-01-25 15:55:36 +11:00
Bernhard Stegmaier 3e2b4244f9 OSX: add support for wxMagnifyEvent on OSX builds using wxWidgets 3.1.0 or greater. 2016-01-24 19:18:29 -05:00
Wayne Stambaugh 2aac71700b Eeschema: move is complex hierarchy and find next item from SCH_SHEET_PATH to SCH_SHEET.
* Add function to get a list pointers to this sheet and all of it's  sub-sheets
  to SCH_SHEET.
* Remove unused function SetFootprintField() from SCH_SHEET_PATH.
2016-01-24 15:46:14 -05:00
Cirilo Bernardo ff07ad3f05 Fixed bug: 3D model selector sets scale values to zero 2016-01-24 08:37:28 +11:00
Martin d'Allens d18baf1487 Eeschema: Set modified flag after "Append Schematic Sheet" 2016-01-23 10:25:07 -05:00
Cirilo Bernardo 20f97f34c3 Temporarily disabled some 3D data transfer code due to cross-platform differences in wxFileDialog 2016-01-23 20:36:39 +11:00
Cirilo Bernardo 31af6d7dbc Fixed GUI issues related to setting scale/offset/rotation 2016-01-23 20:07:58 +11:00
Cirilo Bernardo 3cb1924750 Suppressed 3D plugin VRML file output from default DEBUG build 2016-01-23 16:58:22 +11:00
Cirilo Bernardo c79cc21396 Fixed syntax problem in MSWin specific code 2016-01-23 16:34:29 +11:00
Cirilo Bernardo fa37f233ef Added 'Change' button to 3D file selector to improve UI usability 2016-01-23 16:24:12 +11:00
Cirilo Bernardo 81f95a8dbc Improve message displayed when resolver encounters a non-existent alias 2016-01-23 16:09:42 +11:00
Cirilo Bernardo 7c829c9e84 Added manual editing of 3D file name with alias tags 2016-01-23 14:52:54 +11:00
jean-pierre charras d24bd85bf5 Minor code cleanup. 2016-01-22 13:30:44 +01:00
Wayne Stambaugh ac30be332f Eeschema: move get multi-unit components from SCH_SHEET_PATH to SCH_SHEET. 2016-01-21 19:01:34 -05:00
Chris Pavlina 8e8e126dcd Regression fix: hotkeys in eeschema not saved
Regression introduced in bzr 6474 / git 5173699
2016-01-21 10:17:55 -05:00
jean-pierre charras de0ac192fe Kicad manager: very minor fix: Change default accelerator key Ctrl+C to Ctrl+A to run the pcb_calculator utility.
Ctrl+C cannot be used here as accelerator, because it is captured by other widgets.
2016-01-21 15:36:46 +01:00
jean-pierre charras 731a87db25 Fix Bug #1536427 ("User (Custom)" size selection in"Page Settings" issue in non English languages).
Remove also a no more in use code
2016-01-21 11:15:13 +01:00
Chris Pavlina 4c1d9af0a4 Fix Python regression from rev 6496
SWIG does not export contants defined "static const" in a header; it is
instead necessary to use #define.
2016-01-20 19:32:50 -05:00
Dick Hollenbeck 364776a5d4 Remove commented out GetStandardLayerName() 2016-01-20 18:04:56 +01:00
Maciej Suminski 74b498d92d Remove redundant forward declarations. 2016-01-20 15:22:58 +01:00
Maciej Suminski 75c8094b5a Make DRC markers not editable with the standard tools (GAL). 2016-01-20 15:22:09 +01:00
Maciej Suminski b42382e403 Draw arrows for DRC markers (GAL). 2016-01-20 15:19:26 +01:00
Maciej Suminski 4951285a67 GAL::DrawPolygon() and GAL::DrawPolyline() variants that work with VECTOR2D array. 2016-01-20 15:16:39 +01:00
Chris Pavlina c490e7dd06 Fix typing problems with GR_KB_* constants 2016-01-20 07:11:17 -05:00
Cirilo Bernardo ab2fff46f1 Added version tag to cache data 2016-01-20 09:07:09 +11:00
Cirilo Bernardo 3a80de107d + Improved 3D file resolution behavior with respect to duplicated paths
+ Added versioning to the 3D search path configuration file
2016-01-20 08:36:26 +11:00
Cirilo Bernardo fcd89c57ed Change in VRML1 color retrieval rule for out-of-bounds index 2016-01-19 16:13:12 +11:00
Cirilo Bernardo 39ca807ac4 Improved VRML1 support, including relaxed rules to support poorly structured models 2016-01-19 15:21:00 +11:00
Cirilo Bernardo ec9acfd410 + Changed wxT macro from _T() to _()
+ Added hints to 3d_filename_resolver to help transition from
  legacy 3D model resolver behavior.
2016-01-19 11:05:40 +11:00
Wayne Stambaugh cf9a9a09ad Eeschema: decouple SCH_COMPONENT from SCH_SHEET_PATH.
* All reference paths except netlist objects are retrieve from the parent
  sheet of the component rather than the external sheet path object.
2016-01-18 18:47:55 -05:00
Cirilo Bernardo d3f68e6482 Fix resolution of paths relative to KISYS3DMOD in legacy support 2016-01-19 10:30:20 +11:00
Cirilo Bernardo 625ce3cb69 Fix accidental application of filters to all cells of 3D search path GUI 2016-01-19 10:11:09 +11:00
Cirilo Bernardo 54940002f9 Implemented 3D search path configuration GUI 2016-01-18 19:53:35 +11:00
Cirilo Bernardo 7848b2a52e Implemented new 3D searchpath configurator 2016-01-18 16:59:06 +11:00
Simon Wells edc47c3f8e Clean up includes in confirm.cpp, confirm.h 2016-01-18 00:17:56 -05:00
Cirilo Bernardo 7434e673e1 Fixed bug in VRML coordinate conversion 2016-01-18 10:54:24 +11:00
Cirilo Bernardo 9a0b020806 Added VRML conversion of 'translation' and 'center' to mm on read and 0.1 inch on write 2016-01-18 10:39:51 +11:00
Cirilo Bernardo ef62a5f153 Ensure consistent use of mm within SG models and that SG models write VRML files using 0.1 inch units 2016-01-18 08:35:29 +11:00
Cirilo Bernardo 9aeaf4a71b Prevent unresolved path expansions from appearing as blank entries in 3D path list 2016-01-18 08:34:21 +11:00
Cirilo Bernardo 5d82d9348d Fix bug: MSWin to UNIX file separator conversion was in the wrong place, leading to wrong separator shown in GUI 2016-01-18 08:33:39 +11:00
Simon Richter da9ca2def2 Avoid cast from const_iterator to iterator
The standard library requires iterators passed to functions that modify the
container to be mutable iterators, but GCC's implementation accepts
const_iterator in some places where these are only used to mark a place,
but the actual modification happens through a different parameter.

As this breaks implementations that use the passed iterator to modify the
container (e.g. because they use a different data organization), this is
not portable; because we already have a non-const reference to the
container anyway, this is trivially fixed as well.
2016-01-17 12:31:00 -05:00
Simon Richter ff4febc7a8 Clarify atan2 overloads
In the C++ standard, this function is only defined for floating point
types, and integers cannot be implicitly converted. Using explicit
conversions avoids a GCC specific extension to the standard library.
2016-01-17 10:59:24 -05:00
Simon Richter ef582c07f3 Drop some debug output
This was apparently left in from debugging earlier, and should no longer be
needed. Since it uses a GCC extension, it makes compilation on others fail.
2016-01-17 10:59:17 -05:00
Simon Richter ba66f0360a Avoid comparing filepos with integers
The filepos type is not necessarily an integer type, because it also needs
to save the multibyte character state in case we're reading from a stream
with shift states.

The convention of using -1 as a special value is from Unix ftell(), and not
portable. Instead, the stream's failbit needs to be examined after the call
to tellg().
2016-01-17 10:59:08 -05:00
Mark Roszko 05ee63fe39 Replace dangerous cast of pointer->long 2016-01-16 22:56:58 -05:00
Chris Pavlina a9216b9a32 Merge: Move eeschema colors into preferences 2016-01-16 18:53:19 -05:00
Chris Pavlina 5d805e94eb Remove last vestiges of DIALOG_COLOR_CONFIG
The color config dialog in libedit edits the same settings as the one in
eeschema, so there's no reason for it - it's just duplicated.
2016-01-16 18:51:56 -05:00
Chris Pavlina b891fa4358 Remove separate color configuration dialog 2016-01-16 18:51:48 -05:00
Chris Pavlina bf03642220 Pull colors widget into preferences dialog 2016-01-16 18:51:38 -05:00
Chris Pavlina 9513741816 Rename WIDGET_COLOR_CONFIG -> WIDGET_EESCHEMA_COLOR_CONFIG 2016-01-16 18:51:27 -05:00
Chris Pavlina 8c2427d3fa Add and use WIDGET_COLOR_CONFIG::InstallOnPanel 2016-01-16 18:50:55 -05:00
Chris Pavlina c4694e029d Move color configuration into a separate widget 2016-01-16 18:50:45 -05:00
Simon Wells b5a9e466ff Fix layer widget appearance on OSX 2016-01-16 17:07:24 -05:00
Simon Wells b125054afe Pcbnew: Allow changing layer color with left mouse button
Many users, particularly those on laptops, have no middle mouse button, and
thus have no way at all to set the layer colors.
2016-01-16 10:31:10 -05:00
Simon Wells e0beb36f1e GAL: Update grid color when changed by user 2016-01-16 10:23:28 -05:00
jean-pierre charras e3f399ca38 pcb_calculator: remove no more in use png files. 2016-01-16 15:59:50 +01:00
jean-pierre charras 38b84f3551 pcb_calculator: fix incorrect formulas shown in attenuators panel. Png files are no more used, and formulas are now html doc files.
kicad_curl.cpp: fix a compil warning on Windows due to incorrect order of includes (regression)
2016-01-16 15:56:45 +01:00
jean-pierre charras 454dd64ac5 Remove autogenerated files 2016-01-16 15:50:34 +01:00
jean-pierre charras 6155cba077 kicad_curl.cpp: fix a compil warning on Windows (regression)
pcb_calculator: fix incorrect formulas shown in attenuators panel. Png files are no more used, and formulas are now html doc files.
2016-01-16 15:27:42 +01:00
Cirilo Bernardo e185b29baa Resync with main branch r6482 2016-01-16 19:10:53 +11:00
Cirilo Bernardo f3c56eff12 Work in progress: changed Footprint Properties editors to handle aliased 3D file names 2016-01-16 17:49:28 +11:00
Chris Pavlina bc614a5e0b Fix accidental string+int in a debug message 2016-01-15 22:47:47 -05:00
Simon Richter 128459470a Clean up truncation of constant
In the autorouter code, the value 0x80 is assigned to MATRIX_CELL, which is
an overflow for a signed 8-bit type. As this type is used as a bit mask,
there is no point in having a sign bit anyway.
2016-01-15 22:24:17 -05:00
Simon Richter f674942e27 Remove superfluous include in the middle of source file 2016-01-15 22:20:32 -05:00
Chris Pavlina 60055e04af Merge new hotkey edit/entry widget 2016-01-15 21:08:33 -05:00
Chris Pavlina 3b4e6dc1fa Fix wx font bug
Labels don't size correctly with large font
2016-01-15 21:07:42 -05:00
Chris Pavlina 950d2458c0 Fix label sizing in hotkey query dialog 2016-01-15 21:07:35 -05:00
Chris Pavlina 6e52c228bc Add comment and tidy up 2016-01-15 21:07:28 -05:00
Chris Pavlina 165f42daaf Continue fixing silly Windows-related bugs 2016-01-15 21:07:19 -05:00
Chris Pavlina 4391f99a25 Clean up EVT_CHAR_HOOK and fix a bug on Linux
Forgot aEvent.Skip()
2016-01-15 21:07:12 -05:00
Chris Pavlina 95988802f7 Fix special keys on Windows 2016-01-15 21:07:06 -05:00
Chris Pavlina f574620d07 Fix special hotkeys on Windows 2016-01-15 21:06:59 -05:00
Chris Pavlina 14008321fe Dynamically size horizontal column if necessary. 2016-01-15 21:06:51 -05:00
Chris Pavlina 2ed78cf84b Move import/export button back into menu 2016-01-15 21:06:41 -05:00
Chris Pavlina 80fae7161e Coding style fixes 2016-01-15 21:06:25 -05:00
Chris Pavlina 73faa8238e Adjust options window 2016-01-15 21:06:15 -05:00
Chris Pavlina b2a5307e4b Do not reset the selection after changing hotkey 2016-01-15 21:06:07 -05:00
Chris Pavlina 06add0d130 Add context menu 2016-01-15 20:58:53 -05:00
Chris Pavlina 4dad12794a Add and use WIDGET_HOTKEY_LIST::InstallOnPanel 2016-01-15 20:58:39 -05:00
Chris Pavlina 7d30eaf13a Refactor keycode lookup 2016-01-15 20:58:31 -05:00
Chris Pavlina 87cb6c4429 Adjustments to dialog formatting 2016-01-15 20:58:23 -05:00
Chris Pavlina 45a304ed1c Change label 2016-01-15 20:58:14 -05:00
Chris Pavlina a16b2c6eba New hotkey press acquirer 2016-01-15 20:57:10 -05:00
Chris Pavlina af042628ff Refactor WIDGET_HOTKEY_LIST out of DIALOG_HOTKEYS_EDITOR 2016-01-15 20:56:57 -05:00
Chris Pavlina 9663060f97 Recreate menu bar after changing hotkeys 2016-01-15 20:56:23 -05:00
Chris Pavlina 2e4bb307dc Fix dialog sizing issue on Windows 2016-01-15 20:56:16 -05:00
Chris Pavlina db178dcdaf Eeschema options+hotkeys fixes
Fix wxTreeListCtrl column sizing

Minor: fix signed/unsigned comparison

Remove unnecessary m_parent direct access
2016-01-15 20:56:00 -05:00
Chris Pavlina 5173699eec Pull hotkey editor into eeschema preferences 2016-01-15 20:55:50 -05:00
Simon Wells e5f3edf0f1 Eeschema: minor coding policy fix 2016-01-15 20:26:34 -05:00
Simon Wells 24d293ab8d bmp2cmp: include cleanup 2016-01-15 19:57:52 -05:00
Chris Pavlina 74ef947575 github_plugin: remove unused variable 2016-01-15 11:56:14 -05:00
Chris Pavlina 2ff439b894 Move some old legacy save code into the block for that 2016-01-15 10:34:51 -05:00
Cirilo Bernardo 4d5097b41d Work in progress: preparing new resolver scheme 2016-01-15 14:01:21 +11:00
Simon Richter 769104d542 pin table: Support flat table 2016-01-14 21:26:42 -05:00
Chris Pavlina ca01527d20 Coding style fix in the previous patch 2016-01-14 21:21:54 -05:00
Simon Richter 64782736ac pin table: Add GetString() to retrieve string value for column
This is in anticipation of the introduction of icons -- retrieving all the
icons and throwing them away during sorting takes ages.
2016-01-14 21:21:26 -05:00
Simon Richter a568f35978 Fix preprocessor logic
The C++ preprocessor is actually not required to process "true" and "false"
correctly. This works in C if <stdbool.h> is included, because these are
then macros themselves, and resolved correctly, but C++ requires them to be
keywords, so no such macros exist, and the preprocessor can treat both as
undefined/zero.
2016-01-14 20:48:44 -05:00
Simon Richter 1190b7880a Fix double class name
Mostly cosmetic change, although there are compilers that choke on this.

The C++ standard specifies that classes contain themselves as members,
probably so they shadow any other definition of the same name for their own
member functions, but there is really no reason why the class name should
be duplicated here.
2016-01-14 20:43:38 -05:00
Cirilo Bernardo 2ed89c29d2 Work in progress: transition to new 3D name resolution with nicknames 2016-01-15 11:28:28 +11:00
Chris Pavlina b30a461ee9 Pcbnew: fix Flip hotkey for blocks in legacy (fixes lp:1534120) 2016-01-14 12:52:27 -05:00
Wayne Stambaugh f15af3ac8d Restore FindOpenSSL.cmake, the cmake version does not work on MinGW. 2016-01-14 10:31:59 -05:00
Dick Hollenbeck f527b29e68 GitHub plugin: fix threading issues when libcurl is build against openssl.
* Dick Hollenbeck also contributed commit r6440.  I inadvertently forgot to set
  the Bazaar author tag before I committed it.  My apologies.
* Switch to static linking of libcurl and on linux and windows and also
  statically link in only required portions of openssl.
* Add the required thread locks which openssl needs.
* Remove the get curl version call from BASEFRAME since it pulls in curl and
  openssl into every derived wxFrame class link image.
* Remove curl function from PGM_BASE, switch to atexit() instead.  Anything in
  PGM_BASE made the singletops bigger.
* Tested on Linux, Windows, and OSX.
2016-01-14 10:17:13 -05:00
jean-pierre charras 731f785256 Fix erroneous calculation of segments by circle count in shape_poly_set.cpp Inflate method. 2016-01-14 12:37:09 +01:00
Cirilo Bernardo d519df22ca Change parameter type to accommodate expected integer range 2016-01-14 13:50:16 +11:00
Cirilo Bernardo f4414e8325 Change 3D cache manager to use boost SHA-1 digest rather than in-tree MD5 2016-01-14 13:49:40 +11:00
Simon Richter 5af18e553c Compress consecutive numbers in pin summary.
For pin numbers ending in digits, consecutive numbers are collapsed to
ranges for a better overview.
2016-01-13 14:18:05 -05:00
Simon Richter 3c5a4a3505 Add pin number summary
Below the pin table, display which pins are currently defined, in order to
find gaps.
2016-01-13 14:17:54 -05:00
Chris Pavlina f7c7920b0b Add missing files from 6461 and 6462 2016-01-13 14:13:38 -05:00
Simon Richter 9e8acdc71a Move container functionality
The "set of pin numbers" functionality is also useful outside the pin table
dialog, so create a wrapper class that exposes the relevant interfaces.
2016-01-13 14:09:24 -05:00
Simon Richter a7b102c366 Move comparison helper class to generic header
This class wraps the comparison function in a way that is compatible with
std::map and std::set. This, too is generally useful, so it should be moved
to the generic header.

At the same time, the criterium for less-than is changed from "equal to -1"
to "smaller than 0", because technically the comparison function may return
other values.
2016-01-13 14:09:18 -05:00
Simon Richter 88ccd787a4 Split off pin number comparison
Pin numbers need to be ordered in more places in the future, so fold this
out of the pin table dialog into a utility class.
2016-01-13 14:09:07 -05:00
Tomasz Wlostowski 991b9d509a GAL: apply grid offset when board is loaded and respect grid color setting. (fixes lp:1533168) 2016-01-13 13:37:52 -05:00
Wayne Stambaugh 99ba5259a6 Undo commit r6456 which completely breaks building on MSYS2/MingGW. 2016-01-12 21:50:18 -05:00
Wayne Stambaugh cdba425bad Eeschema: move get components from SCH_SHEET_PATH to SCH_SHEET.
* Add sheet number that is set by schematic file load order.  This duplicates
  the previous SCH_SHEET_PATH behavior.
* Uncouple SCH_REFERENCE and SCH_REFERENCE_LIST from SCH_SHEET_PATH.
* Add - operator to SCH_SHEET for comparison purposes.  This duplicates the
  behavior of SCH_SHEET_PATH::Cmp().
2016-01-12 21:31:34 -05:00
Simon Richter b09c88042b Synchronize FindwxWidgets.cmake with CMake project 2016-01-12 20:33:13 -05:00
Simon Wells 09ef795a02 Minor coding style fixes in headers 2016-01-12 11:33:33 -05:00
Chris Pavlina 3a8e78c586 Eeschema: always enable Replace All when there is a search term 2016-01-12 10:57:17 -05:00
Chris Pavlina ee2752827a Remove old, empty header 2016-01-12 10:35:27 -05:00
Cirilo Bernardo 2ef42001df Added missing header to 3D plugin loader 2016-01-12 18:18:11 +11:00
Cirilo Bernardo 81977ed6b7 Finished checking debug/info messages and internationalization where appropriate 2016-01-12 18:03:17 +11:00
Cirilo Bernardo 3a5110f74a Work in progress: checking debug output messages, internationalizing user info messages 2016-01-12 17:09:04 +11:00
Cirilo Bernardo 4919f2ba75 Fix IDF parse error when final EOL is missing 2016-01-11 23:02:12 -05:00
Simon Wells 731a137af0 Remove unused items in gpcb_plugin.cpp 2016-01-11 22:07:33 -05:00
Simon Wells 2028fa7926 Add missing header to richio 2016-01-11 21:41:33 -05:00
Cirilo Bernardo 217a5f39e1 Resync with main branch r6449 2016-01-12 10:36:31 +11:00
Cirilo Bernardo c952cb4902 Changed VRML parsers to use LINE_READER 2016-01-12 10:12:50 +11:00
Simon Wells 9362a6ec24 Update FindwxWidgets.cmake to new version without -isystem
See: https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d05f195
2016-01-11 17:15:48 -05:00
Simon Wells a88e61a6e0 Fix uninitialized variable in PCBNEW_CONTROL::CursorControl 2016-01-11 17:12:49 -05:00
Simon Wells 712ff51d3f Clarify assignment as conditional in EDIT_TOOL::Main 2016-01-11 17:12:11 -05:00
Simon Wells dbb7b38bae Delete unused variables in GRID_HELPER::AlignToSegment 2016-01-11 17:06:11 -05:00
Tomasz Wlostowski 95252267ec Router: check layers of all traversed joints in FindLinesBetweenJoints(). (fixes lp:1531762) 2016-01-11 13:37:00 -05:00
Wayne Stambaugh ef87a0de54 Fix build errors when casting wxString to const char * with some compilers. 2016-01-11 10:44:33 -05:00
jean-pierre charras 74b629fa19 Fix issues I created in rev 6442 (no issue on msys2/gcc5.3, but issues on Kubuntu 14.04/ gcc 4.8). I'll find a better fix later. 2016-01-11 10:13:13 +01:00
jean-pierre charras 41db57c5f0 pcbnew.py: fix error "NameError: name 'UNDEFINED_LAYER' is not defined" when running pcbnew/wxPython, which prevents from openning the Python console.
CMakeLists.txt: remove no more used boost libs, and add missing coroutine lib in list.
Fix 2 minor compil warnings.
2016-01-11 09:26:55 +01:00
Cirilo Bernardo cbfd05e799 Change dynamic loader from wxPluginManager to wxDynamicLoader (wxPluginManager was causing segfaults) 2016-01-11 18:32:37 +11:00
Cirilo Bernardo f123fab15b Removed unnecessary platform-dependent includes 2016-01-11 16:25:38 +11:00
Cirilo Bernardo e0b50b4002 Ensuring consistent internal kicad file separator character on MSWin 2016-01-11 16:24:51 +11:00
Cirilo Bernardo c81a0d0f2f Moved data transfer from OnOK to TransferDataFromWindow() and removed all instances of OnOK and OnExit 2016-01-11 16:14:35 +11:00
Cirilo Bernardo 14bee875cf Replaced platform-dependent dynamic loading code with wxPluginManager 2016-01-11 15:47:08 +11:00
Cirilo Bernardo 2bdc4d770b Fixed plugin->Load invocation (passed wxString instead of const char*) 2016-01-11 14:04:54 +11:00
Chris Pavlina 020ba521df Remove FindOpenSSL.cmake (not used since removing avhttp) 2016-01-10 19:47:30 -05:00
Wayne Stambaugh 5c6c2a0661 GitHub plugin: fix potential multiple initialization of libcurl bug.
* Prevent libcurl from inadvertently being initialized twice.
* Dynamically load libcurl only when required.
* Reduce the number of worker threads when loading footprint libraries to
  prevent issues with the GitHub plugin.
2016-01-10 16:44:37 -05:00
Jon Neal f309eaab00 Pcbnew: spread and pick up new footprints when loaded. 2016-01-10 16:24:13 -05:00
Bernhard Stegmaier 7e2af163dd Silence unused-local-typedef warnings when building with clang 2016-01-10 11:17:06 -05:00
Chris Pavlina 13c5341040 pcbnew/scripting: delete orphaned header 2016-01-10 09:08:13 -05:00
Chris Pavlina fc22580d9a Eeschema: replace accidental dynamic_casts with static_casts
Coverity: 134084, 134805, 134086, 134087
2016-01-09 18:36:09 -05:00
Chris Pavlina b381d99300 Eeschema: fix uninitialized members
Coverity: 102614, 102723
2016-01-09 18:35:20 -05:00
Chris Pavlina 5e36c48012 Eeschema: remove dead code in autoplace (Coverity)
CID 134043, 134094 in autoplace_fields: variable overwritten due to dead code
that should have been removed.
2016-01-09 16:59:01 -05:00
Simon Schubert c1b8a01e03 pcbnew: simplify pad DRC
This simplifies the pad DRC significantly and fixes a bug when two pads
are close to each other in a right angle, when the edge distances are
below the clearance, but the corner distance is actually above the
clearance:

      +---..
      |
      +---..
+---+
|   |
:   :
---

----
<Chris> Pad DRC has handling for trapezoid pads and handling for square
pads. This patch looks relatively low-risk to me, as square is a subset
of trapezoid and the handling for trapezoid pads is not specific to that
pad type.
2016-01-09 16:07:52 -05:00
Chris Pavlina a298e18d6d Fix enum comparison warnings 2016-01-08 17:28:21 -05:00
Cirilo Bernardo c24c07962b Fixed bug in display of Footprint Properties rotation (text too long) 2016-01-08 18:53:45 +11:00
Cirilo Bernardo 87c62b443d Improved SG* code to avoid spurious warnings when adding child/reference nodes 2016-01-08 17:04:17 +11:00
Cirilo Bernardo b04bd8c07a Improved VRML parser's ability to skip comments 2016-01-08 16:51:39 +11:00
Cirilo Bernardo 979edc4f9f Improved VRML1 conformance to spec 2016-01-08 16:23:42 +11:00
Chris Pavlina 0682bd782d Fix coding style error in 6429 2016-01-07 17:35:26 -05:00
Chris Pavlina c44c076bdb Fix coding style error in 6429 2016-01-07 17:33:31 -05:00
jean-pierre charras b3af0fdcad Pcb_calculator: fix a minor cosmetic issue in tracks width versus current notebook page. 2016-01-07 21:01:45 +01:00
Johannes Agricola 07b73b9677 Properly set keepout flag for new zones in GAL 2016-01-07 14:39:21 -05:00
Cirilo Bernardo e8593d177c Change 'class S3D_INFO' declarations to 'struct S3D_INFO' 2016-01-07 19:54:39 +11:00
Cirilo Bernardo 0377be722f Added ShapeHints to VRML1 parser 2016-01-07 18:03:07 +11:00
Cirilo Bernardo 1b6480e858 Added support for VRML1 transforms (except for MatrixTransform) 2016-01-07 17:01:07 +11:00
Cirilo Bernardo 0bb4beb5d7 Fixed bug (missing #ifdef/#endif) 2016-01-07 15:55:24 +11:00
Cirilo Bernardo 7dd4bd9f09 Improving VRML1/2 parsers 2016-01-07 15:43:32 +11:00
Cirilo Bernardo 8a9eb3bbe8 Fixed various bugs in VRML2 and VRML1 code 2016-01-07 11:24:11 +11:00
Wayne Stambaugh e8e0a75b8c Eeschema: move update all screen references from SCH_SHEET_PATH to SCH_SHEET.
* Uncouple SCH_COMPONENT::GetRef() from  SCH_SHEET_PATH and use SCH_SHEET
  instead.
* Uncouple SCH_COMPONENT::GetUnitSelection() from  SCH_SHEET_PATH and use
  SCH_SHEET instead.
* Fix all calls to GetRef() and GetUnitSelection() to pass a pointer to the
  appropriate SCH_SHEET object instead of an SCH_SHEET_PATH object.
2016-01-06 19:07:30 -05:00
jean-pierre charras f76c9376e0 Fix a link issue on some platforms, created by rev 6429 2016-01-06 12:08:43 +01:00
Cirilo Bernardo 29d7829909 Fix for MSWin (plugins not found) 2016-01-06 20:05:29 +11:00
Cirilo Bernardo d6fbd7b4e5 Finished initial implementation of VRML1 parser 2016-01-06 19:45:49 +11:00
jean-pierre charras dda957a048 Minor fixes: rename cvframe.cpp to cvpcb_mainframe.cpp to be consistent with other similar files are named.
* Better name for a cvpcb_mainframe function.
* Minor fixes in comments
* Minor code cleaning and fixes
2016-01-06 08:36:08 +01:00
Cirilo Bernardo 9d55ad375f Removing redundant sg/ifsg colorindex files and references 2016-01-06 18:19:20 +11:00
Cirilo Bernardo 7e165ac866 Work in progress: implementing VRML1 to SGNODE translation 2016-01-06 18:02:21 +11:00
Cirilo Bernardo 403cd94edc Fixed color indexing for VRML2 plugin 2016-01-06 16:51:29 +11:00
Cirilo Bernardo 6f309a46c9 Implemented per-vertex colors for VRML2 and SGNODE 2016-01-06 16:15:54 +11:00
Cirilo Bernardo 6b873ed46b Work in progress: implementing SG translation for VRML1 models 2016-01-06 15:34:14 +11:00
Jon Neal 89c183f041 Add a new dropdown type that has oz/ft^2 for the pcb track width calculator. 2016-01-05 19:04:45 -05:00
Cirilo Bernardo 38543ab94f Work in progress: added Switch and IndexedFaceSet to VRML1 plugin 2016-01-06 08:29:13 +11:00
Cirilo Bernardo 98f867629b Added debug printouts to help debug plugin search/loading on MSWin 2016-01-06 06:48:27 +11:00
Chris Pavlina 89cfef99c1 Convert to single page hotkeys editor. 2016-01-05 13:46:45 -05:00
Maciej Suminski 203e8156a1 pcbnew asks before rotating/flipping a locked item (GAL). 2016-01-05 17:01:59 +01:00
Cirilo Bernardo b126c1b697 Fixed mistaken cut/paste use of VRML2 where it should be VRML1 2016-01-05 19:35:15 +11:00
Cirilo Bernardo 42f83bdf8a VRML1 plugin: added Coordinate3 type node 2016-01-05 19:29:28 +11:00
Cirilo Bernardo 9f9f146cd9 Work in progress: VRML1 plugin 2016-01-05 18:55:54 +11:00
Cirilo Bernardo 79e0564622 Work in progress: VRML1 plugin 2016-01-05 16:38:53 +11:00
Cirilo Bernardo 43c2c7223b Sync with main branch r6421 2016-01-05 16:37:52 +11:00
Chris Pavlina ed2a1d5955 Hotkey dialog refactor.
* Replace the wxListCtrl with a wxTreeListCtrl, allowing expandable categories
  in a future change.
* Clean up the code to make HOTKEY_LIST_CTRL function a bit better on its own.
* Migrate the hotkey dialog to TransferData{To,From}Window, use matching
  TransferData{To,From}Control methods on HOTKEY_LIST_CTRL so it is easy to
  embed.
2016-01-04 19:31:35 -05:00
Wayne Stambaugh 73d6fa3368 Compiling KiCad from source developer documentation fixes.
* Remove KICAD_SKIP_BOOST build configuration option.
* Remove USE_OSX_DEPS_BUILDER build configuration option.
* Add missing web link for OpenGL Mathematics library (GLM).
2016-01-04 17:00:42 -05:00
Bernhard Stegmaier 8c78bd5fd8 OSX: legacy canvas rendering speed improvements.
* Enables USE_WX_GRAPHICS_CONTEXT for OSX by default.  This shouldn¡¯t be a
  major change because it seems to get used on OSX behind the scenes anyway.
  As a side effect, this might improve behavior with anti-aliasing because
  KiCad shifts drawing by (0.5, 0.5) into the middle of the virtual pixels so
  things may be less blurry.  It will still build without enabling
  USE_WX_GRAPHICS_CONTEXT, but the optimizations obviously won¡¯t be used.
* The optimizations currently only are effective when USE_WX_GRAPHICS_CONTEXT
  is enabled and OSX.  They might be also good for other platforms using
  USE_WX_GRAPHICS_CONTEXT because it aggregates some drawing primitives using
  paths wxGraphicsContext provides.
* It adds some #ifdefs for disabling the wxGraphicsContext stuff when
  USE_WX_GRAPHICS_CONTEXT isn¡¯t enabled.  If you hate #ifdefs, this also
  could be dropped but then it will always check if wxGraphicsContext can be
  applied.
2016-01-04 15:13:10 -05:00
Simon Wells 9ba18a4e66 Open PDF viewer improvements. (fixes lp:1530162)
* Fix broken ExecuteCommand() when path contains spaces on OSX.
* Only use system defined mime type for PDF files.
* Remove system dependent fallback applications for opening PDF files.
2016-01-04 13:33:45 -05:00
Simon Wells 5caea3f599 Removed the space in the error message after the new line 2016-01-05 06:12:37 +13:00
Wayne Stambaugh c68790751a Developer documentation and other minor fixes.
* Update the developer road map document.
* Update the compiling KiCad from source document to reflect recent build
  changes.
* Change Cairo library version to 1.8.8 to fix build issues on CentOS 6.
2016-01-04 10:23:28 -05:00
Simon Wells d3dfb5bcc4 Merged lp:~xzcvczx/kicad/page-settings_datetime. 2016-01-04 15:22:59 +01:00
Cirilo Bernardo d52d8867c8 Fixed bug in vrml2_shape.cpp which resulted in segfaults. (used AND rather than OR in control statement) 2016-01-04 20:24:40 +11:00
Cirilo Bernardo c798f8b545 Added support for FreeCAD VRML files 2016-01-04 18:10:15 +11:00
Wayne Stambaugh ff924f6983 Remove download_avhttp.cmake and avhttp source archive. 2016-01-03 18:55:42 -05:00
Cirilo Bernardo 97d4c33a9f Fixed preview pane resizing 2016-01-04 09:15:53 +11:00
Wayne Stambaugh bd436aa6a7 Developer documentation clean up.
* Remove push and shove router documentation which is maintained in the
  user documentation.
* Remove coding_style_policy.pdf since it is know automatically generated
  with the developers documentation and linked on the KiCad website.
* Merge the contents of rules_for_capitalization_in_Kicad_UI.txt into
  UIPolicy.txt.
* Remove rules_for_capitalization_in_Kicad_UI.txt.
2016-01-03 16:53:20 -05:00
Wayne Stambaugh c751bf60bc Remove Boost library building and other build improvements.
* Remove download and build Boost from source and all CMake boost source build
  dependencies.
* Make FindCairo.cmake use pkg-config when it's available not just all
  platforms except windows.
* Add version checking to FindCairo.cmake.
* Change find GML version to 0.9.5.1 which is the current version in Ubuntu
  14.04 LTS.
* Update required Cairo version to 1.12.1.
2016-01-03 15:33:09 -05:00
Wayne Stambaugh 133b8f6b96 Eeschema: move annotate power symbols from SCH_SHEET_PATH to SCH_SHEET.
1
* Uncouple SCH_COMPONENT::SetRef() from  SCH_SHEET_PATH and use SCH_SHEET  instead.
2016-01-03 08:58:27 -05:00
Cirilo Bernardo 54905cb15c Adding forgotten VRML2 Box sources 2016-01-03 17:58:23 +11:00
Cirilo Bernardo 5208a1b47e Added VRML2 Box node 2016-01-03 16:55:53 +11:00
Cirilo Bernardo 59cf4c5ed0 + Fixed calculation of overall transform in SCENEGRAPH
+ Fixed NULL dereference bug in VRML2 nodes
2016-01-03 14:55:30 +11:00
Cirilo Bernardo 62c6cba2a1 Reorganizing VRML parser code 2016-01-03 10:06:28 +11:00
Cirilo Bernardo 4d9ce774a8 Organizing VRML2 plugin debug reporting levels 2016-01-03 09:57:41 +11:00
Cirilo Bernardo 8939955f2f Relax VRML2 naming rules (perhaps temporarily) to accept the '-' character in DEF names 2016-01-03 09:18:16 +11:00
Simon Wells b02bc2bf50 Reorder includes to a more logical order 2016-01-03 01:55:38 +13:00
Cirilo Bernardo 76bf525d12 + Changed the debug output switch to DEBUG_VRML2
+ Transform nodes will now correctly include referenced nodes
2016-01-02 14:41:54 +11:00
Cirilo Bernardo 012e0a2066 Clean up naming of plugin VRML test output 2016-01-02 14:04:28 +11:00
Cirilo Bernardo fad73f0e85 VRML2 3D plugin is now functional 2016-01-02 12:21:02 +11:00
unknown 662d35633a Minor changes to eeschema options dialog 2016-01-01 10:47:17 +01:00
Simon Wells 4634f04ef9 Made the page settings dialog use todays date as default 2016-01-01 21:39:12 +13:00
Cirilo Bernardo d68418d613 Work in progress: WRL2 to SGNODE translation 2016-01-01 18:55:43 +11:00
Simon Wells 0d9ffb11fa Ensure filetype is not null before using open command, Fixed if statements to follow coding guidelines 2016-01-01 20:51:50 +13:00
Cirilo Bernardo b426740195 Removed dead code modules 2016-01-01 16:23:21 +11:00
Cirilo Bernardo 68a512693f Work in progress: implementing VRML2 plugin 2016-01-01 16:05:14 +11:00
jean-pierre charras a84d8f70bc Very minor fixes in dialog_eeschema_options_base: make the dialog resizable, and remove duplicate accelerator keys in 2 items. 2015-12-31 17:11:47 +01:00
Chris Pavlina e12d6fb82f Eeschema: improve default field option dialog tab (fixes lp:1527309)
* Use wxGrid to edit default fields in option dialog which allows user to
  directly instead a separate edit panel.
* Implement TransferData{To,From}Window methods.
2015-12-31 10:12:09 -05:00
Simon Wells 57d4c90055 Fixed bug with a text editor with a space in the name on OSX 2015-12-31 23:16:26 +13:00
Simon Wells c3589b5558 Cleaned up the OpenPDF function, including removing workaround code added in commit 1085 that is no longer required. Added Quotes around the pdf program if a custom one is used in case there are spaces in the file name 2015-12-31 22:03:47 +13:00
Cirilo Bernardo f7ea4ddb72 Cleaning up code in preparation for merge 2015-12-31 10:31:35 +11:00
Cirilo Bernardo 70b545895b Cleaning up debug info messages in preparation for merge 2015-12-31 09:56:56 +11:00
Cirilo Bernardo 548b54d75d + resync with main branch r6409
+ work in progress: new VRML2 3D plugin
2015-12-31 09:28:39 +11:00
jean-pierre charras 2016e92132 Github plugin with curl: fix lack of message when trying to download a non existing footprint library (Curl does not return an error: the message "Not Fount" is stored in buffer, and the zip handler returns a not suitable error message)
Minor and very minor other fixes.
2015-12-30 09:10:39 +01:00
jean-pierre charras 6ff0092e21 Github plugin: fix lack of message when trying to download a non existing footprint library (Curl does not return an error: the message "Not Fount" is stored in buffer, and the zip handler returns a not suitable error message)
Minor and very minor other fixes.
2015-12-30 08:46:32 +01:00
jean-pierre charras ab585f46ce Update doc. 2015-12-29 13:14:35 +01:00
Chris Pavlina 3dff6c097e Eeschema: reorganize options dialog. 2015-12-28 08:33:21 -05:00
Element Green 0417538ab3 Fix Bug #1529214 (pcbnew VRML export dialog settings have no effect) 2015-12-27 18:33:15 +01:00
jean-pierre charras 9d994663f1 Fix Bug #1527446 (Flipping a block in pcbnew doesn't flip inner layers nor their connected microvias).
Also fix a few typos and remove dead code.
2015-12-27 16:51:13 +01:00
jean-pierre charras c4ea4dc0df Fix some warnings (looking like potential bugs) detected by cppcheck, (a few from a patch from Julien Nabet <serval2412@yahoo.fr>), remove not used vars and a few coding style fixes. 2015-12-27 13:16:46 +01:00
Simon Wells 415c72262a Pcbnew: use Legacy instead of Default when referring to wxDC canvas. 2015-12-22 16:25:59 -05:00
Simon Wells 6721545011 Pcbnew: remove the sunken border from the design rules dialog,
* On Linux it has no effect
* On OSX it removes the line border which looks ugly.
* On Windows it makes the dialog look cleaner.
2015-12-22 13:53:13 -05:00
unknown a49b313c77 Fix a cosmetic issue: the "Move exactly" dialog was not exactly right on init 2015-12-22 15:34:34 +01:00
unknown cbc88dfde3 Update INSTALL.txt with current dependencies 2015-12-22 15:25:41 +01:00
unknown e506a4354b Replace avhttp with libcurl: Some fixes:
1. Fixed an assumption somebody originally made in the plugin that std::string had contiguous storage. This is not specced behavior pre C++11 so we gamble by calling .reserve() which should give a far better guarantee.
2. Added copy to clipboard information for curl
3. Removed some openssl references in compiling.md
4. Renamed struct vars to be uppercase to match "public var" code style policy
2015-12-22 15:19:00 +01:00
jean-pierre charras 59d02cf1a4 Minor fixes:
* fix minor coding style issues.
* remove unused member in modview_frame.
* use different frame names in ctor of modview_frame and viewlib_frame depending on the fact they are built modal or not modal (allowing identifications when calling wxFindWindowByName)
* change questionnable code in  class_libentry.cpp.
* remove unused code in class_treeproject_item.cpp
2015-12-22 12:58:26 +01:00
Cirilo Bernardo 189f6fa763 Work in progress: VRML2 parser 2015-12-22 19:02:18 +11:00
Cirilo Bernardo e08c0de68f Work in progress: VRML2 parser 2015-12-22 17:02:33 +11:00
Cirilo Bernardo 07bd4cbc04 + Resync with main r6397
+ Work in progress: VRML parser
2015-12-22 11:08:39 +11:00
Cirilo Bernardo b1177e9025 Work in progress: VRML2 parser 2015-12-22 08:19:05 +11:00
Mark Roszko e47bc6883d Replace the avhttp library used by the github plugin with libcurl. 2015-12-21 15:30:33 -05:00
jean-pierre charras 56d1cac0e8 Pcbnew: avoid crash if something is wrong when opening the Python Console (for instance missing python module) 2015-12-21 21:00:32 +01:00
unknown f041177c3a Fix Bug #1526158 (pcbnew Zone tool: Minimum width is compared against thermal relief spoke, when Pad connection set to "None") 2015-12-21 19:42:16 +01:00
Wayne Stambaugh 96832a5185 Fix build error cause by previous commit when KICAD_SCRIPTING_WXPYTHON is not enabled. 2015-12-21 10:39:36 -05:00
unknown 0ea1c67caf eeschema plot dialog: cosmetic enhancement:
Including the inline of the Output directory and its text field/browse button.
Moving the plot format to the left of the plot options as the plot options depend on the plot format.
2015-12-21 16:08:37 +01:00
Strontium c3d3a7a4c8 Scripting: replace PyCrust shell with enhanced PyAlaMode shell. 2015-12-21 09:55:31 -05:00
jean-pierre charras a11bbffe9b Code reorganization, and change the way 3D viewer frame is managed (now using wxWidgets wxWindow::FindWindowByName() to know if it is existing) , to prepare others fixes. 2015-12-21 12:52:00 +01:00
Fabian M 4e99c9897e Fix spelling errors in README.txt. 2015-12-20 16:37:58 -05:00
Wayne Stambaugh 81e6af6c81 Eeschema: move auto-save test from SCH_SHEET_PATH to SCH_SHEET. 2015-12-20 15:58:18 -05:00
Chris Pavlina 769e18d376 Eeschema: add wildcard and regular expression search to componet select dialog.
* Create base class EDA_PATTERN_MATCH to hand multiple pattern matching methods.
* Create classes for regular expression and wildcard pattern matching.
* Add new pattern matching semantics to component select dialog.
* Thanks to Henner Zellar <h.zeller@acm.org> for improvments to the original patch.
2015-12-20 15:52:39 -05:00
jean-pierre charras e175a96be4 Pcbnew: Enhancement: in Get footprint (hotkey 'T') : better footprint selector dialog. 2015-12-20 19:47:52 +01:00
jean-pierre charras b881ba2bd7 Fix minor Bug #1527398 (Some items (NPTH holes) printed in color with B&W radiobutton checked) 2015-12-20 15:09:06 +01:00
jean-pierre charras fcdbb7484c fix Bug #152546 (Netlist not respecting case sensitivity for labels): the label matching is now case sensitive. To avoid issues with previous eeschema versions, add in ERC a dectection for "similar" labels (labels which differ only by a case sensitivity)
(this option can be disabled, and saved in project config)
2015-12-20 13:40:17 +01:00
Cirilo Bernardo 735137a26a Work in progress: VRML2 parser 2015-12-20 23:37:04 +11:00
Cirilo Bernardo e13dade517 Added beginnings of VRML parser 2015-12-20 18:59:26 +11:00
jean-pierre charras 0842a107fb Fix Bug #1527804 (Eeschema crashes when loading malformed libraries (mainly incorrect libs converted from Eagle) 2015-12-19 10:49:48 +01:00
Cirilo Bernardo fb4b48f35b Removed accidental include in plugins/3d/CMakeLists.txt 2015-12-19 18:00:30 +11:00
Cirilo Bernardo 70be4e8f7f + Reverted accidental edit of sg_node.cpp
+ Fixed invocation of SHAPE_POLY_SET::Simplify() to match changes in main
2015-12-19 17:53:07 +11:00
Cirilo Bernardo 2c4b220f3c Resync with main branch r6383 2015-12-19 15:02:52 +11:00
Cirilo Bernardo 6cd0e51775 Removed build of demo plugin files 2015-12-19 14:59:42 +11:00
Cirilo Bernardo 396825d960 Cleaning up in preparation for merge 2015-12-19 14:57:02 +11:00
unknown 02d9bbbf2b Improve automatic placement of fields between wires 2015-12-18 10:17:05 +01:00
Cirilo Bernardo 86c54ce636 Modified IDF plugin to support IDF assemblies (*.emn) in addition to component outlines (*.idf) 2015-12-18 19:43:27 +11:00
Simon Wells f11da559c7 Removed the sunken border from the Design Rules dialog 2015-12-18 11:56:23 +13:00
unknown 22fdfa61ef Make message window title translatable in a rescue dialog. 2015-12-17 20:06:13 +01:00
Chris Pavlina 3c6c6dcc88 Eeschema: make field autoplace spacing flexible by field text height. 2015-12-17 11:36:03 -05:00
Cirilo Bernardo 85e438570f Fixed bug for MSWin build (bad variable name) 2015-12-17 20:32:24 +11:00
Cirilo Bernardo 879c445b55 Preparing IDF plugin to support EMN/EMP files 2015-12-17 14:46:09 +11:00
Cirilo Bernardo 008d8a540a + Fixed bug in SGSHAPE::Prepare() : bad assignment of color pointer
+ Reworked s3d_plugin_demo2.cpp to use per-vertex-per-face normals
+ Reworked s3d_plugin_idf.cpp to use per-vertex-per-face normals
2015-12-17 13:55:35 +11:00
Wayne Stambaugh 1bd860d1aa Eeschema: move modification state code from SCH_SHEET_LIST to SCH_SHEET. 2015-12-16 19:27:53 -05:00
Chris Pavlina 2add6ca736 Eeschema: fix spacing issues in options dialog. (fixes lp:1526790) 2015-12-16 19:19:16 -05:00
Cirilo Bernardo eab70be17b Changed cache->Prepare() to cache->GetModel() 2015-12-17 09:21:30 +11:00
Simon Wells e7ac0d6764 Fix building layer widget in stand alone mode. 2015-12-16 10:19:27 -05:00
Cirilo Bernardo c0fcb15e3a + Rework S3D_CACHE::Prepare() to take only a filename and return
non-transformed S3DMODEL for rendering.
+ S3D_CACHE now caches S3DMODEL and returns a pointer to a single
  instance of the S3DMODEL for repeated calls to Prepare()
+ Beginning the VRML Plugin
2015-12-16 20:01:44 +11:00
Cirilo Bernardo 580f7aecfc Added model coloring to the IDF 3D model plugin 2015-12-16 15:11:54 +11:00
Cirilo Bernardo c251fbac75 + Improved the normals calculations (however it's still buggy)
+ Reworked 3D plugins to use normals calculations
2015-12-16 14:25:46 +11:00
jean-pierre charras 178cf0dc25 Polygon calculation (zones filling): use fast mode when possible (in fact most of time) and strictly simple polygon option only in critical cases (in fact in plot Gerber functions mainly).
In polygon calculations (combining polygons, fracture) the mode of calculation (fast or strictly simple polygon option) as no more a default value, because choosing the best mode is better to optimize the calculation time.
2015-12-15 21:21:25 +01:00
Maciej Suminski 0caa47e73c Fixed crash on undo pad placement in the footprint editor (GAL). 2015-12-15 13:39:53 +01:00
Cirilo Bernardo 304cd81ebd + Bugfix: changed Plugin Loader to expect 'GetPluginVersion' instead of
'GetVersion'.
+ Introduced normal calculations. This is buggy due to multiple equal
  face normals distorting the vertex normal; this will be fixed by
  removing the redundant face normals from the calculations.
2015-12-15 18:53:03 +11:00
Kristian Nielsen 6f4be750b5 Fix GLM 3D viewer build configuration error. 2015-12-14 19:43:00 -05:00
Simon Wells cccc314524 Remove unnecessary include to Carbon.h in fctsys.h. 2015-12-14 19:21:51 -05:00
Cirilo Bernardo 1940bd71e4 Resync with main branch + fix MSWin build (accidental inclusion of dlfcn.h) 2015-12-15 10:56:11 +11:00
Cirilo Bernardo 31509fa52c Removed superfluous comment 2015-12-15 09:27:34 +11:00
Cirilo Bernardo 6294e507f9 Changed function name to avoid name clash with MinGW system call 2015-12-15 09:17:10 +11:00
Cirilo Bernardo aff84eab52 Using stdint.h rather than cstdint on MSWin 2015-12-15 08:44:20 +11:00
Cirilo Bernardo 2128594a85 Coding policy fixes: remove trailing white space. 2015-12-14 16:20:54 -05:00
Cirilo Bernardo b7d44368bd Build fix: do not include cstdint under MSYS/MinGW 2015-12-15 07:52:37 +11:00
Simon Wells 7b2858acc8 Updated layer_widget.cpp to remove build errors when STAND_ALONE is set 2015-12-15 06:45:11 +13:00
Cirilo Bernardo f099ae27c5 Feature implementation complete: save and load cache data 2015-12-14 20:15:44 +11:00
jean-pierre charras 5d429ed977 Pcbnew: drill file generation: always creates a NPTH file in separate files mode (as it was made in initial code) to avoid mistakes (old broken NPTH file after board edition for instance).
Eeschema: prepare case sensitive label comparison in netlist generation.
2015-12-14 09:00:49 +01:00
Cirilo Bernardo 4924db7491 Bugfix: create 3d config path if nonexistent 2015-12-14 18:41:15 +11:00
Cirilo Bernardo a2fe783f53 Finished refactor and introduction of generic Plugin scheme 2015-12-14 14:51:28 +11:00
Cirilo Bernardo 3ff8ca0caf Refactored to use new generic plugin base 2015-12-14 08:45:22 +11:00
Chris Pavlina 50c418a332 Eeschema: add field automatic placement feature. 2015-12-13 11:56:47 -05:00
Simon Richter 7cbf8a0bda CMake: remove older GCC optimization settings since boost::polygon is no longer used. 2015-12-12 14:56:55 -05:00
jean-pierre charras 7dbefa29ac Minor fix: Remove a duplicate title in eeschema dialog plot. 2015-12-12 19:32:18 +01:00
Wayne Stambaugh c6d591b534 Eeschema: uncouple clearing annotation from SCH_SHEET_PATH.
* Add code to SCH_SHEET object to clear annotation.
* Change SCH_COMPONENT::GetPath() to derive path from SCH_SHEET object instead
  of SCH_SHEET_PATH object.
* Remove clear annotation code from SCH_SCREENS object.
2015-12-12 12:06:24 -05:00
Simon Wells b21b5513fd removed wx carbon include in fctsys as it is unnecessary 2015-12-12 23:03:35 +13:00
Cirilo Bernardo 86042d86a6 Added partial render ability to IDF plugin 2015-12-11 17:37:42 +11:00
Cirilo Bernardo b46451ec81 Introducing the IDF 3D plugin and reorganizing directories 2015-12-11 08:34:52 +11:00
Cirilo Bernardo c5e9bda936 Fix OpenGLM build errors for OSX homebrew developers. 2015-12-10 14:20:35 -05:00
Wayne Stambaugh 204f025ff4 Build configuration fixes.
* Fix broken include path in FindGLM.cmake ( credit Cirilo Bernardo ).
* Fix if()/endif() warning in FindGLM.cmake.
* Remove trailing white space in FindGLM.cmake.
* Fix bug introduced in r6363 that inadvertently made OpenMP a required
  dependency instead of an optional dependency.
* Remove quiet flag for FindOpenMP to report findings.
2015-12-10 11:35:43 -05:00
Maciej Suminski 843c9b99d5 Fixed ratsnest for PCBs imported using plugins (GAL). 2015-12-10 16:29:12 +01:00
unknown eaef5c1043 * Replace questionable wxString::PrintfV() call (which doesn't work reliably on different platforms) with wxString::Format()
*  Extra win: due to use now of the THROW_IO_ERROR() macro, error messages contain line numbers.
2015-12-10 09:13:35 +01:00
Cirilo Bernardo 210416aca4 Attempting to improve the file selector path list combo box 2015-12-10 15:02:05 +11:00
Cirilo Bernardo 4e12999fa8 Removed some trailing white space. Fixed FindGLM. 2015-12-10 11:31:44 +11:00
Simon Richter e872585105 CMake: move find OpenMP so it can be found for all compilers not just GCC. 2015-12-09 15:53:52 -05:00
jean-pierre charras 04271893ff Fix Bug #1521282 (footprint wizard for SOIC ICs generates a wrong position pin mark) 2015-12-09 17:11:32 +01:00
Mark Roszko 030c84d55d Use defined environment variables before falling back to DEFAULT_INSTALL_PATH. 2015-12-09 09:41:41 -05:00
unknown 274e88d381 Fix Python demo script gen_gerber_and_drill_files_board.py to choose one or 2 drill files when calling SetOptions() if NPTH pads are used. 2015-12-09 12:56:18 +01:00
Cirilo Bernardo 41025154a6 Synced to main branch 2015-12-09 19:51:45 +11:00
Cirilo Bernardo f711c9564b Removed empty directory 2015-12-09 19:50:34 +11:00
unknown 77bc1a2dd1 Fix typo in CMakeLists.txt ( in CMake function for position independent code). 2015-12-09 09:03:59 +01:00
Cirilo Bernardo ac3acb0061 Moving headers to facilitate support for building 3D plugins out-of-tree 2015-12-09 18:30:48 +11:00
Cirilo Bernardo a0597c4614 GUI improvements including interactive update of model orientation/position 2015-12-09 16:43:30 +11:00
Cirilo Bernardo 47f40def0c GUI improvements including control of panel sizes and resizing of GL canvas in preview 2015-12-09 10:38:25 +11:00
Cirilo Bernardo 712f57f002 Re-enabled bounding box display 2015-12-09 09:58:36 +11:00
Cirilo Bernardo 2ba7c05cbf Resync with main branch and fixed to work with new symbol visibility rules 2015-12-09 09:52:02 +11:00
unknown 0ae5fed41f When changing the number of copper layers, new layers added to the board in pcbnew are now selected by default for plotting 2015-12-08 16:15:24 +01:00
Simon Richter 32d4dae5ef CMake: use CMake's position independent code handling.
* Bump minimum CMake revision to 2.8.12.  The CMake position independent code
  handling was introduced in CMake 2.8.9 but 2.8.12 is current version in
  Ubuntu 14.04 LTS which is a very popular distro.
* CMake provides a simple declarative statement to enable PIC, so no compiler
  dependent handling is required.
* There is also no need to tell Boost to build with -fPIC, their build system
  is smart enough.
2015-12-08 09:17:23 -05:00
unknown 893e018bc9 Better warning messages in duplicate zone 2015-12-08 13:02:44 +01:00
jean-pierre charras 256e47c00f Commit missing file FindGLM.cmake 2015-12-08 11:52:09 +01:00
Maciej Suminski 231eaecf34 Removed the included GLM library, switched to the system one. 2015-12-08 10:56:53 +01:00
Cirilo Bernardo 6e5473f646 Minor fix: remove reference to GLdebug() 2015-12-08 18:56:30 +11:00
Mario Luzeiro 69cc788e8e + Removed glm source from kicad tree (Maciej / Cirilo)
+ Added renderer for 3D model preview (Mario)
+ Added 3d_cache including name resolver and modifications to 3D model dialogs (Cirilo)
2015-12-08 18:31:57 +11:00
Wayne Stambaugh 2667109c44 Eeschema: SCH_SHEET improvements for Eeschema refactor.
* Make SCH_SHEET parent the SCH_SHEET object that loaded it.  This preserves
  the hierarchy when the schematic is loaded.
* Add function to SCH_SHEET to find the root sheet from any sheet in the
  hierarchy.
* Add functions to SCH_SHEET to create the path and human readable paths for
  any sheet without relying on the external SCH_SHEET_PATH object.
* Remove function LocatePathOfScreen from SCH_SHEET since it was not used
  anywhere.
* Add human readable path to message panel information for SCH_SHEET.
* Set the name of the root sheet to "root" instead of the default generated
  when a new SCH_SHEET is created.
* Set the empty sheet name and file name to "root" and "noname.sch" when
  Eeschema is opened with no schematic.
* When no item is at the current position on a left mouse click, show the
  current sheet information in the message panel.
* Add less than operator for sorting SCH_SHEET objects by path length and
  time stamps when the path lengths are the same.
2015-12-07 19:37:11 -05:00
Simon Richter 2869c9f49a CMake: use visibility definitions in provided by CMake when available.
CMake 3.0 defines two new variables:

 * CMAKE_CXX_VISIBILITY_PRESET and
 * CMAKE_VISIBILITY_INLINES_HIDDEN

to control whether symbols not explicitly tagged for export are implicitly
exported.  Because only version 3.3 and later also applies that to static
libraries when in 3.3 mode, compatibility code is added as well.

When the minimum required version is bumped to 3.3, this code becomes
obsolete and a warning is displayed that the compatibility code should be
removed as well.
2015-12-07 16:46:18 -05:00
jean-pierre charras ab7350bf2d Better fix for issue fixed in rev 6350 2015-12-07 14:51:46 +01:00
jean-pierre charras fefa8d16f0 math_for_graphics.cpp: use abs() instead of std::abs() for integer values, to avoid errors with some compilers. 2015-12-07 11:01:33 +01:00
jean-pierre charras c80d92e927 Kicad manager: fix a potential bug which could crash Kicad manager. math_for_graphics.cpp: remove useless includes. 2015-12-07 10:24:31 +01:00
unknown 2e04d4d621 Fix the following bugs in the IDF export:
1. incorrect orientation of components on the bottom side of the board
when the #D model rotation is non-zero
2. failure to export when some components have no model set
2015-12-07 10:22:09 +01:00
jean-pierre charras 4c880400b1 Better sizing of wx_html_report_panel in dialog_netlist (fix bug #1522758) 2015-12-04 18:06:54 +01:00
Wayne Stambaugh b04f18b245 CMake: remove OpenSSL download and build dependency code.
* Removed some left over OSX_DEP_BUILDER code missed in my previous commit.
2015-12-03 10:59:02 -05:00
jean-pierre charras c99f6722df Messages created by IO_ERROR and PARSE_ERROR: the short filename of the kicad source file is printed instead of the full filename.
The full filename of a Kicad source file has no meaning for users.
2015-12-03 16:53:36 +01:00
jean-pierre charras 23a0dddea9 Potrace library: update version from 1.8 to 1.12 2015-12-03 16:46:17 +01:00
Maciej Suminski 9b4d12653e FIxed the drawing layer for arcs (GAL). 2015-12-03 15:05:53 +01:00
Maciej Suminski d373915340 Fixed crash when context menu is invoked during track dragging (GAL). 2015-12-03 14:26:12 +01:00
Wayne Stambaugh dd06abf002 Documentation: improvement to build from source on windows docs.
* Add note about 32-bit builds to MSYS2 the hard way section.
* Add known issues section for building on windows with MSYS2.
* Add 64-bit Boost 1.59 issue to MSYS2 issues section.
* Fix broken link to KiCad patches source path.
2015-12-02 13:57:54 -05:00
jean-pierre charras f4cf050669 Eagle plugin: fix typo errors. Use paired fab layers for layers 51 and 52. Not perfect, but better than the old choice (drawing layer) 2015-12-02 12:46:55 +01:00
unknown 42525dda98 Eagle importer support dimensions 2015-12-02 09:47:02 +01:00
unknown 6abffca175 Fix incorrect import of footprint fields NAME and VALUE in Eagle import board. 2015-12-02 09:18:32 +01:00
Wayne Stambaugh 6f5a49bb60 Remove OSX dependency builder code from CMake files.
* Remove USE_OSX_DEPS_BUILDER option.
* Remove all download_foo.cmake files used by the OSX dependency builder.
2015-12-01 09:44:40 -05:00
jean-pierre charras 7b0d981f21 pcb_calculator: bigger (more readable) microstrip_zodd_zeven bitmap. 2015-11-29 20:22:03 +01:00
Wayne Stambaugh 6e9237593d Update credits in AUTHORS.txt and about dialog. 2015-11-29 14:02:42 -05:00
jean-pierre charras 7f49fc9a03 Fix a minor bug I created in rev 6332 in dialog_design_rules.cpp (a line of code removed by accident). 2015-11-29 16:17:47 +01:00
jean-pierre charras 19e06f13fc Commit change which was missing in commit 6332 ( Pcbnew: auxiliary axis shape: use the same look as GAL, to be consistent with GAL.) 2015-11-29 15:53:03 +01:00
jean-pierre charras da9f68911c Autosize row label column in wxGrid in pcb_calculator and design rules dialog.
Pcbnew: auxiliary axis shape: use the same look as GAL, to be consistent with GAL.
Minor change in dialog_env_var_config (use the wxStdDialogButtonSize for usual OK, Cancel and help buttons)
2015-11-29 15:19:22 +01:00
jean-pierre charras 407aa9c586 Very minor fix: a pcbnew option (show page limits) was not stored in user config, and was lost after closing the session.
3d-viewer: very minor fix
2015-11-29 07:56:27 +01:00
unknown c1b46e6ed8 Fix bug Bug #1519590 (gal cannot start on surface book) 2015-11-29 07:50:25 +01:00
Adam Wolfe e511afdf0f Fix bug in library-repos-install.sh. 2015-11-24 16:53:15 -05:00
jean-pierre charras 22fb7dafba Rename the automatically generated version.h to kicad_build_version.h as a workaround to an issue in msys2: for a very obscure reason, version.h was added as dependency to most of .cpp files.
It was an issue, because each time the bzr version was modified, a full kicad rebuild was made.
It does not happen on Linux.
2015-11-24 11:09:39 +01:00
jean-pierre charras 9dc5bc4c66 Rename the automatically generated version.h to kicad_build_version.h as a workaround to an issue in msys2: for a very obscure reason, version.h was added as dependency to most of .cpp files. 2015-11-24 11:05:34 +01:00
jean-pierre charras 2afee8fb58 Make translation easier in dialog_create_array_base. 2015-11-22 11:21:14 +01:00
Wayne Stambaugh 08d9b362be More developer credit updates.
* Minor credit information updates.
* Add a packagers tab to the about dialog.
* Coding policy fixes.
2015-11-19 15:03:02 -05:00
Wayne Stambaugh 4b85adb7d3 Developer credit and copyright updates.
* Remove duplicate developer credits added in last commit.
* Update developer email addresses.
* Change copyright.h from GPL2+ to GPL3+ per FSF.
* Update newstroke license from CC-BY to CC0 with permission by author
  Vladimir Uryvaev which reflects the official license on the newstroke
  website http://vovanium.ru/sledy/newstroke/en.
* Coding policy fixes in AboutDialog_main.cpp.
2015-11-19 10:04:12 -05:00
jean-pierre charras 4749921bbc Remove confirmation dialog when deleting footprints.
Very minor other fixes.
2015-11-18 19:59:24 +01:00
Chris Pavlina bbba5d5c47 Eeschema: fix find and replace bug where replace value lags by one cycle. (fixes lp:1517101) 2015-11-18 10:38:46 -05:00
Tomasz Wlostowski 72b0593fdb Pcbnew: push and shove router fixes.
* Fix segfault caused by invalidation of the end item by
  PNS_LINE_PLACER::UpdateSizes().
* GAL zone drawing tool updates the ratsnest after zone drawing is complete.
* Fixed performance issue in zones processing using strict simplification
  only for the final filled area.
2015-11-18 09:35:17 -05:00
Wayne Stambaugh 20b6346180 Update authors.txt and developer list in about dialog. 2015-11-17 14:00:58 -05:00
jean-pierre charras 21d700facc Replace "module" by "footprint" in a few messages. 2015-11-17 17:18:00 +01:00
Wayne Stambaugh ebdc1e4b17 Pcbnew: minor footprint properties dialog fixes.
* Replace the term module with footprint.
* Use default dialog size to allow sizers to determine the size of the dialog.
* Fix a few alignment and spacing issues.
* Fix some minor grammatical issues.
* Use front and back for board side instead of top and bottom to be consistent
  with layer naming scheme.
2015-11-17 09:03:57 -05:00
jean-pierre charras 7f9a07334e Remove the 32 chars limit in chipname in dialog_edit_component_in_schematic, which is useless and creates a bug in wxGTK if the intial chip name has more than 32 chars. (Fix [Bug 1516157) 2015-11-17 09:22:03 +01:00
jean-pierre charras f31f129ce7 Remove the 32 chars limit in chipname in dialog_edit_component_in_schematic, which is useless and creates a bug in wxGTK if the intial chip name has more than 32 chars. 2015-11-17 08:48:51 +01:00
jean-pierre charras 49d75d5850 Drill file generation: add the option to merge NPTH and PTH, which was disabled recently, due to code changes.
Add missing translator name in AUTHORS.txt and About dialog (patch from Eldar Khayrullin)
2015-11-16 19:42:58 +01:00
jean-pierre charras d5aef07816 Kicad manager: fix a very serious bug which crashes Kicad when running and closing gerbview, pcb_calculator, bitmap2component or pl_editor, when the Kicad manager frame is not the top level frame (It happens very easily if eeschema or pcbnew is running, after opening and closing a dialog).
Fix a few wxWidgets asserts.
menubar in pcbnew: move the recreate .cmp file menu to export menu, and fixes its help comment which was fully outdated.
2015-11-15 19:04:19 +01:00
unknown 3e8b4503d1 Try to fix Bug #1458215 (3D viewer plane artifacts on first render) 2015-11-15 18:55:53 +01:00
unknown 4141a250fe Eagle plugin: remve a non-static initializer. 2015-11-15 18:53:26 +01:00
Jon Neal 19075e3434 Pcbnew: fix segfault in eagle plugin when importing zone keepout areas. 2015-11-15 08:29:48 -05:00
jean-pierre charras c3b51b0d07 2 very minor fixes in Eeschema:
* Component doc: add https as prefix in list of urls which are opened by a Internet browser.
* Import .cmp files: Use "IdModule" instead of "IdModule  =" as keyword for footprint name and use '=' only as separator.
2015-11-14 09:20:17 +01:00
jean-pierre charras a356293fee Cvpcb: Fix incorrect unique pad count for footprints using mixed letters/digits in pad name (like AA12, AB12 or Anod for instance.) and skip pads with no pad name. 2015-11-13 12:32:42 +01:00
Wayne Stambaugh 8f79b4fb11 Pcbnew: fix minor Doxygen comment error. 2015-11-11 15:16:39 -05:00
jean-pierre charras 34f1c0ea2d Fix a few Coverity warnings. 2015-11-11 19:47:51 +01:00
Damien Espitallier 16c2c398e9 CvPcb: count unique pin numbers when filtering by pin count. (fixes:1300719) 2015-11-11 13:35:26 -05:00
jean-pierre charras a988d7a2f1 Demos: minor update in kit-dev-coldfire-xilinx_5213.kicad_pcb 2015-11-10 20:33:02 +01:00
jean-pierre charras 91391a5975 Small change in gr_basic.cpp to try to fix Bug #1514635, which is a bug in wxWidgets Print process, on Linux (current pen having sometimes its setup lost after setting wxBrush in curren DC)
It was previoulsy incorrectly fixed when forcing the black and white print option.
2015-11-10 13:17:33 +01:00
jean-pierre charras 6cc91a074b Remove a few conditional compilation for wxWidgets version < 3.0
Update a old .fbp file.
2015-11-09 13:14:28 +01:00
4286 changed files with 730687 additions and 499854 deletions
-50
View File
@@ -1,50 +0,0 @@
boost_root
.downloads-by-cmake
Build
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
.*.swp
*.~*
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
-2
View File
@@ -1,2 +0,0 @@
[core]
excludesfile .bzrignore
+76
View File
@@ -0,0 +1,76 @@
boost_root
.downloads-by-cmake
Build*
build*
common/fp_lib_table_keywords.cpp
common/netlist_keywords.*
common/netlist_lexer.h
common/pcb_plot_params_lexer.h
common/page_layout/page_layout_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
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
pcb_calculator/attenuators/bridget_tee_formula.h
pcb_calculator/attenuators/pi_formula.h
pcb_calculator/attenuators/splitter_formula.h
pcb_calculator/attenuators/tee_formula.h
Makefile
CMakeCache.txt
auto_renamed_to_cpp
Testing
version.h
config.h
install_manifest.txt
Documentation/doxygen
Documentation/development/doxygen
*.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/png*
bitmaps_png/tmp
common/pcb_keywords.cpp
include/pcb_lexer.h
# demo project auxillary files
demos/**/*-bak
demos/**/_autosave-*
# editor/OS fluff
.*.swp
*~
.DS_Store
*.png
*.kiface
*.o
*.a
*.cmake
*.orig
*.rej
*.so
*.old
*.gch
*.orig
*.patch
-233
View File
@@ -1,233 +0,0 @@
/*
* 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 )
{
double a = aVertices[ii].y;
double b = aVertices[ii].z;
RotatePoint( &a, &b, m_MatRotation.x * 10 );
aVertices[ii].y = (float)a;
aVertices[ii].z = (float)b;
}
if( m_MatRotation.y )
{
double a = aVertices[ii].z;
double b = aVertices[ii].x;
RotatePoint( &a, &b, m_MatRotation.x * 10 );
aVertices[ii].z = (float)a;
aVertices[ii].x = (float)b;
}
if( m_MatRotation.z )
{
double a = aVertices[ii].x;
double b = aVertices[ii].y;
RotatePoint( &a, &b, m_MatRotation.x * 10 );
aVertices[ii].x = (float)a;
aVertices[ii].y = (float)b;
}
/* adjust offset position (offset is given in UNIT 3D (0.1 inch) */
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[2].x - aVertices[0].x;
by = aVertices[2].y - aVertices[0].y;
bz = aVertices[2].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();
}
S3DPOINT_VALUE_CTRL::S3DPOINT_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 );
}
S3DPOINT_VALUE_CTRL::~S3DPOINT_VALUE_CTRL()
{
// Nothing to delete: all items are managed by the parent window.
}
S3DPOINT S3DPOINT_VALUE_CTRL::GetValue()
{
S3DPOINT 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 S3DPOINT_VALUE_CTRL::SetValue( S3DPOINT 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 S3DPOINT_VALUE_CTRL::Enable( bool onoff )
{
m_XValueCtrl->Enable( onoff );
m_YValueCtrl->Enable( onoff );
m_ZValueCtrl->Enable( onoff );
}
+835
View File
@@ -0,0 +1,835 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 <fstream>
#include <utility>
#include <iterator>
#include <wx/datetime.h>
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/stdpaths.h>
#include <boost/uuid/sha1.hpp>
#include <glm/glm.hpp>
#include <glm/ext.hpp>
#include "common.h"
#include "3d_cache.h"
#include "3d_info.h"
#include "sg/scenegraph.h"
#include "3d_filename_resolver.h"
#include "3d_plugin_manager.h"
#include "plugins/3dapi/ifsg_api.h"
#define MASK_3D_CACHE "3D_CACHE"
static wxCriticalSection lock3D_cache;
static bool isSHA1Same( const unsigned char* shaA, const unsigned char* shaB )
{
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( NULL == aTag || NULL == 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
{
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)
public:
S3D_CACHE_ENTRY();
~S3D_CACHE_ENTRY();
void SetSHA1( const unsigned char* aSHA1Sum );
const wxString GetCacheBaseName( void );
wxDateTime modTime; // file modification time
unsigned char sha1sum[20];
std::string pluginInfo; // PluginName:Version string
SCENEGRAPH* sceneData;
S3DMODEL* renderData;
};
S3D_CACHE_ENTRY::S3D_CACHE_ENTRY()
{
sceneData = NULL;
renderData = NULL;
memset( sha1sum, 0, 20 );
}
S3D_CACHE_ENTRY::~S3D_CACHE_ENTRY()
{
if( NULL != sceneData )
delete sceneData;
if( NULL != renderData )
S3D::Destroy3DModel( &renderData );
}
void S3D_CACHE_ENTRY::SetSHA1( const unsigned char* aSHA1Sum )
{
if( NULL == aSHA1Sum )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL passed for aSHA1Sum";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return;
}
memcpy( sha1sum, aSHA1Sum, 20 );
return;
}
const wxString S3D_CACHE_ENTRY::GetCacheBaseName( void )
{
if( m_CacheBaseName.empty() )
m_CacheBaseName = sha1ToWXString( sha1sum );
return m_CacheBaseName;
}
S3D_CACHE::S3D_CACHE()
{
m_DirtyCache = false;
m_FNResolver = new S3D_FILENAME_RESOLVER;
m_Plugins = new S3D_PLUGIN_MANAGER;
return;
}
S3D_CACHE::~S3D_CACHE()
{
FlushCache();
if( m_FNResolver )
delete m_FNResolver;
if( m_Plugins )
delete m_Plugins;
return;
}
SCENEGRAPH* S3D_CACHE::load( const wxString& aModelFile, S3D_CACHE_ENTRY** aCachePtr )
{
if( aCachePtr )
*aCachePtr = NULL;
wxString full3Dpath = m_FNResolver->ResolvePath( aModelFile );
if( full3Dpath.empty() )
{
// the model cannot be found; we cannot proceed
wxLogTrace( MASK_3D_CACHE, " * [3D model] could not find model '%s'\n",
aModelFile.GetData() );
return NULL;
}
// check cache if file is already loaded
wxCriticalSectionLocker lock( lock3D_cache );
std::map< wxString, S3D_CACHE_ENTRY*, S3D::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 = false;
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( NULL != mi->second->sceneData )
{
S3D::DestroyNode( mi->second->sceneData );
mi->second->sceneData = NULL;
}
if( NULL != mi->second->renderData )
S3D::Destroy3DModel( &mi->second->renderData );
mi->second->sceneData = m_Plugins->Load3DModel( full3Dpath, mi->second->pluginInfo );
}
}
if( NULL != 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 )
{
return load( aModelFile );
}
SCENEGRAPH* S3D_CACHE::checkCache( const wxString& aFileName, S3D_CACHE_ENTRY** aCachePtr )
{
if( aCachePtr )
*aCachePtr = NULL;
unsigned char sha1sum[20];
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
S3D_CACHE_ENTRY* ep = new S3D_CACHE_ENTRY;
m_CacheList.push_back( ep );
wxFileName fname( aFileName );
ep->modTime = fname.GetModificationTime();
if( m_CacheMap.insert( std::pair< wxString, S3D_CACHE_ENTRY* >
( aFileName, ep ) ).second == false )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] duplicate entry in map file; key = '";
ostr << aFileName.ToUTF8() << "'";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
m_CacheList.pop_back();
delete ep;
}
else
{
if( aCachePtr )
*aCachePtr = ep;
}
return NULL;
}
S3D_CACHE_ENTRY* ep = new S3D_CACHE_ENTRY;
m_CacheList.push_back( ep );
wxFileName fname( aFileName );
ep->modTime = fname.GetModificationTime();
if( m_CacheMap.insert( std::pair< wxString, S3D_CACHE_ENTRY* >
( aFileName, ep ) ).second == false )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] duplicate entry in map file; key = '";
ostr << aFileName.ToUTF8() << "'";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
m_CacheList.pop_back();
delete ep;
return NULL;
}
if( aCachePtr )
*aCachePtr = ep;
ep->SetSHA1( sha1sum );
wxString bname = ep->GetCacheBaseName();
wxString cachename = m_CacheDir + bname + wxT( ".3dc" );
if( wxFileName::FileExists( cachename ) && loadCacheData( ep ) )
return ep->sceneData;
ep->sceneData = m_Plugins->Load3DModel( aFileName, ep->pluginInfo );
if( NULL != ep->sceneData )
saveCacheData( ep );
return ep->sceneData;
}
bool S3D_CACHE::getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum )
{
if( aFileName.empty() )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] empty filename";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return false;
}
if( NULL == aSHA1Sum )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aMD5Sum";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return false;
}
#ifdef WIN32
FILE* fp = _wfopen( aFileName.wc_str(), L"rb" );
#else
FILE* fp = fopen( aFileName.ToUTF8(), "rb" );
#endif
if( NULL == 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() )
{
#ifdef DEBUG
wxLogTrace( MASK_3D_CACHE, " * [3D model] cannot load cached model; no file hash available\n" );
#endif
return false;
}
if( m_CacheDir.empty() )
{
wxString errmsg = "cannot load cached model; config directory unknown";
wxLogTrace( MASK_3D_CACHE, " * [3D model] %s\n", errmsg.GetData() );
return false;
}
wxString fname = m_CacheDir + bname + wxT( ".3dc" );
if( !wxFileName::FileExists( fname ) )
{
wxString errmsg = "cannot open file";
wxLogTrace( MASK_3D_CACHE, " * [3D model] %s '%s'\n",
errmsg.GetData(), fname.GetData() );
return false;
}
if( NULL != aCacheItem->sceneData )
S3D::DestroyNode( (SGNODE*) aCacheItem->sceneData );
aCacheItem->sceneData = (SCENEGRAPH*)S3D::ReadCache( fname.ToUTF8(), m_Plugins, checkTag );
if( NULL == aCacheItem->sceneData )
return false;
return true;
}
bool S3D_CACHE::saveCacheData( S3D_CACHE_ENTRY* aCacheItem )
{
if( NULL == aCacheItem )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * NULL passed for aCacheItem";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return false;
}
if( NULL == aCacheItem->sceneData )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * aCacheItem has no valid scene data";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return false;
}
wxString bname = aCacheItem->GetCacheBaseName();
if( bname.empty() )
{
#ifdef DEBUG
wxLogTrace( MASK_3D_CACHE, " * [3D model] cannot load cached model; no file hash available\n" );
#endif
return false;
}
if( m_CacheDir.empty() )
{
wxString errmsg = "cannot load cached model; config directory unknown";
wxLogTrace( MASK_3D_CACHE, " * [3D model] %s\n", errmsg.GetData() );
return false;
}
wxString fname = m_CacheDir + bname + wxT( ".3dc" );
if( wxFileName::Exists( fname ) )
{
if( !wxFileName::FileExists( fname ) )
{
wxString errmsg = _( "path exists but is not a regular file" );
wxLogTrace( MASK_3D_CACHE, " * [3D model] %s '%s'\n", errmsg.GetData(),
fname.ToUTF8() );
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;
if( aConfigDir.StartsWith( "${" ) || aConfigDir.StartsWith( "$(" ) )
cfgdir.Assign( ExpandEnvVarSubstitutions( aConfigDir ), "" );
else
cfgdir.Assign( aConfigDir, "" );
cfgdir.Normalize();
if( !cfgdir.DirExists() )
{
cfgdir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
if( !cfgdir.DirExists() )
{
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
wxString errmsg = _( "failed to create 3D configuration directory" );
ostr << " * " << errmsg.ToUTF8() << "\n";
errmsg = _( "config directory" );
ostr << " * " << errmsg.ToUTF8() << " '";
ostr << cfgdir.GetPath().ToUTF8() << "'";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
return false;
}
}
m_ConfigDir = cfgdir.GetPath();
// inform the file resolver of the config directory
if( !m_FNResolver->Set3DConfigDir( m_ConfigDir ) )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * could not set 3D Config Directory on filename resolver\n";
ostr << " * config directory: '" << m_ConfigDir.ToUTF8() << "'";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
}
// 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
wxString cacheDir;
#if defined(_WIN32)
wxStandardPaths::Get().UseAppInfo( wxStandardPaths::AppInfo_None );
cacheDir = wxStandardPaths::Get().GetUserLocalDataDir();
cacheDir.append( "\\kicad\\3d" );
#elif defined(__APPLE)
cacheDir = "${HOME}/Library/Caches/kicad/3d";
#else // assume Linux
cacheDir = ExpandEnvVarSubstitutions( "${XDG_CACHE_HOME}" );
if( cacheDir.empty() || cacheDir == "${XDG_CACHE_HOME}" )
cacheDir = "${HOME}/.cache";
cacheDir.append( "/kicad/3d" );
#endif
cacheDir = ExpandEnvVarSubstitutions( cacheDir );
cfgdir.Assign( cacheDir, "" );
if( !cfgdir.DirExists() )
{
cfgdir.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
if( !cfgdir.DirExists() )
{
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
wxString errmsg = "failed to create 3D cache directory";
ostr << " * " << errmsg.ToUTF8() << "\n";
errmsg = "cache directory";
ostr << " * " << errmsg.ToUTF8() << " '";
ostr << cfgdir.GetPath().ToUTF8() << "'";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
return false;
}
}
m_CacheDir = cfgdir.GetPathWithSep();
return true;
}
wxString S3D_CACHE::Get3DConfigDir( bool createDefault )
{
if( !m_ConfigDir.empty() || !createDefault )
return m_ConfigDir;
// note: duplicated from common/common.cpp GetKicadConfigPath() to avoid
// code coupling; ideally the instantiating code should call
// Set3DConfigDir() to set the directory rather than relying on this
// directory remaining the same in future KiCad releases.
wxFileName cfgpath;
// From the wxWidgets wxStandardPaths::GetUserConfigDir() help:
// Unix: ~ (the home directory)
// Windows: "C:\Documents and Settings\username\Application Data"
// Mac: ~/Library/Preferences
cfgpath.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
#if !defined( __WINDOWS__ ) && !defined( __WXMAC__ )
wxString envstr = ExpandEnvVarSubstitutions( "${XDG_CONFIG_HOME}" );
if( envstr.IsEmpty() || envstr == "${XDG_CONFIG_HOME}" )
{
// XDG_CONFIG_HOME is not set, so use the fallback
cfgpath.AppendDir( wxT( ".config" ) );
}
else
{
// Override the assignment above with XDG_CONFIG_HOME
cfgpath.AssignDir( envstr );
}
#endif
cfgpath.AppendDir( wxT( "kicad" ) );
cfgpath.AppendDir( wxT( "3d" ) );
if( !cfgpath.DirExists() )
{
cfgpath.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
}
if( !cfgpath.DirExists() )
{
std::ostringstream ostr;
wxString errmsg = "failed to create 3D configuration directory";
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * " << errmsg.ToUTF8();
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
return wxT( "" );
}
if( Set3DConfigDir( cfgpath.GetPath() ) )
return m_ConfigDir;
return wxEmptyString;
}
bool S3D_CACHE::SetProjectDir( const wxString& aProjDir )
{
bool hasChanged = false;
if( m_FNResolver->SetProjectDir( aProjDir, &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 );
return;
}
wxString S3D_CACHE::GetProjectDir( void )
{
return m_FNResolver->GetProjectDir();
}
S3D_FILENAME_RESOLVER* S3D_CACHE::GetResolver( void )
{
return m_FNResolver;
}
std::list< wxString > const* S3D_CACHE::GetFileFilters( void ) 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();
return;
}
void S3D_CACHE::ClosePlugins( void )
{
if( NULL != m_Plugins )
m_Plugins->ClosePlugins();
return;
}
S3DMODEL* S3D_CACHE::GetModel( const wxString& aModelFileName )
{
S3D_CACHE_ENTRY* cp = NULL;
SCENEGRAPH* sp = load( aModelFileName, &cp );
if( !sp )
return NULL;
if( !cp )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] model loaded with no associated S3D_CACHE_ENTRY";
wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return NULL;
}
if( cp->renderData )
return cp->renderData;
S3DMODEL* mp = S3D::GetModel( sp );
cp->renderData = mp;
return mp;
}
wxString S3D_CACHE::GetModelHash( const wxString& aModelFileName )
{
wxString full3Dpath = m_FNResolver->ResolvePath( aModelFileName );
if( full3Dpath.empty() || !wxFileName::FileExists( full3Dpath ) )
return wxEmptyString;
// check cache if file is already loaded
std::map< wxString, S3D_CACHE_ENTRY*, S3D::rsort_wxString >::iterator mi;
mi = m_CacheMap.find( full3Dpath );
if( mi != m_CacheMap.end() )
return mi->second->GetCacheBaseName();
// a cache item does not exist; search the Filename->Cachename map
S3D_CACHE_ENTRY* cp = NULL;
checkCache( full3Dpath, &cp );
if( NULL != cp )
return cp->GetCacheBaseName();
return wxEmptyString;
}
+206
View File
@@ -0,0 +1,206 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines the display data cache manager for 3D models
*/
#ifndef CACHE_3D_H
#define CACHE_3D_H
#include <list>
#include <map>
#include <wx/string.h>
#include "str_rsort.h"
#include "3d_filename_resolver.h"
#include "3d_info.h"
#include "plugins/3dapi/c3dmodel.h"
class PGM_BASE;
class S3D_CACHE;
class S3D_CACHE_ENTRY;
class SCENEGRAPH;
class S3D_FILENAME_RESOLVER;
class S3D_PLUGIN_MANAGER;
class S3D_CACHE
{
private:
/// cache entries
std::list< S3D_CACHE_ENTRY* > m_CacheList;
/// mapping of file names to cache names and data
std::map< wxString, S3D_CACHE_ENTRY*, S3D::rsort_wxString > m_CacheMap;
/// object to resolve file names
S3D_FILENAME_RESOLVER* m_FNResolver;
/// plugin manager
S3D_PLUGIN_MANAGER* m_Plugins;
/// set true if the cache needs to be updated
bool m_DirtyCache;
/// 3D cache directory
wxString m_CacheDir;
/// base configuration path for 3D items
wxString m_ConfigDir;
/// current KiCad project dir
wxString m_ProjDir;
/** 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[in] aFileName file name (full or partial path)
* @param[out] aCachePtr optional return address for cache entry pointer
* @return SCENEGRAPH object associated with file name
* @retval NULL on error
*/
SCENEGRAPH* checkCache( const wxString& aFileName, S3D_CACHE_ENTRY** aCachePtr = NULL );
/**
* Function getSHA1
* calculates the SHA1 hash of the given file
*
* @param[in] aFileName file name (full path)
* @param[out] aSHA1Sum a 20 byte character array to hold the SHA1 hash
* @retval true success
* @retval false failure
*/
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, S3D_CACHE_ENTRY** aCachePtr = NULL );
public:
S3D_CACHE();
virtual ~S3D_CACHE();
/**
* Function Set3DConfigDir
* 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 );
/**
* Function Get3DConfigDir
* returns the current 3D configuration directory on
* success, otherwise it returns wxEmptyString. If the
* directory was not previously set via Set3DConfigDir()
* then a default is used which is based on kicad's
* configuration directory code as of September 2015.
*/
wxString Get3DConfigDir( bool createDefault = false );
/**
* Function SetProjectDir
* sets the current project's working directory; this
* affects the model search path
*/
bool SetProjectDir( const wxString& aProjDir );
/**
* Function SetProgramBase
* sets the filename resolver's pointer to the application's
* PGM_BASE instance; the pointer is used to extract the
* local env vars.
*/
void SetProgramBase( PGM_BASE* aBase );
/**
* Function GetProjectDir
* returns the current project's working directory
*/
wxString GetProjectDir( void );
/**
* Function Load
* attempts 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.
*
* @param aModelFile [in] is the partial or full path to the model to be loaded
* @return true if the model was successfully loaded, otherwise false.
* The model may fail to load if, for example, the plugin does not
* support rendering of the 3D model.
*/
SCENEGRAPH* Load( const wxString& aModelFile );
S3D_FILENAME_RESOLVER* GetResolver( void );
/**
* Function GetFileFilters
* returns 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( void ) const;
/**
* Function FlushCache
* frees all data in the cache and by default closes all plugins
*/
void FlushCache( bool closePlugins = true );
/**
* Function ClosePlugins
* unloads plugins to free memory
*/
void ClosePlugins( void );
/**
* Function GetModel
* attempts 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 );
wxString GetModelHash( const wxString& aModelFileName );
};
#endif // CACHE_3D_H
+70
View File
@@ -0,0 +1,70 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 <common.h>
#include <pgm_base.h>
#include "3d_cache_wrapper.h"
static wxCriticalSection lock3D_wrapper;
CACHE_WRAPPER::CACHE_WRAPPER()
{
return;
}
CACHE_WRAPPER::~CACHE_WRAPPER()
{
return;
}
S3D_CACHE* PROJECT::Get3DCacheManager( bool updateProjDir )
{
wxCriticalSectionLocker lock( lock3D_wrapper );
CACHE_WRAPPER* cw = (CACHE_WRAPPER*) GetElem( ELEM_3DCACHE );
S3D_CACHE* cache = dynamic_cast<S3D_CACHE*>( cw );
// check that we get the expected type of object or NULL
wxASSERT( !cw || cache );
if( !cw )
{
cw = new CACHE_WRAPPER;
cache = dynamic_cast<S3D_CACHE*>( cw );
wxFileName cfgpath;
cfgpath.AssignDir( GetKicadConfigPath() );
cfgpath.AppendDir( wxT( "3d" ) );
cache->SetProgramBase( &Pgm() );
cache->Set3DConfigDir( cfgpath.GetFullPath() );
SetElem( ELEM_3DCACHE, cw );
updateProjDir = true;
}
if( updateProjDir )
cache->SetProjectDir( GetProjectPath() );
return cache;
}
+37
View File
@@ -0,0 +1,37 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 CACHE_WRAPPER_3D_H
#define CACHE_WRAPPER_3D_H
#include <project.h>
#include "3d_cache.h"
class CACHE_WRAPPER : public S3D_CACHE, public PROJECT::_ELEM
{
public:
CACHE_WRAPPER();
virtual ~CACHE_WRAPPER();
};
#endif // CACHE_WRAPPER_3D_H
File diff suppressed because it is too large Load Diff
+204
View File
@@ -0,0 +1,204 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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_filename_resolver.h
* provides an extensible class to resolve 3D model paths. Initially
* the legacy behavior will be implemented and an incomplete path
* would be checked against the project directory or the KISYS3DMOD
* environment variable. In the future a configurable set of search
* paths may be specified.
*/
#ifndef FILENAME_RESOLVER_3D_H
#define FILENAME_RESOLVER_3D_H
#include <list>
#include <map>
#include <vector>
#include <wx/string.h>
#include "str_rsort.h"
class PGM_BASE;
struct S3D_ALIAS
{
wxString m_alias; // alias to the base path
wxString m_pathvar; // base path as stored in the config file
wxString m_pathexp; // expanded base path
wxString m_description; // description of the aliased path
};
class S3D_FILENAME_RESOLVER
{
private:
wxString m_ConfigDir; // 3D configuration directory
std::list< S3D_ALIAS > m_Paths; // list of base paths to search from
int m_errflags;
PGM_BASE* m_pgm;
wxString m_curProjDir;
/**
* Function createPathList
* builds the path list using available information such as
* KISYS3DMOD and the 3d_path_list configuration file. Invalid
* paths are silently discarded and removed from the configuration
* file.
*
* @return true if at least one valid path was found
*/
bool createPathList( void );
/**
* Function addPath
* checks that a path is valid and adds it to the search list
*
* @param aPath is the alias set to be checked and added
* @return true if aPath is valid
*/
bool addPath( const S3D_ALIAS& aPath );
/**
* Function readPathList
* reads a list of path names from a configuration file
*
* @return true if a file was found and contained at least
* one valid path
*/
bool readPathList( void );
/**
* Function writePathList
* writes the current path list to a configuration file
*
* @return true if the path list was not empty and was
* successfully written to the configuration file
*/
bool writePathList( void );
/**
* Function checkEnvVarPath
* checks the ${ENV_VAR} component of a path and adds
* it to the resolver's path list if it is not yet in
* the list
*/
void checkEnvVarPath( const wxString& aPath );
public:
S3D_FILENAME_RESOLVER();
/**
* Function Set3DConfigDir
* sets the user's configuration directory
* for 3D models.
*
* @param aConfigDir
* @return true if the call succeeds (directory exists)
*/
bool Set3DConfigDir( const wxString& aConfigDir );
/**
* Function SetProjectDir
* sets the current KiCad project directory as the first
* entry in the model path list
*
* @param[in] aProjDir current project directory
* @param[out] flgChanged optional, set to true if directory was changed
* @retval true success
* @retval false failure
*/
bool SetProjectDir( const wxString& aProjDir, bool* flgChanged = NULL );
wxString GetProjectDir( void );
/**
* Function SetProgramBase
* sets a pointer to the application's PGM_BASE instance;
* the pointer is used to extract the local env vars.
*/
void SetProgramBase( PGM_BASE* aBase );
/**
* Function UpdatePathList
* clears the current path list and substitutes the given path
* list, updating the path configuration file on success.
*/
bool UpdatePathList( std::vector< S3D_ALIAS >& aPathList );
/**
* Function ResolvePath
* determines the full path of the given file name. In the future
* remote files may be supported, in which case it is best to
* require a full URI in which case ResolvePath should check that
* the URI conforms to RFC-2396 and related documents and copies
* aFileName into aResolvedName if the URI is valid.
*/
wxString ResolvePath( const wxString& aFileName );
/**
* Function ShortenPath
* produces a relative path based on the existing
* search directories or returns the same path if
* the path is not a superset of an existing search path.
*
* @param aFullPathName is an absolute path to shorten
* @return the shortened path or aFullPathName
*/
wxString ShortenPath( const wxString& aFullPathName );
/**
* Function GetPaths
* returns a pointer to the internal path list; the items in:load
*
* the list can be used to set up the list of search paths
* available to a 3D file browser.
*
* @return pointer to the internal path list
*/
const std::list< S3D_ALIAS >* GetPaths( void );
/**
* Function SplitAlias
* returns true if the given name contains an alias and
* populates the string anAlias with the alias and aRelPath
* with the relative path.
*/
bool SplitAlias( const wxString& aFileName, wxString& anAlias, wxString& aRelPath );
/**
* Function ValidateName
* returns true if the given path is a valid aliased relative path.
* If the path contains an alias then hasAlias is set true.
*/
bool ValidateFileName( const wxString& aFileName, bool& hasAlias );
/**
* Function GetKicadPaths
* returns a list of path environment variables local to Kicad;
* this list always includes KISYS3DMOD even if it is not
* defined locally.
*/
bool GetKicadPaths( std::list< wxString >& paths );
};
#endif // FILENAME_RESOLVER_3D_H
+52
View File
@@ -0,0 +1,52 @@
/*
* 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 MODULE_3D_SETTINGS;
struct S3D_INFO
{
S3D_INFO();
S3D_INFO( const MODULE_3D_SETTINGS& 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
+588
View File
@@ -0,0 +1,588 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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/config.h>
#include <wx/dir.h>
#include <wx/dynlib.h>
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/stdpaths.h>
#include <wx/string.h>
#include "common.h"
#include "pgm_base.h"
#include "3d_plugin_dir.h"
#include "3d_plugin_manager.h"
#include "plugins/3d/3d_plugin.h"
#include "3d_cache/sg/scenegraph.h"
#include "plugins/ldr/3d/pluginldr3D.h"
#define MASK_3D_PLUGINMGR "3D_PLUGIN_MANAGER"
S3D_PLUGIN_MANAGER::S3D_PLUGIN_MANAGER()
{
// create the initial file filter list entry
m_FileFilters.push_back( _( "All Files (*.*)|*.*" ) );
// 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, " * Extension [plugin name]:\n" );
while( sM != eM )
{
wxLogTrace( MASK_3D_PLUGINMGR, " + '%s' [%s]\n", sM->first.GetData(),
sM->second->GetKicadPluginName() );
++sM;
}
}
else
{
wxLogTrace( MASK_3D_PLUGINMGR, " * 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, " * File filters:\n" );
while( sFF != eFF )
{
wxLogTrace( MASK_3D_PLUGINMGR, " + '%s'\n", (*sFF).GetData() );
++sFF;
}
}
else
{
wxLogTrace( MASK_3D_PLUGINMGR, " * No file filters available\n" );
}
#endif // DEBUG
return;
}
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();
return;
}
void S3D_PLUGIN_MANAGER::loadPlugins( void )
{
std::list< wxString > searchpaths;
std::list< wxString > pluginlist;
wxFileName fn;
#ifndef __WXMAC__
#ifdef DEBUG
// set up to work from the build directory
fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
fn.AppendDir( wxT("..") );
fn.AppendDir( wxT("plugins") );
fn.AppendDir( wxT("3d") );
std::string testpath = std::string( fn.GetPathWithSep().ToUTF8() );
checkPluginPath( testpath, searchpaths );
// add subdirectories too
wxDir debugPluginDir;
wxString subdir;
debugPluginDir.Open( testpath );
if( debugPluginDir.IsOpened() &&
debugPluginDir.GetFirst( &subdir, wxEmptyString, wxDIR_DIRS ) )
{
checkPluginPath( testpath + subdir, searchpaths );
while( debugPluginDir.GetNext( &subdir ) )
checkPluginPath( testpath + subdir, searchpaths );
}
#endif
#ifndef _WIN32
// multiarch friendly determination of the plugin directory: the executable dir
// is first determined via wxStandardPaths::Get().GetExecutablePath() and then
// the CMAKE_INSTALL_LIBDIR path is appended relative to the executable dir.
fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
fn.RemoveLastDir();
wxString tfname = fn.GetPathWithSep();
tfname.Append( wxString::FromUTF8Unchecked( PLUGINDIR ) );
fn.Assign( tfname, "");
fn.AppendDir( "kicad" );
#else
// on windows the plugins directory is within the executable's directory
fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
#endif
fn.AppendDir( wxT( "plugins" ) );
fn.AppendDir( wxT( "3d" ) );
// checks plugin directory relative to executable path
checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths );
// check for per-user third party plugins
// note: GetUserDataDir() gives '.pcbnew' rather than '.kicad' since it uses the exe name;
fn.Assign( wxStandardPaths::Get().GetUserDataDir(), "" );
fn.RemoveLastDir();
#ifdef _WIN32
fn.AppendDir( wxT( "kicad" ) );
#else
fn.AppendDir( wxT( ".kicad" ) );
#endif
fn.AppendDir( wxT( "plugins" ) );
fn.AppendDir( wxT( "3d" ) );
checkPluginPath( fn.GetPathWithSep(), searchpaths );
#else
// Search path on OS X is
// (1) User ~/Library/Application Support/kicad/PlugIns/3d
checkPluginPath( GetOSXKicadUserDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
// (2) Machine /Library/Application Support/kicad/PlugIns/3d
checkPluginPath( GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
// (3) Bundle kicad.app/Contents/PlugIns/3d
fn.Assign( Pgm().GetExecutablePath() );
fn.AppendDir( wxT( "Contents" ) );
fn.AppendDir( wxT( "PlugIns" ) );
fn.AppendDir( wxT( "3d" ) );
checkPluginPath( fn.GetPathWithSep(), searchpaths );
#endif
std::list< wxString >::iterator sPL = searchpaths.begin();
std::list< wxString >::iterator ePL = searchpaths.end();
while( sPL != ePL )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n";
ostr << " * [DEBUG] searching path: '" << (*sPL).ToUTF8() << "'";
wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
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() ) )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n";
ostr << "* [DEBUG] adding plugin";
wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
m_Plugins.push_back( pp );
int nf = pp->GetNFilters();
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] adding " << nf << " filters";
wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
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
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n";
ostr << "* [DEBUG] deleting plugin";
wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
delete pp;
}
++sPL;
}
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n";
ostr << "* [DEBUG] plugins loaded";
wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return;
}
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 modules)
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( ".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();
return;
}
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;
if( aPath.StartsWith( "${" ) || aPath.StartsWith( "$(" ) )
path.Assign( ExpandEnvVarSubstitutions( aPath ) );
else
path.Assign( aPath );
path.Normalize();
// 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;
}
aPluginList.push_back( wxpath );
#ifdef DEBUG
wxLogTrace( MASK_3D_PLUGINMGR, " * [INFO] found 3D plugin '%s'\n",
wxpath.GetData() );
#endif
return;
}
void S3D_PLUGIN_MANAGER::checkPluginPath( const wxString& aPath,
std::list< wxString >& aSearchList )
{
// check the existence of a path and add it to the path search list
if( aPath.empty() )
return;
#ifdef DEBUG
wxLogTrace( MASK_3D_PLUGINMGR, " * [INFO] checking for 3D plugins in '%s'\n",
aPath.GetData() );
#endif
wxFileName path;
if( aPath.StartsWith( "${" ) || aPath.StartsWith( "$(" ) )
path.Assign( ExpandEnvVarSubstitutions( aPath ), "" );
else
path.Assign( aPath, "" );
path.Normalize();
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 );
return;
}
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( NULL == aPlugin )
return;
int nExt = aPlugin->GetNExtensions();
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] adding " << nExt << " extensions";
wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
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.insert( std::pair< const wxString, KICAD_PLUGIN_LDR_3D* >( ws, aPlugin ) );
}
}
return;
}
std::list< wxString > const* S3D_PLUGIN_MANAGER::GetFileFilters( void ) const
{
return &m_FileFilters;
}
SCENEGRAPH* S3D_PLUGIN_MANAGER::Load3DModel( const wxString& aFileName, std::string& aPluginInfo )
{
wxFileName raw( aFileName );
wxString ext = 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.LowerCase();
#endif
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 );
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( NULL != sp )
{
sL->second->GetPluginInfo( aPluginInfo );
return sp;
}
}
++sL;
}
return NULL;
}
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();
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] closing " << m_Plugins.size() << " plugins";
wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
while( sP != eP )
{
(*sP)->Close();
++sP;
}
return;
}
bool S3D_PLUGIN_MANAGER::CheckTag( const char* aTag )
{
if( NULL == 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;
}
+103
View File
@@ -0,0 +1,103 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
{
private:
/// 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;
/// 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 );
public:
S3D_PLUGIN_MANAGER();
virtual ~S3D_PLUGIN_MANAGER();
/**
* Function GetFileFilters
* returns 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;
SCENEGRAPH* Load3DModel( const wxString& aFileName, std::string& aPluginInfo );
/**
* Function ClosePlugins
* iterates 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 );
/**
* Function CheckTag
* checks 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 );
};
#endif // PLUGIN_MANAGER_3D_H
+1
View File
@@ -0,0 +1 @@
add_subdirectory( sg )
@@ -0,0 +1,66 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 <wx/filename.h>
#include "3d_info.h"
#include "3d_cache.h"
#include "plugins/3dapi/ifsg_api.h"
#include "3d_cache_dialogs.h"
#include "dlg_3d_pathconfig.h"
#include "dlg_select_3dmodel.h"
bool S3D::Select3DModel( wxWindow* aParent, S3D_CACHE* aCache,
wxString& prevModelSelectDir, int& prevModelWildcard, MODULE_3D_SETTINGS* aModel )
{
if( NULL == aModel )
return false;
DLG_SELECT_3DMODEL* dm = new DLG_SELECT_3DMODEL( aParent, aCache, aModel,
prevModelSelectDir, prevModelWildcard );
if( wxID_OK == dm->ShowModal() )
{
delete dm;
return true;
}
delete dm;
return false;
}
bool S3D::Configure3DPaths( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver )
{
DLG_3D_PATH_CONFIG* dp = new DLG_3D_PATH_CONFIG( aParent, aResolver );
if( wxID_OK == dp->ShowModal() )
{
delete dp;
return true;
}
delete dp;
return false;
}
@@ -0,0 +1,40 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 CACHE_DIALOGS_3D_H
#define CACHE_DIALOGS_3D_H
#include <wx/window.h>
class S3D_CACHE;
class S3D_FILENAME_RESOLVER;
namespace S3D
{
bool Select3DModel( wxWindow* aParent, S3D_CACHE* aCache,
wxString& prevModelSelectDir, int& prevModelWildcard, MODULE_3D_SETTINGS* aModel );
bool Configure3DPaths( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver );
}
#endif // CACHE_DIALOGS_3D_H
@@ -0,0 +1,384 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 <wx/msgdlg.h>
#include <pgm_base.h>
#include <html_messagebox.h>
#include "3d_cache/dialogs/dlg_3d_pathconfig.h"
#include "3d_cache/3d_filename_resolver.h"
DLG_3D_PATH_CONFIG::DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver ) :
DLG_3D_PATH_CONFIG_BASE( aParent ), m_resolver( aResolver )
{
initDialog();
GetSizer()->SetSizeHints( this );
Centre();
return;
}
void DLG_3D_PATH_CONFIG::initDialog()
{
m_Aliases->EnableEditing( true );
// Gives a min width to each column, when the user drags a column
m_Aliases->SetColMinimalWidth( 0, 80 );
m_Aliases->SetColMinimalWidth( 1, 300 );
m_Aliases->SetColMinimalWidth( 2, 120 );
m_Aliases->SetColMinimalAcceptableWidth( 80 );
// Set column sizes to this min value
m_Aliases->SetColSize( 0, 80 );
m_Aliases->SetColSize( 1, 300 );
m_Aliases->SetColSize( 2, 120 );
m_EnvVars->SetColMinimalWidth( 0, 80 );
m_EnvVars->SetColMinimalWidth( 1, 300 );
m_EnvVars->SetColMinimalAcceptableWidth( 80 );
m_EnvVars->SetColSize( 0, 80 );
m_EnvVars->SetColSize( 1, 300 );
if( m_resolver )
{
updateEnvVars();
// prohibit these characters in the alias names: []{}()%~<>"='`;:.,&?/\|$
m_aliasValidator.SetStyle( wxFILTER_EXCLUDE_CHAR_LIST );
m_aliasValidator.SetCharExcludes( wxT( "{}[]()%~<>\"='`;:.,&?/\\|$" ) );
const std::list< S3D_ALIAS >* rpaths = m_resolver->GetPaths();
std::list< S3D_ALIAS >::const_iterator rI = rpaths->begin();
std::list< S3D_ALIAS >::const_iterator rE = rpaths->end();
size_t listsize = rpaths->size();
size_t listidx = 0;
while( rI != rE && ( (*rI).m_alias.StartsWith( "${" )
|| (*rI).m_alias.StartsWith( "$(" ) ) )
{
++listidx;
++rI;
}
if( listidx < listsize )
m_curdir = (*rI).m_pathexp;
else
return;
listsize = listsize - listidx - m_Aliases->GetNumberRows();
// note: if the list allocation fails we have bigger problems
// and there is no point in trying to notify the user here
if( listsize > 0 && !m_Aliases->InsertRows( 0, listsize ) )
return;
int nitems = 0;
wxGridCellTextEditor* pEdAlias;
while( rI != rE )
{
m_Aliases->SetCellValue( nitems, 0, rI->m_alias );
if( 0 == nitems )
{
m_Aliases->SetCellEditor( nitems, 0, new wxGridCellTextEditor );
pEdAlias = (wxGridCellTextEditor*) m_Aliases->GetCellEditor( nitems, 0 );
pEdAlias->SetValidator( m_aliasValidator );
pEdAlias->DecRef();
}
else
{
pEdAlias->IncRef();
m_Aliases->SetCellEditor( nitems, 0, pEdAlias );
}
m_Aliases->SetCellValue( nitems, 1, rI->m_pathvar );
m_Aliases->SetCellValue( nitems++, 2, rI->m_description );
// TODO: implement a wxGridCellEditor which invokes a wxDirDialog
++rI;
}
m_Aliases->AutoSize();
}
}
bool DLG_3D_PATH_CONFIG::TransferDataFromWindow()
{
if( NULL == m_resolver )
{
wxMessageBox( _( "[BUG] No valid resolver; data will not be updated" ),
_( "Update 3D search path list" ) );
return false;
}
std::vector<S3D_ALIAS> alist;
S3D_ALIAS alias;
int ni = m_Aliases->GetNumberRows();
if( ni <= 0 )
{
// note: UI usability: we should ask a user if they're sure they
// want to clear the entire path list
m_resolver->UpdatePathList( alist );
return true;
}
for( int i = 0; i < ni; ++i )
{
alias.m_alias = m_Aliases->GetCellValue( i, 0 );
alias.m_pathvar = m_Aliases->GetCellValue( i, 1 );
alias.m_description = m_Aliases->GetCellValue( i, 2 );
if( !alias.m_alias.empty() && !alias.m_pathvar.empty() )
alist.push_back( alias );
}
return m_resolver->UpdatePathList( alist );
}
void DLG_3D_PATH_CONFIG::OnAddAlias( wxCommandEvent& event )
{
int ni = m_Aliases->GetNumberRows();
if( m_Aliases->InsertRows( ni, 1 ) )
{
wxGridCellTextEditor* pEdAlias;
pEdAlias = (wxGridCellTextEditor*) m_Aliases->GetCellEditor( 0, 0 );
m_Aliases->SetCellEditor( ni, 0, pEdAlias );
m_Aliases->SelectRow( ni, false );
m_Aliases->AutoSize();
Fit();
// TODO: set the editors on any newly created rows
}
event.Skip();
}
void DLG_3D_PATH_CONFIG::OnDelAlias( wxCommandEvent& event )
{
wxArrayInt sel = m_Aliases->GetSelectedRows();
if( sel.empty() )
{
wxMessageBox( _( "No entry selected" ), _( "Delete alias entry" ) );
return;
}
if( sel.size() > 1 )
{
wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ),
_( "Delete alias entry" ) );
return;
}
if( m_Aliases->GetNumberRows() > 1 )
{
int ni = sel.front();
m_Aliases->DeleteRows( ni, 1 );
if( ni >= m_Aliases->GetNumberRows() )
ni = m_Aliases->GetNumberRows() - 1;
m_Aliases->SelectRow( ni, false );
m_Aliases->AutoSize();
Fit();
}
else
{
m_Aliases->SetCellValue( 0, 0, wxEmptyString );
m_Aliases->SetCellValue( 0, 1, wxEmptyString );
m_Aliases->SetCellValue( 0, 2, wxEmptyString );
}
event.Skip();
}
void DLG_3D_PATH_CONFIG::OnAliasMoveUp( wxCommandEvent& event )
{
wxArrayInt sel = m_Aliases->GetSelectedRows();
if( sel.empty() )
{
wxMessageBox( _( "No entry selected" ), _( "Move alias up" ) );
return;
}
if( sel.size() > 1 )
{
wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ),
_( "Move alias up" ) );
return;
}
int ci = sel.front();
if( ci > 0 )
{
S3D_ALIAS al0;
al0.m_alias = m_Aliases->GetCellValue( ci, 0 );
al0.m_pathvar = m_Aliases->GetCellValue( ci, 1 );
al0.m_description = m_Aliases->GetCellValue( ci, 2 );
int ni = ci - 1;
m_Aliases->SetCellValue( ci, 0, m_Aliases->GetCellValue( ni, 0 ) );
m_Aliases->SetCellValue( ci, 1, m_Aliases->GetCellValue( ni, 1 ) );
m_Aliases->SetCellValue( ci, 2, m_Aliases->GetCellValue( ni, 2 ) );
m_Aliases->SetCellValue( ni, 0, al0.m_alias );
m_Aliases->SetCellValue( ni, 1, al0.m_pathvar );
m_Aliases->SetCellValue( ni, 2, al0.m_description );
m_Aliases->SelectRow( ni, false );
}
event.Skip();
}
void DLG_3D_PATH_CONFIG::OnAliasMoveDown( wxCommandEvent& event )
{
wxArrayInt sel = m_Aliases->GetSelectedRows();
if( sel.empty() )
{
wxMessageBox( _( "No entry selected" ), _( "Move alias down" ) );
return;
}
if( sel.size() > 1 )
{
wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ),
_( "Move alias down" ) );
return;
}
int ni = m_Aliases->GetNumberRows() - 1;
int ci = sel.front();
if( ci < ni )
{
S3D_ALIAS al0;
al0.m_alias = m_Aliases->GetCellValue( ci, 0 );
al0.m_pathvar = m_Aliases->GetCellValue( ci, 1 );
al0.m_description = m_Aliases->GetCellValue( ci, 2 );
ni = ci + 1;
m_Aliases->SetCellValue( ci, 0, m_Aliases->GetCellValue( ni, 0 ) );
m_Aliases->SetCellValue( ci, 1, m_Aliases->GetCellValue( ni, 1 ) );
m_Aliases->SetCellValue( ci, 2, m_Aliases->GetCellValue( ni, 2 ) );
m_Aliases->SetCellValue( ni, 0, al0.m_alias );
m_Aliases->SetCellValue( ni, 1, al0.m_pathvar );
m_Aliases->SetCellValue( ni, 2, al0.m_description );
m_Aliases->SelectRow( ni, false );
}
event.Skip();
}
void DLG_3D_PATH_CONFIG::OnConfigEnvVar( wxCommandEvent& event )
{
Pgm().ConfigurePaths( this );
updateEnvVars();
event.Skip();
}
void DLG_3D_PATH_CONFIG::updateEnvVars( void )
{
if( !m_resolver )
return;
std::list< wxString > epaths;
m_resolver->GetKicadPaths( epaths );
size_t nitems = epaths.size();
size_t nrows = m_EnvVars->GetNumberRows();
bool resize = nrows != nitems; // true after adding/removing env vars
if( nrows > nitems )
{
size_t ni = nrows - nitems;
m_EnvVars->DeleteRows( 0, ni );
}
else if( nrows < nitems )
{
size_t ni = nitems - nrows;
m_EnvVars->InsertRows( 0, ni );
}
int j = 0;
for( const auto& i : epaths )
{
wxString val = ExpandEnvVarSubstitutions( i );
m_EnvVars->SetCellValue( j, 0, i );
m_EnvVars->SetCellValue( j, 1, val );
m_EnvVars->SetReadOnly( j, 0, true );
m_EnvVars->SetReadOnly( j, 1, true );
wxGridCellAttr* ap = m_EnvVars->GetOrCreateCellAttr( j, 0 );
ap->SetReadOnly( true );
ap->SetBackgroundColour( *wxLIGHT_GREY );
m_EnvVars->SetRowAttr( j, ap );
++j;
}
m_EnvVars->AutoSize();
// Resizing the full dialog is sometimes needed for a clean display
// i.e. when adding/removing Kicad environment variables
if( resize )
GetSizer()->SetSizeHints( this );
return;
}
void DLG_3D_PATH_CONFIG::OnHelp( wxCommandEvent& event )
{
wxString msg = _( "Enter the name and path for each 3D alias variable.<br>KiCad "
"environment variables and their values are shown for "
"reference only and cannot be edited." );
msg << "<br><br><b>";
msg << _( "Alias names may not contain any of the characters " );
msg << "{}[]()%~<>\"='`;:.,&?/\\|$";
msg << "</b>";
HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) );
dlg.AddHTML_Text( msg );
dlg.ShowModal();
event.Skip();
}
@@ -0,0 +1,57 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 DLG_3D_PATHCONFIG_H
#define DLG_3D_PATHCONFIG_H
#include <wx/valtext.h>
#include "dlg_3d_pathconfig_base.h"
class S3D_FILENAME_RESOLVER;
class DLG_3D_PATH_CONFIG : public DLG_3D_PATH_CONFIG_BASE
{
private:
S3D_FILENAME_RESOLVER* m_resolver;
wxString m_curdir;
wxTextValidator m_aliasValidator;
void initDialog();
void OnAddAlias( wxCommandEvent& event ) override;
void OnDelAlias( wxCommandEvent& event ) override;
void OnAliasMoveUp( wxCommandEvent& event ) override;
void OnAliasMoveDown( wxCommandEvent& event ) override;
void OnConfigEnvVar( wxCommandEvent& event ) override;
void OnHelp( wxCommandEvent& event ) override;
public:
DLG_3D_PATH_CONFIG( wxWindow* aParent, S3D_FILENAME_RESOLVER* aResolver );
bool TransferDataFromWindow() override;
private:
void updateEnvVars( void );
};
#endif // DLG_3D_PATHCONFIG_H
@@ -0,0 +1,162 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dlg_3d_pathconfig_base.h"
///////////////////////////////////////////////////////////////////////////
DLG_3D_PATH_CONFIG_BASE::DLG_3D_PATH_CONFIG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer5;
bSizer5 = new wxBoxSizer( wxVERTICAL );
m_EnvVars = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_EnvVars->CreateGrid( 1, 2 );
m_EnvVars->EnableEditing( true );
m_EnvVars->EnableGridLines( true );
m_EnvVars->EnableDragGridSize( false );
m_EnvVars->SetMargins( 0, 0 );
// Columns
m_EnvVars->SetColSize( 0, 150 );
m_EnvVars->SetColSize( 1, 300 );
m_EnvVars->EnableDragColMove( false );
m_EnvVars->EnableDragColSize( true );
m_EnvVars->SetColLabelSize( 30 );
m_EnvVars->SetColLabelValue( 0, _("Name") );
m_EnvVars->SetColLabelValue( 1, _("Path") );
m_EnvVars->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_EnvVars->EnableDragRowSize( true );
m_EnvVars->SetRowLabelSize( 80 );
m_EnvVars->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_EnvVars->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_EnvVars->SetMinSize( wxSize( 250,100 ) );
bSizer5->Add( m_EnvVars, 1, wxALL|wxEXPAND, 5 );
m_btnEnvCfg = new wxButton( this, wxID_ANY, _("Configure Environment Variables"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer5->Add( m_btnEnvCfg, 0, wxALIGN_CENTER|wxALL, 5 );
bSizerMain->Add( bSizer5, 0, wxEXPAND, 5 );
m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 );
wxBoxSizer* bSizerGrid;
bSizerGrid = new wxBoxSizer( wxHORIZONTAL );
m_Aliases = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_Aliases->CreateGrid( 1, 3 );
m_Aliases->EnableEditing( true );
m_Aliases->EnableGridLines( true );
m_Aliases->EnableDragGridSize( false );
m_Aliases->SetMargins( 0, 0 );
// Columns
m_Aliases->SetColSize( 0, 80 );
m_Aliases->SetColSize( 1, 300 );
m_Aliases->SetColSize( 2, 120 );
m_Aliases->EnableDragColMove( false );
m_Aliases->EnableDragColSize( true );
m_Aliases->SetColLabelSize( 30 );
m_Aliases->SetColLabelValue( 0, _("Alias") );
m_Aliases->SetColLabelValue( 1, _("Path") );
m_Aliases->SetColLabelValue( 2, _("Description") );
m_Aliases->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_Aliases->AutoSizeRows();
m_Aliases->EnableDragRowSize( false );
m_Aliases->SetRowLabelSize( 80 );
m_Aliases->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_Aliases->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_Aliases->SetMinSize( wxSize( -1,150 ) );
bSizerGrid->Add( m_Aliases, 1, wxALL|wxEXPAND, 5 );
bSizerMain->Add( bSizerGrid, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerButtons;
bSizerButtons = new wxBoxSizer( wxHORIZONTAL );
m_btnAddAlias = new wxButton( this, wxID_ANY, _("Add Alias"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_btnAddAlias, 0, wxALL, 5 );
m_btnDelAlias = new wxButton( this, wxID_ANY, _("Remove Alias"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_btnDelAlias, 0, wxALL, 5 );
m_btnMoveUp = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_btnMoveUp, 0, wxALL, 5 );
m_btnMoveDown = new wxButton( this, wxID_ANY, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerButtons->Add( m_btnMoveDown, 0, wxALL, 5 );
bSizerMain->Add( bSizerButtons, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_sdbSizer2 = new wxStdDialogButtonSizer();
m_sdbSizer2OK = new wxButton( this, wxID_OK );
m_sdbSizer2->AddButton( m_sdbSizer2OK );
m_sdbSizer2Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer2->AddButton( m_sdbSizer2Cancel );
m_sdbSizer2Help = new wxButton( this, wxID_HELP );
m_sdbSizer2->AddButton( m_sdbSizer2Help );
m_sdbSizer2->Realize();
bSizerMain->Add( m_sdbSizer2, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerMain->Fit( this );
this->Centre( wxBOTH );
// Connect Events
m_btnEnvCfg->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnConfigEnvVar ), NULL, this );
m_btnAddAlias->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAddAlias ), NULL, this );
m_btnDelAlias->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnDelAlias ), NULL, this );
m_btnMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveUp ), NULL, this );
m_btnMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveDown ), NULL, this );
m_sdbSizer2Help->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnHelp ), NULL, this );
}
DLG_3D_PATH_CONFIG_BASE::~DLG_3D_PATH_CONFIG_BASE()
{
// Disconnect Events
m_btnEnvCfg->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnConfigEnvVar ), NULL, this );
m_btnAddAlias->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAddAlias ), NULL, this );
m_btnDelAlias->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnDelAlias ), NULL, this );
m_btnMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveUp ), NULL, this );
m_btnMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnAliasMoveDown ), NULL, this );
m_sdbSizer2Help->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DLG_3D_PATH_CONFIG_BASE::OnHelp ), NULL, this );
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,67 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DLG_3D_PATHCONFIG_BASE_H__
#define __DLG_3D_PATHCONFIG_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/font.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DLG_3D_PATH_CONFIG_BASE
///////////////////////////////////////////////////////////////////////////////
class DLG_3D_PATH_CONFIG_BASE : public DIALOG_SHIM
{
private:
protected:
wxGrid* m_EnvVars;
wxButton* m_btnEnvCfg;
wxStaticLine* m_staticline2;
wxGrid* m_Aliases;
wxButton* m_btnAddAlias;
wxButton* m_btnDelAlias;
wxButton* m_btnMoveUp;
wxButton* m_btnMoveDown;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer2;
wxButton* m_sdbSizer2OK;
wxButton* m_sdbSizer2Cancel;
wxButton* m_sdbSizer2Help;
// Virtual event handlers, overide them in your derived class
virtual void OnConfigEnvVar( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAddAlias( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDelAlias( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAliasMoveUp( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAliasMoveDown( wxCommandEvent& event ) { event.Skip(); }
virtual void OnHelp( wxCommandEvent& event ) { event.Skip(); }
public:
DLG_3D_PATH_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("3D Search Path Configuration"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DLG_3D_PATH_CONFIG_BASE();
};
#endif //__DLG_3D_PATHCONFIG_BASE_H__
@@ -0,0 +1,287 @@
/*
* 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 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2017 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 <set>
#include "dlg_select_3dmodel.h"
#include "project.h"
#include "3d_cache/3d_info.h"
#include "3d_cache/3d_cache.h"
#include "3d_cache_dialogs.h"
#include <3d_model_viewer/c3d_model_viewer.h>
#include <common_ogl/cogl_att_list.h>
#include <pcbnew/class_module.h>
#define ID_FILE_TREE ( wxID_LAST + 1 )
#define ID_SET_DIR ( ID_FILE_TREE + 1 )
#define ID_CFG_PATHS ( ID_SET_DIR + 1 )
wxBEGIN_EVENT_TABLE( DLG_SELECT_3DMODEL, wxDialog )
EVT_DIRCTRL_SELECTIONCHANGED( ID_FILE_TREE, DLG_SELECT_3DMODEL::OnSelectionChanged )
EVT_DIRCTRL_FILEACTIVATED( ID_FILE_TREE, DLG_SELECT_3DMODEL::OnFileActivated )
EVT_CHOICE( ID_SET_DIR, DLG_SELECT_3DMODEL::SetRootDir )
EVT_BUTTON( ID_CFG_PATHS, DLG_SELECT_3DMODEL::Cfg3DPaths )
wxEND_EVENT_TABLE()
DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager,
MODULE_3D_SETTINGS* aModelItem, wxString& prevModelSelectDir, int& prevModelWildcard ) :
wxDialog( aParent, wxID_ANY, _( "Select 3D Model" ), wxDefaultPosition,
wxSize( 500,200 ), wxCAPTION | wxRESIZE_BORDER | wxCLOSE_BOX
| wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU ),
m_model( aModelItem ), m_cache( aCacheManager ), m_previousDir( prevModelSelectDir ),
m_previousFilterIndex( prevModelWildcard )
{
SetSizeHints( wxSize( 500,200 ), wxDefaultSize );
if( NULL != m_cache )
m_resolver = m_cache->GetResolver();
else
m_resolver = NULL;
wxBoxSizer* bSizer0 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer1 = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer2 = new wxBoxSizer( wxVERTICAL );
// set to NULL to avoid segfaults when m_FileTree is instantiated
// and wxGenericDirCtrl events are posted
m_modelViewer = NULL;
dirChoices = NULL;
m_FileTree = new wxGenericDirCtrl( this, ID_FILE_TREE, prevModelSelectDir, wxDefaultPosition,
wxSize( 300,100 ), wxDIRCTRL_3D_INTERNAL | wxDIRCTRL_EDIT_LABELS
| wxDIRCTRL_SELECT_FIRST | wxDIRCTRL_SHOW_FILTERS|wxSUNKEN_BORDER, wxEmptyString, 0 );
m_FileTree->ShowHidden( false );
m_FileTree->SetMinSize( wxSize( 300,100 ) );
m_FileTree->SetLabel( wxT( "3D_MODEL_SELECTOR" ) );
bSizer2->Add( m_FileTree, 1, wxEXPAND | wxALL, 5 );
bSizer1->Add( bSizer2, 1, wxEXPAND, 5 );
m_modelViewer = new C3D_MODEL_VIEWER( this,
COGL_ATT_LIST::GetAttributesList( true ),
m_cache );
m_modelViewer->SetMinSize( wxSize( 512, 384 ) );
bSizer1->Add( m_modelViewer, 0, wxCENTER, 5 );
// create the filter list
if( NULL != m_cache )
{
std::list< wxString > const* fl = m_cache->GetFileFilters();
std::list< wxString >::const_iterator sL = fl->begin();
std::list< wxString >::const_iterator eL = fl->end();
wxString filter;
while( sL != eL )
{
filter.Append( *sL );
++sL;
if( sL != eL )
filter.Append( wxT( "|" ) );
}
if( !filter.empty() )
m_FileTree->SetFilter( filter );
else
m_FileTree->SetFilter( wxT( "*.*" ) );
if( prevModelWildcard >= 0 && prevModelWildcard < (int)fl->size() )
m_FileTree->SetFilterIndex( prevModelWildcard );
else
{
prevModelWildcard = 0;
m_FileTree->SetFilterIndex( 0 );
}
}
else
{
m_FileTree->SetFilter( wxT( "*.*" ) );
prevModelWildcard = 0;
m_FileTree->SetFilterIndex( 0 );
}
// Add the path choice box and config button
wxBoxSizer* hboxDirChoice = new wxBoxSizer( wxHORIZONTAL );
dirChoices = new wxChoice( this, ID_SET_DIR, wxDefaultPosition, wxSize( 320, 20 ) );
dirChoices->SetMinSize( wxSize( 320, 12 ) );
wxStaticText* stDirChoice = new wxStaticText( this, -1, _( "Paths:" ) );
wxButton* cfgPaths = new wxButton( this, ID_CFG_PATHS, _( "Configure Path" ) );
hboxDirChoice->Add( stDirChoice, 0, wxALL | wxCENTER, 5 );
hboxDirChoice->Add( dirChoices, 1, wxEXPAND | wxALL, 5 );
hboxDirChoice->Add( cfgPaths, 0, wxALL, 5 );
wxButton* btn_OK = new wxButton( this, wxID_OK, _( "OK" ) );
wxButton* btn_Cancel = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
wxStdDialogButtonSizer* hSizer1 = new wxStdDialogButtonSizer();
hSizer1->AddButton( btn_OK );
hSizer1->AddButton( btn_Cancel );
hSizer1->Realize();
bSizer0->Add( bSizer1, 1, wxALL | wxEXPAND, 5 );
bSizer0->Add( hboxDirChoice, 0, wxALL | wxEXPAND, 5 );
bSizer0->Add( hSizer1, 0, wxALL | wxEXPAND, 5 );
updateDirChoiceList();
SetSizerAndFit( bSizer0 );
Layout();
Centre( wxBOTH );
m_modelViewer->Refresh();
m_modelViewer->SetFocus();
}
bool DLG_SELECT_3DMODEL::TransferDataFromWindow()
{
if( NULL == m_model || NULL == m_FileTree )
return true;
m_model->m_Scale.x = 1.0;
m_model->m_Scale.y = 1.0;
m_model->m_Scale.z = 1.0;
m_model->m_Rotation.x = 0.0;
m_model->m_Rotation.y = 0.0;
m_model->m_Rotation.z = 0.0;
m_model->m_Offset = m_model->m_Rotation;
m_model->m_Filename.clear();
wxString name = m_FileTree->GetFilePath();
if( name.empty() )
return true;
m_previousDir = m_FileTree->GetPath();
m_previousFilterIndex = m_FileTree->GetFilterIndex();
// file selection mode: retrieve the filename and specify a
// path relative to one of the config paths
wxFileName fname = m_FileTree->GetFilePath();
fname.Normalize();
m_model->m_Filename = m_resolver->ShortenPath( fname.GetFullPath() );
return true;
}
void DLG_SELECT_3DMODEL::OnSelectionChanged( wxTreeEvent& event )
{
if( m_modelViewer )
m_modelViewer->Set3DModel( m_FileTree->GetFilePath() );
event.Skip();
return;
}
void DLG_SELECT_3DMODEL::OnFileActivated( wxTreeEvent& event )
{
if( m_modelViewer )
m_modelViewer->Set3DModel( m_FileTree->GetFilePath() );
event.Skip();
SetEscapeId( wxID_OK );
Close();
return;
}
void DLG_SELECT_3DMODEL::SetRootDir( wxCommandEvent& event )
{
if( m_FileTree )
m_FileTree->SetPath( dirChoices->GetString( dirChoices->GetSelection() ) );
return;
}
void DLG_SELECT_3DMODEL::Cfg3DPaths( wxCommandEvent& event )
{
if( S3D::Configure3DPaths( this, m_resolver ) )
updateDirChoiceList();
}
void DLG_SELECT_3DMODEL::updateDirChoiceList( void )
{
if( NULL == m_FileTree || NULL == m_resolver || NULL == dirChoices )
return;
std::list< S3D_ALIAS > const* md = m_resolver->GetPaths();
std::list< S3D_ALIAS >::const_iterator sL = md->begin();
std::list< S3D_ALIAS >::const_iterator eL = md->end();
std::set< wxString > cl;
wxString prjDir;
// extract the current project dir
if( sL != eL )
{
prjDir = sL->m_pathexp;
++sL;
}
while( sL != eL )
{
if( !sL->m_pathexp.empty() && sL->m_pathexp.compare( prjDir ) )
cl.insert( sL->m_pathexp );
++sL;
}
if( !cl.empty() )
{
dirChoices->Clear();
if( !prjDir.empty() )
dirChoices->Append( prjDir );
std::set< wxString >::const_iterator sI = cl.begin();
std::set< wxString >::const_iterator eI = cl.end();
while( sI != eI )
{
dirChoices->Append( *sI );
++sI;
}
dirChoices->Select( 0 );
}
return;
}
@@ -0,0 +1,75 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 dlg_select_3dmodel.h
* creates a dialog to select 3D model files
*/
#ifndef DLG_SELECT_3DMODEL_H
#define DLG_SELECT_3DMODEL_H
#include <wx/event.h>
#include <wx/stattext.h>
#include <wx/button.h>
#include <wx/dialog.h>
#include <wx/dirctrl.h>
#include <wx/sizer.h>
#include <wx/frame.h>
class MODULE_3D_SETTINGS;
class S3D_CACHE;
class S3D_FILENAME_RESOLVER;
class C3D_MODEL_VIEWER;
class DLG_SELECT_3DMODEL : public wxDialog
{
private:
MODULE_3D_SETTINGS* m_model; // data for the selected model
S3D_CACHE* m_cache; // cache manager
S3D_FILENAME_RESOLVER* m_resolver; // 3D filename resolver
wxString& m_previousDir;
int& m_previousFilterIndex;
wxGenericDirCtrl* m_FileTree;
C3D_MODEL_VIEWER* m_modelViewer;
wxChoice* dirChoices;
void updateDirChoiceList( void );
public:
DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager, MODULE_3D_SETTINGS* aModelItem,
wxString& prevModelSelectDir, int& prevModelWildcard );
bool TransferDataFromWindow() override;
void OnSelectionChanged( wxTreeEvent& event );
void OnFileActivated( wxTreeEvent& event );
void SetRootDir( wxCommandEvent& event );
void Cfg3DPaths( wxCommandEvent& event );
wxDECLARE_EVENT_TABLE();
};
#endif // DLG_SELECT_3DMODEL_H
@@ -0,0 +1,353 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jan 12 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "panel_prev_3d_base.h"
///////////////////////////////////////////////////////////////////////////
PANEL_PREV_3D_BASE::PANEL_PREV_3D_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
{
wxBoxSizer* bSizermain;
bSizermain = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerLeft;
bSizerLeft = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerScale;
bSizerScale = new wxBoxSizer( wxVERTICAL );
m_staticTextScale = new wxStaticText( this, wxID_ANY, _("Scale"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextScale->Wrap( -1 );
bSizerScale->Add( m_staticTextScale, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxFlexGridSizer* fgSizerScale;
fgSizerScale = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizerScale->SetFlexibleDirection( wxBOTH );
fgSizerScale->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticText1 = new wxStaticText( this, wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
fgSizerScale->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
xscale = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerScale->Add( xscale, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_spinXscale = new wxSpinButton( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL );
fgSizerScale->Add( m_spinXscale, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_staticText2 = new wxStaticText( this, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 );
fgSizerScale->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
yscale = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerScale->Add( yscale, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_spinYscale = new wxSpinButton( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL );
fgSizerScale->Add( m_spinYscale, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_staticText3 = new wxStaticText( this, wxID_ANY, _("Z:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3->Wrap( -1 );
fgSizerScale->Add( m_staticText3, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
zscale = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerScale->Add( zscale, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
m_spinZscale = new wxSpinButton( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL );
fgSizerScale->Add( m_spinZscale, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
bSizerScale->Add( fgSizerScale, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 );
bSizerLeft->Add( bSizerScale, 0, wxEXPAND, 5 );
wxBoxSizer* bSizerRotation;
bSizerRotation = new wxBoxSizer( wxVERTICAL );
m_staticTextRot = new wxStaticText( this, wxID_ANY, _("Rotation (degrees)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRot->Wrap( -1 );
bSizerRotation->Add( m_staticTextRot, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxFlexGridSizer* fgSizerRotate;
fgSizerRotate = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizerRotate->SetFlexibleDirection( wxBOTH );
fgSizerRotate->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticText11 = new wxStaticText( this, wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText11->Wrap( -1 );
fgSizerRotate->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
xrot = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
if ( !xrot->HasFlag( wxTE_MULTILINE ) )
{
xrot->SetMaxLength( 9 );
}
#else
xrot->SetMaxLength( 9 );
#endif
fgSizerRotate->Add( xrot, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_spinXrot = new wxSpinButton( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL );
fgSizerRotate->Add( m_spinXrot, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_staticText21 = new wxStaticText( this, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText21->Wrap( -1 );
fgSizerRotate->Add( m_staticText21, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
yrot = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
if ( !yrot->HasFlag( wxTE_MULTILINE ) )
{
yrot->SetMaxLength( 9 );
}
#else
yrot->SetMaxLength( 9 );
#endif
fgSizerRotate->Add( yrot, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxTOP, 5 );
m_spinYrot = new wxSpinButton( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL );
fgSizerRotate->Add( m_spinYrot, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_staticText31 = new wxStaticText( this, wxID_ANY, _("Z:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText31->Wrap( -1 );
fgSizerRotate->Add( m_staticText31, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
zrot = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
#ifdef __WXGTK__
if ( !zrot->HasFlag( wxTE_MULTILINE ) )
{
zrot->SetMaxLength( 9 );
}
#else
zrot->SetMaxLength( 9 );
#endif
fgSizerRotate->Add( zrot, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
m_spinZrot = new wxSpinButton( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL );
fgSizerRotate->Add( m_spinZrot, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
bSizerRotation->Add( fgSizerRotate, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 );
bSizerLeft->Add( bSizerRotation, 0, wxEXPAND, 5 );
wxBoxSizer* bSizerOffset;
bSizerOffset = new wxBoxSizer( wxVERTICAL );
m_staticTextOffset = new wxStaticText( this, wxID_ANY, _("Offset"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextOffset->Wrap( -1 );
bSizerOffset->Add( m_staticTextOffset, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxFlexGridSizer* fgSizerOffset;
fgSizerOffset = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizerOffset->SetFlexibleDirection( wxBOTH );
fgSizerOffset->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticText12 = new wxStaticText( this, wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText12->Wrap( -1 );
fgSizerOffset->Add( m_staticText12, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
xoff = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerOffset->Add( xoff, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_spinXoffset = new wxSpinButton( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL );
fgSizerOffset->Add( m_spinXoffset, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_staticText22 = new wxStaticText( this, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText22->Wrap( -1 );
fgSizerOffset->Add( m_staticText22, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
yoff = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerOffset->Add( yoff, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 5 );
m_spinYoffset = new wxSpinButton( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL );
fgSizerOffset->Add( m_spinYoffset, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_staticText32 = new wxStaticText( this, wxID_ANY, _("Z:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText32->Wrap( -1 );
fgSizerOffset->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
zoff = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerOffset->Add( zoff, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
m_spinZoffset = new wxSpinButton( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_VERTICAL );
fgSizerOffset->Add( m_spinZoffset, 0, wxALIGN_CENTER_VERTICAL, 5 );
bSizerOffset->Add( fgSizerOffset, 0, wxEXPAND|wxLEFT|wxRIGHT, 10 );
bSizerLeft->Add( bSizerOffset, 1, wxEXPAND, 5 );
bSizermain->Add( bSizerLeft, 0, wxEXPAND, 5 );
wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL );
m_SizerPanelView = new wxBoxSizer( wxVERTICAL );
bSizerRight->Add( m_SizerPanelView, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer3DButtons;
bSizer3DButtons = new wxBoxSizer( wxHORIZONTAL );
bSizer3DButtons->Add( 0, 0, 1, wxEXPAND, 5 );
m_fgSizerButtons = new wxFlexGridSizer( 0, 4, 0, 0 );
m_fgSizerButtons->AddGrowableCol( 0 );
m_fgSizerButtons->AddGrowableCol( 1 );
m_fgSizerButtons->AddGrowableCol( 2 );
m_fgSizerButtons->AddGrowableCol( 3 );
m_fgSizerButtons->SetFlexibleDirection( wxBOTH );
m_fgSizerButtons->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_bpvISO = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_bpvISO->SetToolTip( _("Change to isometric perspective") );
m_fgSizerButtons->Add( m_bpvISO, 0, wxALL|wxEXPAND, 5 );
m_bpvLeft = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_fgSizerButtons->Add( m_bpvLeft, 0, wxALL|wxEXPAND, 5 );
m_bpvFront = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_fgSizerButtons->Add( m_bpvFront, 0, wxALL|wxEXPAND, 5 );
m_bpvTop = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_fgSizerButtons->Add( m_bpvTop, 0, wxALL|wxEXPAND, 5 );
m_bpUpdate = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_bpUpdate->SetToolTip( _("Reload board and 3D models") );
m_fgSizerButtons->Add( m_bpUpdate, 0, wxALL|wxEXPAND, 5 );
m_bpvRight = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_fgSizerButtons->Add( m_bpvRight, 0, wxALL|wxEXPAND, 5 );
m_bpvBack = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_fgSizerButtons->Add( m_bpvBack, 0, wxALL|wxEXPAND, 5 );
m_bpvBottom = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
m_fgSizerButtons->Add( m_bpvBottom, 0, wxALL|wxEXPAND, 5 );
bSizer3DButtons->Add( m_fgSizerButtons, 6, wxEXPAND, 5 );
bSizer3DButtons->Add( 0, 0, 1, wxEXPAND, 5 );
bSizerRight->Add( bSizer3DButtons, 0, wxALL|wxEXPAND, 5 );
bSizermain->Add( bSizerRight, 1, wxEXPAND, 5 );
this->SetSizer( bSizermain );
this->Layout();
bSizermain->Fit( this );
// Connect Events
xscale->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelScale ), NULL, this );
xscale->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinXscale->Connect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementScale ), NULL, this );
m_spinXscale->Connect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementScale ), NULL, this );
yscale->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelScale ), NULL, this );
yscale->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinYscale->Connect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementScale ), NULL, this );
m_spinYscale->Connect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementScale ), NULL, this );
zscale->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelScale ), NULL, this );
zscale->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinZscale->Connect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementScale ), NULL, this );
m_spinZscale->Connect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementScale ), NULL, this );
xrot->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelRot ), NULL, this );
xrot->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinXrot->Connect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementRot ), NULL, this );
m_spinXrot->Connect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementRot ), NULL, this );
yrot->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelRot ), NULL, this );
yrot->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinYrot->Connect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementRot ), NULL, this );
m_spinYrot->Connect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementRot ), NULL, this );
zrot->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelRot ), NULL, this );
zrot->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinZrot->Connect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementRot ), NULL, this );
m_spinZrot->Connect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementRot ), NULL, this );
xoff->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelOffset ), NULL, this );
xoff->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinXoffset->Connect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementOffset ), NULL, this );
m_spinXoffset->Connect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementOffset ), NULL, this );
yoff->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelOffset ), NULL, this );
yoff->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinYoffset->Connect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementOffset ), NULL, this );
m_spinYoffset->Connect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementOffset ), NULL, this );
zoff->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelOffset ), NULL, this );
zoff->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinZoffset->Connect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementOffset ), NULL, this );
m_spinZoffset->Connect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementOffset ), NULL, this );
m_bpvISO->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DISO ), NULL, this );
m_bpvLeft->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DLeft ), NULL, this );
m_bpvFront->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DFront ), NULL, this );
m_bpvTop->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DTop ), NULL, this );
m_bpUpdate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DUpdate ), NULL, this );
m_bpvRight->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DRight ), NULL, this );
m_bpvBack->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DBack ), NULL, this );
m_bpvBottom->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DBottom ), NULL, this );
}
PANEL_PREV_3D_BASE::~PANEL_PREV_3D_BASE()
{
// Disconnect Events
xscale->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelScale ), NULL, this );
xscale->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinXscale->Disconnect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementScale ), NULL, this );
m_spinXscale->Disconnect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementScale ), NULL, this );
yscale->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelScale ), NULL, this );
yscale->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinYscale->Disconnect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementScale ), NULL, this );
m_spinYscale->Disconnect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementScale ), NULL, this );
zscale->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelScale ), NULL, this );
zscale->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinZscale->Disconnect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementScale ), NULL, this );
m_spinZscale->Disconnect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementScale ), NULL, this );
xrot->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelRot ), NULL, this );
xrot->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinXrot->Disconnect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementRot ), NULL, this );
m_spinXrot->Disconnect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementRot ), NULL, this );
yrot->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelRot ), NULL, this );
yrot->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinYrot->Disconnect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementRot ), NULL, this );
m_spinYrot->Disconnect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementRot ), NULL, this );
zrot->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelRot ), NULL, this );
zrot->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinZrot->Disconnect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementRot ), NULL, this );
m_spinZrot->Disconnect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementRot ), NULL, this );
xoff->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelOffset ), NULL, this );
xoff->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinXoffset->Disconnect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementOffset ), NULL, this );
m_spinXoffset->Disconnect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementOffset ), NULL, this );
yoff->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelOffset ), NULL, this );
yoff->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinYoffset->Disconnect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementOffset ), NULL, this );
m_spinYoffset->Disconnect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementOffset ), NULL, this );
zoff->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( PANEL_PREV_3D_BASE::onMouseWheelOffset ), NULL, this );
zoff->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_PREV_3D_BASE::updateOrientation ), NULL, this );
m_spinZoffset->Disconnect( wxEVT_SCROLL_LINEDOWN, wxSpinEventHandler( PANEL_PREV_3D_BASE::onDecrementOffset ), NULL, this );
m_spinZoffset->Disconnect( wxEVT_SCROLL_LINEUP, wxSpinEventHandler( PANEL_PREV_3D_BASE::onIncrementOffset ), NULL, this );
m_bpvISO->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DISO ), NULL, this );
m_bpvLeft->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DLeft ), NULL, this );
m_bpvFront->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DFront ), NULL, this );
m_bpvTop->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DTop ), NULL, this );
m_bpUpdate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DUpdate ), NULL, this );
m_bpvRight->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DRight ), NULL, this );
m_bpvBack->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DBack ), NULL, this );
m_bpvBottom->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_PREV_3D_BASE::View3DBottom ), NULL, this );
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,110 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jan 12 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __PANEL_PREV_3D_BASE_H__
#define __PANEL_PREV_3D_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/spinbutt.h>
#include <wx/sizer.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/bmpbuttn.h>
#include <wx/button.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class PANEL_PREV_3D_BASE
///////////////////////////////////////////////////////////////////////////////
class PANEL_PREV_3D_BASE : public wxPanel
{
private:
protected:
wxStaticText* m_staticTextScale;
wxStaticText* m_staticText1;
wxTextCtrl* xscale;
wxSpinButton* m_spinXscale;
wxStaticText* m_staticText2;
wxTextCtrl* yscale;
wxSpinButton* m_spinYscale;
wxStaticText* m_staticText3;
wxTextCtrl* zscale;
wxSpinButton* m_spinZscale;
wxStaticText* m_staticTextRot;
wxStaticText* m_staticText11;
wxTextCtrl* xrot;
wxSpinButton* m_spinXrot;
wxStaticText* m_staticText21;
wxTextCtrl* yrot;
wxSpinButton* m_spinYrot;
wxStaticText* m_staticText31;
wxTextCtrl* zrot;
wxSpinButton* m_spinZrot;
wxStaticText* m_staticTextOffset;
wxStaticText* m_staticText12;
wxTextCtrl* xoff;
wxSpinButton* m_spinXoffset;
wxStaticText* m_staticText22;
wxSpinButton* m_spinYoffset;
wxStaticText* m_staticText32;
wxTextCtrl* zoff;
wxSpinButton* m_spinZoffset;
wxBoxSizer* m_SizerPanelView;
wxFlexGridSizer* m_fgSizerButtons;
wxBitmapButton* m_bpvISO;
wxBitmapButton* m_bpvLeft;
wxBitmapButton* m_bpvFront;
wxBitmapButton* m_bpvTop;
wxBitmapButton* m_bpUpdate;
wxBitmapButton* m_bpvRight;
wxBitmapButton* m_bpvBack;
wxBitmapButton* m_bpvBottom;
// Virtual event handlers, overide them in your derived class
virtual void onMouseWheelScale( wxMouseEvent& event ) { event.Skip(); }
virtual void updateOrientation( wxCommandEvent& event ) { event.Skip(); }
virtual void onDecrementScale( wxSpinEvent& event ) { event.Skip(); }
virtual void onIncrementScale( wxSpinEvent& event ) { event.Skip(); }
virtual void onMouseWheelRot( wxMouseEvent& event ) { event.Skip(); }
virtual void onDecrementRot( wxSpinEvent& event ) { event.Skip(); }
virtual void onIncrementRot( wxSpinEvent& event ) { event.Skip(); }
virtual void onMouseWheelOffset( wxMouseEvent& event ) { event.Skip(); }
virtual void onDecrementOffset( wxSpinEvent& event ) { event.Skip(); }
virtual void onIncrementOffset( wxSpinEvent& event ) { event.Skip(); }
virtual void View3DISO( wxCommandEvent& event ) { event.Skip(); }
virtual void View3DLeft( wxCommandEvent& event ) { event.Skip(); }
virtual void View3DFront( wxCommandEvent& event ) { event.Skip(); }
virtual void View3DTop( wxCommandEvent& event ) { event.Skip(); }
virtual void View3DUpdate( wxCommandEvent& event ) { event.Skip(); }
virtual void View3DRight( wxCommandEvent& event ) { event.Skip(); }
virtual void View3DBack( wxCommandEvent& event ) { event.Skip(); }
virtual void View3DBottom( wxCommandEvent& event ) { event.Skip(); }
public:
wxTextCtrl* yoff;
PANEL_PREV_3D_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL );
~PANEL_PREV_3D_BASE();
};
#endif //__PANEL_PREV_3D_BASE_H__
@@ -0,0 +1,693 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015-2018 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 panel_prev_model.cpp
*/
#include <3d_canvas/eda_3d_canvas.h>
#include <common_ogl/cogl_att_list.h>
#include <cstdlib>
#include <limits.h>
#include <bitmaps.h>
#include <wx/valnum.h>
#include <wx/tglbtn.h>
#include "project.h"
#include "panel_prev_model.h"
#include <class_board.h>
PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager,
MODULE* aModuleCopy,
COLORS_DESIGN_SETTINGS *aColors,
std::vector<MODULE_3D_SETTINGS> *aParentInfoList ) :
PANEL_PREV_3D_BASE( aParent, wxID_ANY )
{
initPanel();
// Initialize the color settings to draw the board and the footprint
if( aColors )
m_dummyBoard->SetColorsSettings( aColors );
else
{
static COLORS_DESIGN_SETTINGS defaultColors( FRAME_PCB_DISPLAY3D );
m_dummyBoard->SetColorsSettings( &defaultColors );
}
if( NULL != aCacheManager )
m_resolver = aCacheManager->GetResolver();
m_parentInfoList = aParentInfoList;
m_dummyBoard->Add( (MODULE*)aModuleCopy );
m_copyModule = aModuleCopy;
// Set 3d viewer configuration for preview
m_settings3Dviewer = new CINFO3D_VISU();
// Create the 3D canvas
m_previewPane = new EDA_3D_CANVAS( this,
COGL_ATT_LIST::GetAttributesList( true ),
m_dummyBoard,
*m_settings3Dviewer,
aCacheManager );
m_SizerPanelView->Add( m_previewPane, 1, wxEXPAND );
m_previewPane->Connect( wxEVT_ENTER_WINDOW,
wxMouseEventHandler( PANEL_PREV_3D::onEnterPreviewCanvas ),
NULL, this );
}
PANEL_PREV_3D::~PANEL_PREV_3D()
{
m_previewPane->Disconnect( wxEVT_ENTER_WINDOW,
wxMouseEventHandler( PANEL_PREV_3D::onEnterPreviewCanvas ),
NULL, this );
delete m_settings3Dviewer;
delete m_dummyBoard;
delete m_previewPane;
}
void PANEL_PREV_3D::initPanel()
{
m_resolver = NULL;
currentModelFile.clear();
m_dummyBoard = new BOARD();
m_currentSelectedIdx = -1;
// Set the bitmap of 3D view buttons:
m_bpvTop->SetBitmap( KiBitmap( axis3d_top_xpm ) );
m_bpvFront->SetBitmap( KiBitmap( axis3d_front_xpm ) );
m_bpvBack->SetBitmap( KiBitmap( axis3d_back_xpm ) );
m_bpvLeft->SetBitmap( KiBitmap( axis3d_left_xpm ) );
m_bpvRight->SetBitmap( KiBitmap( axis3d_right_xpm ) );
m_bpvBottom->SetBitmap( KiBitmap( axis3d_bottom_xpm ) );
m_bpvISO->SetBitmap( KiBitmap( ortho_xpm ) );
m_bpUpdate->SetBitmap( KiBitmap( reload_xpm ) );
// Set the min and max values of spin buttons (mandatory on Linux)
// They are not used, so they are set to min and max 32 bits int values
// (the min and max values supported by a wxSpinButton)
// It avoids blocking the up or down arrows when reaching this limit after
// a few clicks.
wxSpinButton* spinButtonList[] =
{
m_spinXscale, m_spinYscale, m_spinZscale,
m_spinXrot, m_spinYrot, m_spinZrot,
m_spinXoffset,m_spinYoffset, m_spinZoffset
};
for( int ii = 0; ii < 9; ii++ )
{
spinButtonList[ii]->SetRange( INT_MIN, INT_MAX );
}
wxString units;
switch( g_UserUnit )
{
case INCHES:
units = _( "inches" );
break;
case MILLIMETRES:
units = _( "mm" );
break;
default:
break;
}
if( !units.IsEmpty() )
{
units = wxString::Format( _( "Offset (%s)" ), units );
m_staticTextOffset->SetLabel( units );
}
}
/**
* @brief checkRotation
* Ensure -MAX_ROTATION <= rotation <= MAX_ROTATION
* aRotation will be normalized between -MAX_ROTATION and MAX_ROTATION
* @param aRotation: in out parameter
*/
static void checkRotation( double& aRotation )
{
if( aRotation > MAX_ROTATION )
{
int n = aRotation / MAX_ROTATION;
aRotation -= MAX_ROTATION * n;
}
else if( aRotation < -MAX_ROTATION )
{
int n = -aRotation / MAX_ROTATION;
aRotation += MAX_ROTATION * n;
}
}
static bool validateFloatTextCtrl( wxTextCtrl* aTextCtrl )
{
if( aTextCtrl == NULL )
return false;
if( aTextCtrl->GetLineLength(0) == 0 ) // This will skip the got and event with empty field
return false;
if( aTextCtrl->GetLineLength(0) == 1 )
{
if( (aTextCtrl->GetLineText(0).compare( "." ) == 0) ||
(aTextCtrl->GetLineText(0).compare( "," ) == 0) )
return false;
}
return true;
}
static void incrementTextCtrl( wxTextCtrl* aTextCtrl, double aInc, double aMinval, double aMaxval )
{
if( !validateFloatTextCtrl( aTextCtrl ) )
return;
double curr_value = 0;
aTextCtrl->GetValue().ToDouble( &curr_value );
curr_value += aInc;
if( curr_value > aMaxval )
curr_value = aMaxval;
if( curr_value < aMinval )
curr_value = aMinval;
aTextCtrl->SetValue( wxString::Format( "%.4f", curr_value ) );
}
void PANEL_PREV_3D::SetModelDataIdx( int idx, bool aReloadPreviewModule )
{
wxASSERT( m_parentInfoList != NULL );
if( m_parentInfoList && (idx >= 0) )
{
wxASSERT( (unsigned int)idx < (*m_parentInfoList).size() );
if( (unsigned int)idx < (*m_parentInfoList).size() )
{
m_currentSelectedIdx = -1; // In case that we receive events on the
// next updates, it will set first an
// invalid selection
const MODULE_3D_SETTINGS *aModel = (const MODULE_3D_SETTINGS *)&((*m_parentInfoList)[idx]);
xscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.x ) );
yscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.y ) );
zscale->SetValue( wxString::Format( "%.4f", aModel->m_Scale.z ) );
xrot->SetValue( wxString::Format( "%.2f", aModel->m_Rotation.x ) );
yrot->SetValue( wxString::Format( "%.2f", aModel->m_Rotation.y ) );
zrot->SetValue( wxString::Format( "%.2f", aModel->m_Rotation.z ) );
// Convert from internal units (mm) to user units
double scaler = 1;
switch( g_UserUnit )
{
case MILLIMETRES:
scaler = 1.0f;
break;
case INCHES:
scaler = 25.4f;
break;
default:
wxASSERT( 0 );
}
xoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.x / scaler ) );
yoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.y / scaler ) );
zoff->SetValue( wxString::Format( "%.4f", aModel->m_Offset.z / scaler ) );
UpdateModelName( aModel->m_Filename );
if( aReloadPreviewModule && m_previewPane )
{
updateListOnModelCopy();
m_previewPane->ReloadRequest();
m_previewPane->Request_refresh();
}
m_currentSelectedIdx = idx;
}
}
if( m_previewPane )
{
m_previewPane->SetFocus();
}
return;
}
void PANEL_PREV_3D::ResetModelData( bool aReloadPreviewModule )
{
m_currentSelectedIdx = -1;
xscale->SetValue( wxString::FromDouble( 1.0 ) );
yscale->SetValue( wxString::FromDouble( 1.0 ) );
zscale->SetValue( wxString::FromDouble( 1.0 ) );
xrot->SetValue( wxString::FromDouble( 0.0 ) );
yrot->SetValue( wxString::FromDouble( 0.0 ) );
zrot->SetValue( wxString::FromDouble( 0.0 ) );
xoff->SetValue( wxString::FromDouble( 0.0 ) );
yoff->SetValue( wxString::FromDouble( 0.0 ) );
zoff->SetValue( wxString::FromDouble( 0.0 ) );
// This will update the model on the preview board with the current list of 3d shapes
if( aReloadPreviewModule )
{
updateListOnModelCopy();
if( m_previewPane )
{
m_previewPane->ReloadRequest();
m_previewPane->Request_refresh();
}
}
if( m_previewPane )
m_previewPane->SetFocus();
}
void PANEL_PREV_3D::UpdateModelName( wxString const& aModelName )
{
bool newModel = false;
m_modelInfo.m_Filename = aModelName;
// if the model name is a directory simply clear the current model
if( aModelName.empty() || wxFileName::DirExists( aModelName ) )
{
currentModelFile.clear();
m_modelInfo.m_Filename.clear();
}
else
{
wxString newModelFile;
if( m_resolver )
newModelFile = m_resolver->ResolvePath( aModelName );
if( !newModelFile.empty() && newModelFile.Cmp( currentModelFile ) )
newModel = true;
currentModelFile = newModelFile;
}
if( currentModelFile.empty() || newModel )
{
updateListOnModelCopy();
if( m_previewPane )
{
m_previewPane->ReloadRequest();
m_previewPane->Refresh();
}
if( currentModelFile.empty() )
return;
}
else
{
if( m_previewPane )
m_previewPane->Refresh();
}
if( m_previewPane )
m_previewPane->SetFocus();
return;
}
void PANEL_PREV_3D::updateOrientation( wxCommandEvent &event )
{
wxTextCtrl *textCtrl = (wxTextCtrl *)event.GetEventObject();
if( textCtrl == NULL )
return;
if( textCtrl->GetLineLength(0) == 0 ) // This will skip the got and event with empty field
return;
if( textCtrl->GetLineLength(0) == 1 )
if( (textCtrl->GetLineText(0).compare( "." ) == 0) ||
(textCtrl->GetLineText(0).compare( "," ) == 0) )
return;
SGPOINT scale;
SGPOINT rotation;
SGPOINT offset;
getOrientationVars( scale, rotation, offset );
m_modelInfo.m_Scale.x = scale.x;
m_modelInfo.m_Scale.y = scale.y;
m_modelInfo.m_Scale.z = scale.z;
m_modelInfo.m_Offset.x = offset.x;
m_modelInfo.m_Offset.y = offset.y;
m_modelInfo.m_Offset.z = offset.z;
m_modelInfo.m_Rotation.x = rotation.x;
m_modelInfo.m_Rotation.y = rotation.y;
m_modelInfo.m_Rotation.z = rotation.z;
if( m_currentSelectedIdx >= 0 )
{
// This will update the parent list with the new data
(*m_parentInfoList)[m_currentSelectedIdx] = m_modelInfo;
// It will update the copy model in the preview board
updateListOnModelCopy();
// Since the OpenGL render does not need to be reloaded to update the
// shapes position, we just request to redraw again the canvas
if( m_previewPane )
m_previewPane->Refresh();
}
}
void PANEL_PREV_3D::onIncrementRot( wxSpinEvent& event )
{
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
wxTextCtrl * textCtrl = xrot;
if( spinCtrl == m_spinYrot )
textCtrl = yrot;
else if( spinCtrl == m_spinZrot )
textCtrl = zrot;
incrementTextCtrl( textCtrl, ROTATION_INCREMENT, -MAX_ROTATION, MAX_ROTATION );
}
void PANEL_PREV_3D::onDecrementRot( wxSpinEvent& event )
{
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
wxTextCtrl * textCtrl = xrot;
if( spinCtrl == m_spinYrot )
textCtrl = yrot;
else if( spinCtrl == m_spinZrot )
textCtrl = zrot;
incrementTextCtrl( textCtrl, -ROTATION_INCREMENT, -MAX_ROTATION, MAX_ROTATION );
}
void PANEL_PREV_3D::onIncrementScale( wxSpinEvent& event )
{
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
wxTextCtrl * textCtrl = xscale;
if( spinCtrl == m_spinYscale )
textCtrl = yscale;
else if( spinCtrl == m_spinZscale )
textCtrl = zscale;
incrementTextCtrl( textCtrl, SCALE_INCREMENT, 1/MAX_SCALE, MAX_SCALE );
}
void PANEL_PREV_3D::onDecrementScale( wxSpinEvent& event )
{
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
wxTextCtrl * textCtrl = xscale;
if( spinCtrl == m_spinYscale )
textCtrl = yscale;
else if( spinCtrl == m_spinZscale )
textCtrl = zscale;
incrementTextCtrl( textCtrl, -SCALE_INCREMENT, 1/MAX_SCALE, MAX_SCALE );
}
void PANEL_PREV_3D::onIncrementOffset( wxSpinEvent& event )
{
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
wxTextCtrl * textCtrl = xoff;
if( spinCtrl == m_spinYoffset )
textCtrl = yoff;
else if( spinCtrl == m_spinZoffset )
textCtrl = zoff;
double step = OFFSET_INCREMENT_MM;
if( g_UserUnit == INCHES )
step = OFFSET_INCREMENT_MIL/1000.0;
incrementTextCtrl( textCtrl, step, -MAX_OFFSET, MAX_OFFSET );
}
void PANEL_PREV_3D::onDecrementOffset( wxSpinEvent& event )
{
wxSpinButton* spinCtrl = (wxSpinButton*) event.GetEventObject();
wxTextCtrl * textCtrl = xoff;
if( spinCtrl == m_spinYoffset )
textCtrl = yoff;
else if( spinCtrl == m_spinZoffset )
textCtrl = zoff;
double step = OFFSET_INCREMENT_MM;
if( g_UserUnit == INCHES )
step = OFFSET_INCREMENT_MIL/1000.0;
incrementTextCtrl( textCtrl, -step, -MAX_OFFSET, MAX_OFFSET );
}
void PANEL_PREV_3D::onMouseWheelScale( wxMouseEvent& event )
{
wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
double step = SCALE_INCREMENT;
if( event.ShiftDown( ) )
step = SCALE_INCREMENT_FINE;
if( event.GetWheelRotation() >= 0 )
step = -step;
incrementTextCtrl( textCtrl, step, 1/MAX_SCALE, MAX_SCALE );
}
void PANEL_PREV_3D::onMouseWheelRot( wxMouseEvent& event )
{
wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
wxKeyboardState kbdState;
double step = ROTATION_INCREMENT_WHEEL;
if( event.ShiftDown( ) )
step = ROTATION_INCREMENT_WHEEL_FINE;
if( event.GetWheelRotation() >= 0 )
step = -step;
incrementTextCtrl( textCtrl, step, -MAX_ROTATION, MAX_ROTATION );
}
void PANEL_PREV_3D::onMouseWheelOffset( wxMouseEvent& event )
{
wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
double step = OFFSET_INCREMENT_MM;
if( event.ShiftDown( ) )
step = OFFSET_INCREMENT_MM_FINE;
if( g_UserUnit == INCHES )
{
step = OFFSET_INCREMENT_MIL/1000.0;
if( event.ShiftDown( ) )
step = OFFSET_INCREMENT_MIL_FINE/1000.0;
}
if( event.GetWheelRotation() >= 0 )
step = -step;
incrementTextCtrl( textCtrl, step, -MAX_OFFSET, MAX_OFFSET );
}
void PANEL_PREV_3D::getOrientationVars( SGPOINT& aScale, SGPOINT& aRotation, SGPOINT& aOffset )
{
if( NULL == xscale || NULL == yscale || NULL == zscale
|| NULL == xrot || NULL == yrot || NULL == zrot
|| NULL == xoff || NULL == yoff || NULL == zoff )
{
return;
}
xscale->GetValue().ToDouble( &aScale.x );
yscale->GetValue().ToDouble( &aScale.y );
zscale->GetValue().ToDouble( &aScale.z );
xrot->GetValue().ToDouble( &aRotation.x );
yrot->GetValue().ToDouble( &aRotation.y );
zrot->GetValue().ToDouble( &aRotation.z );
checkRotation( aRotation.x );
checkRotation( aRotation.y );
checkRotation( aRotation.z );
xoff->GetValue().ToDouble( &aOffset.x );
yoff->GetValue().ToDouble( &aOffset.y );
zoff->GetValue().ToDouble( &aOffset.z );
// Convert from user units to internal units (mm)
double scaler = 1.0f;
switch( g_UserUnit )
{
case MILLIMETRES:
scaler = 1.0f;
break;
case INCHES:
scaler = 25.4f;
break;
default:
wxASSERT( 0 );
}
aOffset.x *= scaler;
aOffset.y *= scaler;
aOffset.z *= scaler;
return;
}
bool PANEL_PREV_3D::ValidateWithMessage( wxString& aErrorMessage )
{
bool invalidScale = false;
for( unsigned int idx = 0; idx < m_parentInfoList->size(); ++idx )
{
wxString msg;
bool addError = false;
MODULE_3D_SETTINGS& s3dshape = (*m_parentInfoList)[idx];
SGPOINT scale;
scale.x = s3dshape.m_Scale.x;
scale.y = s3dshape.m_Scale.y;
scale.z = s3dshape.m_Scale.z;
if( 1/MAX_SCALE > scale.x || MAX_SCALE < scale.x )
{
invalidScale = true;
addError = true;
msg += _( "Invalid X scale" );
}
if( 1/MAX_SCALE > scale.y || MAX_SCALE < scale.y )
{
invalidScale = true;
addError = true;
if( !msg.IsEmpty() )
msg += "\n";
msg += _( "Invalid Y scale" );
}
if( 1/MAX_SCALE > scale.z || MAX_SCALE < scale.z )
{
invalidScale = true;
addError = true;
if( !msg.IsEmpty() )
msg += "\n";
msg += _( "Invalid Z scale" );
}
if( addError )
{
msg.Prepend( s3dshape.m_Filename + "\n" );
if( !aErrorMessage.IsEmpty() )
aErrorMessage += "\n\n";
aErrorMessage += msg;
}
}
if( !aErrorMessage.IsEmpty() )
{
aErrorMessage += "\n\n";
aErrorMessage += wxString::Format( "Min value = %.4f and max value = %.4f",
1/MAX_SCALE, MAX_SCALE );
}
return invalidScale == false;
}
void PANEL_PREV_3D::updateListOnModelCopy()
{
auto draw3D = &m_copyModule->Models();
draw3D->clear();
draw3D->insert( draw3D->end(), m_parentInfoList->begin(), m_parentInfoList->end() );
}
@@ -0,0 +1,221 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2015-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 panel_prev_model.h
* @brief Defines a panel which is to be added to a wxFileDialog via
* SetExtraControl();
* The panel shows a preview of the module being edited and provides controls
* to set the offset/rotation/scale of each model 3d shape as per KiCad's
* current behavior. The panel may also be used in the 3D configuration dialog
* to tune the positioning of the models without invoking a file selector dialog.
*/
#ifndef PANEL_PREV_MODEL_H
#define PANEL_PREV_MODEL_H
#include "panel_prev_3d_base.h"
#include <vector>
#include <3d_canvas/eda_3d_canvas.h>
// Define min and max parameter values
#define MAX_SCALE 10000.0
#define MAX_ROTATION 180.0
#define MAX_OFFSET 1000.0
#define SCALE_INCREMENT_FINE 0.02
#define SCALE_INCREMENT 0.1
#define ROTATION_INCREMENT 5 // in degrees, for spin button command
#define ROTATION_INCREMENT_WHEEL 15 // in degrees, for mouse wheel command
#define ROTATION_INCREMENT_WHEEL_FINE 1 // in degrees, for mouse wheel command
#define OFFSET_INCREMENT_MM 0.5
#define OFFSET_INCREMENT_MM_FINE 0.1
#define OFFSET_INCREMENT_MIL 25.0
#define OFFSET_INCREMENT_MIL_FINE 5.0
// Declared classes to create pointers
class S3D_CACHE;
class S3D_FILENAME_RESOLVER;
class BOARD;
class CINFO3D_VISU;
class MODULE;
class COLORS_DESIGN_SETTINGS;
class PANEL_PREV_3D: public PANEL_PREV_3D_BASE
{
public:
PANEL_PREV_3D( wxWindow* aParent, S3D_CACHE* aCacheManager,
MODULE* aModuleCopy,
COLORS_DESIGN_SETTINGS *aColors,
std::vector<MODULE_3D_SETTINGS> *aParentInfoList = NULL );
~PANEL_PREV_3D();
private:
wxString currentModelFile; ///< Used to check if the model file was changed
S3D_FILENAME_RESOLVER *m_resolver; ///< Used to get the full path name
/// The 3D canvas
EDA_3D_CANVAS *m_previewPane;
/// A dummy board used to store the copy moduled
BOARD *m_dummyBoard;
/// The settings that will be used for this 3D viewer canvas
CINFO3D_VISU *m_settings3Dviewer;
/// A pointer to a new copy of the original module
MODULE *m_copyModule;
/// A pointer to the parent MODULE_3D_SETTINGS list that we will use to copy to the preview module
std::vector<MODULE_3D_SETTINGS> *m_parentInfoList;
/// The current selected index of the MODULE_3D_SETTINGS list
int m_currentSelectedIdx;
/// Current MODULE_3D_SETTINGS that is being edited
MODULE_3D_SETTINGS m_modelInfo;
// Methods of the class
private:
void initPanel();
/**
* @brief updateOrientation - it will receive the events from editing the fields
* @param event
*/
void updateOrientation( wxCommandEvent &event ) override;
void onMouseWheelScale( wxMouseEvent& event ) override;
void onMouseWheelRot( wxMouseEvent& event ) override;
void onMouseWheelOffset( wxMouseEvent& event ) override;
void onIncrementRot( wxSpinEvent& event ) override;
void onDecrementRot( wxSpinEvent& event ) override;
void onIncrementScale( wxSpinEvent& event ) override;
void onDecrementScale( wxSpinEvent& event ) override;
void onIncrementOffset( wxSpinEvent& event ) override;
void onDecrementOffset( wxSpinEvent& event ) override;
/**
* @brief getOrientationVars - gets the transformation from entries and validate it
* @param aScale: output scale var
* @param aRotation: output rotation var
* @param aOffset: output offset var
*/
void getOrientationVars( SGPOINT& aScale, SGPOINT& aRotation, SGPOINT& aOffset );
/**
* @brief updateListOnModelCopy - copy the current shape list to the copy of module that is on
* the preview dummy board
*/
void updateListOnModelCopy();
void onEnterPreviewCanvas( wxMouseEvent& event )
{
m_previewPane->SetFocus();
}
void View3DISO( wxCommandEvent& event ) override
{
m_settings3Dviewer->CameraGet().ToggleProjection();
m_previewPane->Refresh();
}
void View3DLeft( wxCommandEvent& event ) override
{
m_previewPane->SetView3D( 'X' );
}
void View3DFront( wxCommandEvent& event ) override
{
m_previewPane->SetView3D( 'Y' );
}
void View3DTop( wxCommandEvent& event ) override
{
m_previewPane->SetView3D( 'z' );
}
void View3DUpdate( wxCommandEvent& event ) override
{
m_previewPane->ReloadRequest();
m_previewPane->Refresh();
}
void View3DRight( wxCommandEvent& event ) override
{
m_previewPane->SetView3D( 'x' );
}
void View3DBack( wxCommandEvent& event ) override
{
m_previewPane->SetView3D( 'y' );
}
void View3DBottom( wxCommandEvent& event ) override
{
m_previewPane->SetView3D( 'Z' );
}
public:
/**
* @brief SetModelDataIdx - This will set the index of the INFO list that was set on the parent.
* So we will update our values to edit based on the index on that list.
* @param idx - The index that was selected
* @param aReloadPreviewModule: if need to update the preview module
*/
void SetModelDataIdx( int idx, bool aReloadPreviewModule = false );
/**
* @brief ResetModelData - Clear the values and reload the preview board
* @param aReloadPreviewModule: if need to update the preview module
*/
void ResetModelData( bool aReloadPreviewModule = false );
void UpdateModelName( wxString const& aModel );
/**
* @brief verify X,Y and Z scale factors are acceptable (> 0.001 and < 1000.0)
* @return false if one (or more) value is not acceptable.
* @param aErrorMessage is a wxString to store error messages, if any
*/
bool ValidateWithMessage( wxString& aErrorMessage );
bool Validate() override
{
wxString temp;
return ValidateWithMessage(temp);
}
};
#endif // PANEL_PREV_MODEL_H
+102
View File
@@ -0,0 +1,102 @@
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 )
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} )
install( TARGETS
kicad_3dsg
DESTINATION ${KICAD_LIB}
COMPONENT binary
)
+671
View File
@@ -0,0 +1,671 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 <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"
#ifdef DEBUG
static char BadNode[] = " * [BUG] NULL pointer passed for aNode\n";
#endif
// 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;
return;
}
bool S3D::WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode,
bool reuse, bool renameNodes )
{
if( NULL == 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;
}
if( NULL == aTopNode )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aTopNode";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return false;
}
if( S3D::SGTYPE_TRANSFORM != aTopNode->GetNodeType() )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] aTopNode is not a SCENEGRAPH object";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return false;
}
OPEN_OSTREAM( op, filename );
if( op.fail() )
{
wxString errmsg;
errmsg << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
errmsg << " * [INFO] " << "failed to open file" << " '" << filename << "'";
wxLogTrace( MASK_3D_SG, errmsg );
return false;
}
op.imbue( std::locale( "C" ) );
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 );
wxString errmsg;
errmsg << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
errmsg << " * [INFO] " << "problems encountered writing file" << " '" << filename << "'";
wxLogTrace( MASK_3D_SG, errmsg );
return false;
}
void S3D::ResetNodeIndex( SGNODE* aNode )
{
if( NULL == aNode )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadNode;
wxLogTrace( MASK_3D_SG, "%s", ostr.str().c_str() );
} while( 0 );
#endif
return;
}
aNode->ResetNodeIndex();
return;
}
void S3D::RenameNodes( SGNODE* aNode )
{
if( NULL == aNode )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadNode;
wxLogTrace( MASK_3D_SG, "%s", ostr.str().c_str() );
} while( 0 );
#endif
return;
}
aNode->ReNameNodes();
return;
}
void S3D::DestroyNode( SGNODE* aNode )
{
if( NULL == aNode )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadNode;
wxLogTrace( MASK_3D_SG, "%s", ostr.str().c_str() );
} while( 0 );
#endif
return;
}
delete aNode;
return;
}
bool S3D::WriteCache( const char* aFileName, bool overwrite, SGNODE* aNode,
const char* aPluginInfo )
{
if( NULL == aFileName || aFileName[0] == 0 )
return false;
wxString ofile = wxString::FromUTF8Unchecked( aFileName );
if( NULL == aNode )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadNode;
wxLogTrace( MASK_3D_SG, "%s", ostr.str().c_str() );
} while( 0 );
#endif
return false;
}
if( wxFileName::Exists( ofile ) )
{
if( !overwrite )
{
wxString errmsg;
errmsg << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
errmsg << " * [INFO] " << "file exists; not overwriting" << " '";
errmsg << aFileName << "'";
wxLogTrace( MASK_3D_SG, errmsg );
return false;
}
// make sure we make no attempt to write a directory
if( !wxFileName::FileExists( aFileName ) )
{
wxString errmsg;
errmsg << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
errmsg << " * [INFO] " << "specified path is a directory" << " '";
errmsg << aFileName << "'";
wxLogTrace( MASK_3D_SG, errmsg );
return false;
}
}
OPEN_OSTREAM( output, aFileName );
if( output.fail() )
{
wxString errmsg;
errmsg << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
errmsg << " * [INFO] " << "failed to open file" << " '" << aFileName << "'";
wxLogTrace( MASK_3D_SG, errmsg );
return false;
}
output << "(" << SG_VERSION_TAG << ")";
if( NULL != aPluginInfo && aPluginInfo[0] != 0 )
output << "(" << aPluginInfo << ")";
else
output << "(INTERNAL:0.0.0.0)";
bool rval = aNode->WriteCache( output, NULL );
CLOSE_STREAM( output );
if( !rval )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] problems encountered writing cache file '";
ostr << aFileName << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
// delete the defective file
wxRemoveFile( ofile );
}
return rval;
}
SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr,
bool (*aTagCheck)( const char*, void* ) )
{
if( NULL == aFileName || aFileName[0] == 0 )
return NULL;
wxString ofile = wxString::FromUTF8Unchecked( aFileName );
if( !wxFileName::FileExists( aFileName ) )
{
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
wxString errmsg = _( "no such file" );
ostr << " * [INFO] " << errmsg.ToUTF8() << " '";
ostr << aFileName << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
return NULL;
}
SGNODE* np = new SCENEGRAPH( NULL );
if( NULL == np )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] failed to instantiate SCENEGRAPH";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return NULL;
}
OPEN_ISTREAM( file, aFileName );
if( file.fail() )
{
delete np;
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
wxString errmsg = _( "failed to open file" );
ostr << " * [INFO] " << errmsg.ToUTF8() << " '";
ostr << aFileName << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
return NULL;
}
// 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 )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; missing left parenthesis at position ";
ostr << file.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
CLOSE_STREAM( file );
return NULL;
}
file.get( schar );
while( ')' != schar && file.good() )
{
name.push_back( schar );
file.get( schar );
}
if( name.compare( SG_VERSION_TAG ) )
{
CLOSE_STREAM( file );
return NULL;
}
} 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 )
{
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; missing left parenthesis at position ";
ostr << file.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
CLOSE_STREAM( file );
return NULL;
}
file.get( schar );
while( ')' != schar && file.good() )
{
name.push_back( schar );
file.get( schar );
}
// check the plugin tag
if( NULL != aTagCheck && NULL != aPluginMgr && !aTagCheck( name.c_str(), aPluginMgr ) )
{
CLOSE_STREAM( file );
return NULL;
}
} while( 0 );
bool rval = np->ReadCache( file, NULL );
CLOSE_STREAM( file );
if( !rval )
{
delete np;
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
wxString errmsg = "problems encountered reading cache file";
ostr << " * [INFO] " << errmsg.ToUTF8() << " '";
ostr << aFileName << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
return NULL;
}
return np;
}
S3DMODEL* S3D::GetModel( SCENEGRAPH* aNode )
{
if( NULL == aNode )
return NULL;
if( aNode->GetNodeType() != S3D::SGTYPE_TRANSFORM )
return NULL;
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( NULL );
app.ambient = SGCOLOR( 0.6, 0.6, 0.6 );
app.diffuse = SGCOLOR( 0.6, 0.6, 0.6 );
app.specular = app.diffuse;
app.shininess = 0.05;
app.transparency = 0.0;
materials.matorder.push_back( &app );
materials.matmap.insert( std::pair< SGAPPEARANCE const*, int >( &app, 0 ) );
if( aNode->Prepare( NULL, materials, meshes ) )
{
if( meshes.empty() )
return NULL;
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 NULL;
}
void S3D::Destroy3DModel( S3DMODEL** aModel )
{
if( NULL == aModel || NULL == *aModel )
return;
S3DMODEL* m = *aModel;
S3D::FREE_S3DMODEL( *m );
delete m;
*aModel = NULL;
return;
}
void Free3DModel( S3DMODEL& aModel )
{
S3D::FREE_S3DMODEL( aModel );
return;
}
void S3D::Free3DMesh( SMESH& aMesh )
{
S3D::FREE_SMESH( aMesh );
return;
}
S3DMODEL* S3D::New3DModel( void )
{
S3DMODEL* mp = new S3DMODEL;
S3D::INIT_S3DMODEL( *mp );
return mp;
}
void S3D::Init3DMaterial( SMATERIAL& aMat )
{
S3D::INIT_SMATERIAL( aMat );
return;
}
void S3D::Init3DMesh( SMESH& aMesh )
{
S3D::INIT_SMESH( aMesh );
return;
}
void S3D::GetLibVersion( unsigned char* Major, unsigned char* Minor,
unsigned char* Patch, unsigned char* Revision )
{
if( Major )
*Major = KICADSG_VERSION_MAJOR;
if( Minor )
*Minor = KICADSG_VERSION_MINOR;
if( Revision )
*Revision = KICADSG_VERSION_REVISION;
if( Patch )
*Patch = KICADSG_VERSION_PATCH;
return;
}
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( NULL == aNode )
return SGTYPE_END;
return aNode->GetNodeType();
}
SGNODE* S3D::GetSGNodeParent( SGNODE* aNode )
{
if( NULL == aNode )
return NULL;
return aNode->GetParent();
}
bool S3D::AddSGNodeRef( SGNODE* aParent, SGNODE* aChild )
{
if( NULL == aParent || NULL == aChild )
return false;
return aParent->AddRefNode( aChild );
}
bool S3D::AddSGNodeChild( SGNODE* aParent, SGNODE* aChild )
{
if( NULL == aParent || NULL == aChild )
return false;
return aParent->AddChildNode( aChild );
}
void S3D::AssociateSGNodeWrapper( SGNODE* aObject, SGNODE** aRefPtr )
{
if( NULL == aObject || NULL == aRefPtr || aObject != *aRefPtr )
return;
aObject->AssociateWrapper( aRefPtr );
return;
}
+472
View File
@@ -0,0 +1,472 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 BadObject[];
extern char BadOperand[];
extern char BadParent[];
extern char WrongParent[];
IFSG_APPEARANCE::IFSG_APPEARANCE( bool create )
{
m_node = NULL;
if( !create )
return ;
m_node = new SGAPPEARANCE( NULL );
if( m_node )
m_node->AssociateWrapper( &m_node );
return;
}
IFSG_APPEARANCE::IFSG_APPEARANCE( SGNODE* aParent )
{
m_node = new SGAPPEARANCE( NULL );
if( m_node )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
IFSG_APPEARANCE::IFSG_APPEARANCE( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( ! pp )
{
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
}
#endif
m_node = new SGAPPEARANCE( NULL );
if( m_node )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
bool IFSG_APPEARANCE::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = NULL;
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() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid SGNODE parent (";
ostr << aParent->GetNodeTypeName( aParent->GetNodeType() );
ostr << ") to SGAPPEARANCE";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
delete m_node;
m_node = NULL;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_APPEARANCE::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
if( NULL == np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return NewNode( np );
}
bool IFSG_APPEARANCE::SetEmissive( float aRVal, float aGVal, float aBVal )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject << "\n";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetEmissive( aRVal, aGVal, aBVal );
}
bool IFSG_APPEARANCE::SetEmissive( const SGCOLOR* aRGBColor )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject << "\n";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetEmissive( aRGBColor );
}
bool IFSG_APPEARANCE::SetEmissive( const SGCOLOR& aRGBColor )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetEmissive( aRGBColor );
}
bool IFSG_APPEARANCE::SetDiffuse( float aRVal, float aGVal, float aBVal )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetDiffuse( aRVal, aGVal, aBVal );
}
bool IFSG_APPEARANCE::SetDiffuse( const SGCOLOR* aRGBColor )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetDiffuse( aRGBColor );
}
bool IFSG_APPEARANCE::SetDiffuse( const SGCOLOR& aRGBColor )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetDiffuse( aRGBColor );
}
bool IFSG_APPEARANCE::SetSpecular( float aRVal, float aGVal, float aBVal )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetSpecular( aRVal, aGVal, aBVal );
}
bool IFSG_APPEARANCE::SetSpecular( const SGCOLOR* aRGBColor )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetSpecular( aRGBColor );
}
bool IFSG_APPEARANCE::SetSpecular( const SGCOLOR& aRGBColor )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetSpecular( aRGBColor );
}
bool IFSG_APPEARANCE::SetAmbient( float aRVal, float aGVal, float aBVal )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetAmbient( aRVal, aGVal, aBVal );
}
bool IFSG_APPEARANCE::SetAmbient( const SGCOLOR* aRGBColor )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetAmbient( aRGBColor );
}
bool IFSG_APPEARANCE::SetAmbient( const SGCOLOR& aRGBColor )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGAPPEARANCE*)m_node)->SetAmbient( aRGBColor );
}
bool IFSG_APPEARANCE::SetShininess( float aShininess )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( aShininess < 0 || aShininess > 1.0 )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] shininess out of range [0..1]";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGAPPEARANCE*)m_node)->shininess = aShininess;
return true;
}
bool IFSG_APPEARANCE::SetTransparency( float aTransparency )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( aTransparency < 0 || aTransparency > 1.0 )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] transparency out of range [0..1]";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGAPPEARANCE*)m_node)->transparency = aTransparency;
return true;
}
+267
View File
@@ -0,0 +1,267 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 BadObject[];
extern char BadParent[];
extern char WrongParent[];
IFSG_COLORS::IFSG_COLORS( bool create )
{
m_node = NULL;
if( !create )
return ;
m_node = new SGCOLORS( NULL );
if( m_node )
m_node->AssociateWrapper( &m_node );
return;
}
IFSG_COLORS::IFSG_COLORS( SGNODE* aParent )
{
m_node = new SGCOLORS( NULL );
if( m_node )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
IFSG_COLORS::IFSG_COLORS( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( ! pp )
{
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
}
#endif
m_node = new SGCOLORS( NULL );
if( m_node )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
bool IFSG_COLORS::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = NULL;
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() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid SGNODE parent (";
ostr << aParent->GetNodeTypeName( aParent->GetNodeType() );
ostr << ") to SGCOLORS";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
delete m_node;
m_node = NULL;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_COLORS::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
if( NULL == np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return NewNode( np );
}
bool IFSG_COLORS::GetColorList( size_t& aListSize, SGCOLOR*& aColorList )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGCOLORS*)m_node)->GetColorList( aListSize, aColorList );
}
bool IFSG_COLORS::SetColorList( size_t aListSize, const SGCOLOR* aColorList )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGCOLORS*)m_node)->SetColorList( aListSize, aColorList );
return true;
}
bool IFSG_COLORS::AddColor( double aRedValue, double aGreenValue, double aBlueValue )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGCOLORS*)m_node)->AddColor( aRedValue, aGreenValue, aBlueValue );
return true;
}
bool IFSG_COLORS::AddColor( const SGCOLOR& aColor )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGCOLORS*)m_node)->AddColor( aColor );
return true;
}
+186
View File
@@ -0,0 +1,186 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 BadObject[];
extern char BadOperand[];
extern char BadParent[];
extern char WrongParent[];
IFSG_COORDINDEX::IFSG_COORDINDEX( bool create )
{
m_node = NULL;
if( !create )
return;
m_node = new SGCOORDINDEX( NULL );
if( m_node )
m_node->AssociateWrapper( &m_node );
return;
}
IFSG_COORDINDEX::IFSG_COORDINDEX( SGNODE* aParent )
{
m_node = new SGCOORDINDEX( NULL );
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
IFSG_COORDINDEX::IFSG_COORDINDEX( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
if( !pp )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node = new SGCOORDINDEX( NULL );
if( !m_node->SetParent( pp ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
delete m_node;
m_node = NULL;
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
bool IFSG_COORDINDEX::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = NULL;
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() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid SGNODE parent (";
ostr << aParent->GetNodeTypeName( aParent->GetNodeType() );
ostr << ") to SGCOORDINDEX";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
delete m_node;
m_node = NULL;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_COORDINDEX::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
if( NULL == np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return NewNode( np );
}
+267
View File
@@ -0,0 +1,267 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 BadObject[];
extern char BadParent[];
extern char WrongParent[];
IFSG_COORDS::IFSG_COORDS( bool create )
{
m_node = NULL;
if( !create )
return ;
m_node = new SGCOORDS( NULL );
if( m_node )
m_node->AssociateWrapper( &m_node );
return;
}
IFSG_COORDS::IFSG_COORDS( SGNODE* aParent )
{
m_node = new SGCOORDS( NULL );
if( m_node )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
IFSG_COORDS::IFSG_COORDS( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( ! pp )
{
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
}
#endif
m_node = new SGCOORDS( NULL );
if( m_node )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
bool IFSG_COORDS::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = NULL;
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() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid SGNODE parent (";
ostr << aParent->GetNodeTypeName( aParent->GetNodeType() );
ostr << ") to SGCOORDS";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
delete m_node;
m_node = NULL;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_COORDS::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
if( NULL == np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return NewNode( np );
}
bool IFSG_COORDS::GetCoordsList( size_t& aListSize, SGPOINT*& aCoordsList )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGCOORDS*)m_node)->GetCoordsList( aListSize, aCoordsList );
}
bool IFSG_COORDS::SetCoordsList( size_t aListSize, const SGPOINT* aCoordsList )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGCOORDS*)m_node)->SetCoordsList( aListSize, aCoordsList );
return true;
}
bool IFSG_COORDS::AddCoord( double aXValue, double aYValue, double aZValue )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGCOORDS*)m_node)->AddCoord( aXValue, aYValue, aZValue );
return true;
}
bool IFSG_COORDS::AddCoord( const SGPOINT& aPoint )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGCOORDS*)m_node)->AddCoord( aPoint );
return true;
}
+199
View File
@@ -0,0 +1,199 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 BadObject[];
extern char BadParent[];
extern char WrongParent[];
IFSG_FACESET::IFSG_FACESET( bool create )
{
m_node = NULL;
if( !create )
return ;
m_node = new SGFACESET( NULL );
if( m_node )
m_node->AssociateWrapper( &m_node );
return;
}
IFSG_FACESET::IFSG_FACESET( SGNODE* aParent )
{
m_node = new SGFACESET( NULL );
if( m_node )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
IFSG_FACESET::IFSG_FACESET( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( ! pp )
{
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
}
#endif
m_node = new SGFACESET( NULL );
if( m_node )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
bool IFSG_FACESET::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = NULL;
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() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid SGNODE parent (";
ostr << aParent->GetNodeTypeName( aParent->GetNodeType() );
ostr << ") to SGFACESET";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
delete m_node;
m_node = NULL;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_FACESET::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
if( NULL == np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return NewNode( np );
}
bool IFSG_FACESET::CalcNormals( SGNODE** aPtr )
{
if( m_node )
return ((SGFACESET*)m_node)->CalcNormals( aPtr );
return false;
}
+100
View File
@@ -0,0 +1,100 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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"
extern char BadObject[];
extern char BadOperand[];
extern char BadParent[];
extern char WrongParent[];
IFSG_INDEX::IFSG_INDEX() : IFSG_NODE()
{
return;
}
bool IFSG_INDEX::GetIndices( size_t& nIndices, int*& aIndexList )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGINDEX*)m_node)->GetIndices( nIndices, aIndexList );
}
bool IFSG_INDEX::SetIndices( size_t nIndices, int* aIndexList )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGINDEX*)m_node)->SetIndices( nIndices, aIndexList );
return true;
}
bool IFSG_INDEX::AddIndex( int aIndex )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGINDEX*)m_node)->AddIndex( aIndex );
return true;
}
+296
View File
@@ -0,0 +1,296 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 = NULL;
}
IFSG_NODE::~IFSG_NODE()
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
return;
}
void IFSG_NODE::Destroy( void )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
delete m_node;
m_node = NULL;
return;
}
SGNODE* IFSG_NODE::GetRawPtr( void )
{
return m_node;
}
S3D::SGTYPES IFSG_NODE::GetNodeType( void ) const
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return S3D::SGTYPE_END;
}
return m_node->GetNodeType();
}
SGNODE* IFSG_NODE::GetParent( void ) const
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return NULL;
}
return m_node->GetParent();
}
bool IFSG_NODE::SetParent( SGNODE* aParent )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return m_node->SetParent( aParent );
}
const char* IFSG_NODE::GetName( void )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return NULL;
}
return m_node->GetName();
}
bool IFSG_NODE::SetName( const char *aName )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
m_node->SetName( aName );
return true;
}
const char * IFSG_NODE::GetNodeTypeName( S3D::SGTYPES aNodeType ) const
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return NULL;
}
return m_node->GetNodeTypeName( aNodeType );
}
SGNODE* IFSG_NODE::FindNode( const char *aNodeName )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return NULL;
}
return m_node->FindNode( aNodeName, NULL );
}
bool IFSG_NODE::AddRefNode( SGNODE* aNode )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return m_node->AddRefNode( aNode );
}
bool IFSG_NODE::AddRefNode( IFSG_NODE& aNode )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* np = aNode.GetRawPtr();
if( NULL == np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadOperand;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return m_node->AddRefNode( np );
}
bool IFSG_NODE::AddChildNode( SGNODE* aNode )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return m_node->AddChildNode( aNode );
}
bool IFSG_NODE::AddChildNode( IFSG_NODE& aNode )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* np = aNode.GetRawPtr();
if( NULL == np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadOperand;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return m_node->AddChildNode( np );
}
+266
View File
@@ -0,0 +1,266 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 BadObject[];
extern char BadOperand[];
extern char BadParent[];
extern char WrongParent[];
IFSG_NORMALS::IFSG_NORMALS( bool create )
{
m_node = NULL;
if( !create )
return;
m_node = new SGNORMALS( NULL );
if( m_node )
m_node->AssociateWrapper( &m_node );
return;
}
IFSG_NORMALS::IFSG_NORMALS( SGNODE* aParent )
{
m_node = new SGNORMALS( NULL );
if( m_node )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
IFSG_NORMALS::IFSG_NORMALS( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( ! pp )
{
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
}
#endif
m_node = new SGNORMALS( NULL );
if( m_node )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
bool IFSG_NORMALS::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = NULL;
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() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid SGNODE parent (";
ostr << aParent->GetNodeTypeName( aParent->GetNodeType() );
ostr << ") to SGNORMALS";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
delete m_node;
m_node = NULL;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_NORMALS::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
if( NULL == np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return NewNode( np );
}
bool IFSG_NORMALS::GetNormalList( size_t& aListSize, SGVECTOR*& aNormalList )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ((SGNORMALS*)m_node)->GetNormalList( aListSize, aNormalList );
}
bool IFSG_NORMALS::SetNormalList( size_t aListSize, const SGVECTOR* aNormalList )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGNORMALS*)m_node)->SetNormalList( aListSize, aNormalList );
return true;
}
bool IFSG_NORMALS::AddNormal( double aXValue, double aYValue, double aZValue )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGNORMALS*)m_node)->AddNormal( aXValue, aYValue, aZValue );
return true;
}
bool IFSG_NORMALS::AddNormal( const SGVECTOR& aNormal )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SGNORMALS*)m_node)->AddNormal( aNormal );
return true;
}
+191
View File
@@ -0,0 +1,191 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 BadObject[];
extern char BadOperand[];
extern char BadParent[];
extern char WrongParent[];
IFSG_SHAPE::IFSG_SHAPE( bool create )
{
m_node = NULL;
if( !create )
return ;
m_node = new SGSHAPE( NULL );
if( m_node )
m_node->AssociateWrapper( &m_node );
return;
}
IFSG_SHAPE::IFSG_SHAPE( SGNODE* aParent )
{
m_node = new SGSHAPE( NULL );
if( m_node )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
IFSG_SHAPE::IFSG_SHAPE( IFSG_NODE& aParent )
{
SGNODE* pp = aParent.GetRawPtr();
#ifdef DEBUG
if( ! pp )
{
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
}
#endif
m_node = new SGSHAPE( NULL );
if( m_node )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
bool IFSG_SHAPE::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = NULL;
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() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid SGNODE parent (";
ostr << aParent->GetNodeTypeName( aParent->GetNodeType() );
ostr << ") to SGSHAPE";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
delete m_node;
m_node = NULL;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_SHAPE::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
if( NULL == np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return NewNode( np );
}
+284
View File
@@ -0,0 +1,284 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 BadObject[];
extern char BadOperand[];
extern char BadParent[];
extern char WrongParent[];
IFSG_TRANSFORM::IFSG_TRANSFORM( bool create )
{
m_node = NULL;
if( !create )
return;
m_node = new SCENEGRAPH( NULL );
if( m_node )
m_node->AssociateWrapper( &m_node );
return;
}
IFSG_TRANSFORM::IFSG_TRANSFORM( SGNODE* aParent )
{
m_node = new SCENEGRAPH( NULL );
if( m_node )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << WrongParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_node->AssociateWrapper( &m_node );
}
return;
}
bool IFSG_TRANSFORM::Attach( SGNODE* aNode )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
m_node = NULL;
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() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid SGNODE parent (";
ostr << aParent->GetNodeTypeName( aParent->GetNodeType() );
ostr << ") to SCENEGRAPH";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
delete m_node;
m_node = NULL;
return false;
}
m_node->AssociateWrapper( &m_node );
return true;
}
bool IFSG_TRANSFORM::NewNode( IFSG_NODE& aParent )
{
SGNODE* np = aParent.GetRawPtr();
if( NULL == np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadParent;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return NewNode( np );
}
bool IFSG_TRANSFORM::SetRotation( const SGVECTOR& aRotationAxis, double aAngle )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SCENEGRAPH*)m_node)->rotation_axis = aRotationAxis;
((SCENEGRAPH*)m_node)->rotation_angle = aAngle;
return true;
}
bool IFSG_TRANSFORM::SetScale( const SGPOINT& aScale )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SCENEGRAPH*)m_node)->scale = aScale;
return true;
}
bool IFSG_TRANSFORM::SetScale( double aScale )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( aScale < 1e-8 && aScale > -1e-8 )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] |scale| is < 1e-8 - this seems strange";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SCENEGRAPH*)m_node)->scale = SGPOINT( aScale, aScale, aScale );
return true;
}
bool IFSG_TRANSFORM::SetTranslation( const SGPOINT& aTranslation )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SCENEGRAPH*)m_node)->translation = aTranslation;
return true;
}
bool IFSG_TRANSFORM::SetScaleOrientation( const SGVECTOR& aScaleAxis, double aAngle )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SCENEGRAPH*)m_node)->scale_axis = aScaleAxis;
((SCENEGRAPH*)m_node)->scale_angle = aAngle;
return true;
}
bool IFSG_TRANSFORM::SetCenter( const SGPOINT& aCenter )
{
if( NULL == m_node )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << BadObject;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
((SCENEGRAPH*)m_node)->center = aCenter;
return true;
}
+817
View File
@@ -0,0 +1,817 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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( NULL != aParent && S3D::SGTYPE_TRANSFORM != aParent->GetNodeType() )
{
m_Parent = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] inappropriate parent to SCENEGRAPH (type ";
ostr << aParent->GetNodeType() << ")";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
}
else if( NULL != aParent && S3D::SGTYPE_TRANSFORM == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
return;
}
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 );
return;
}
bool SCENEGRAPH::SetParent( SGNODE* aParent, bool notify )
{
if( NULL != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = NULL;
if( NULL == aParent )
return true;
}
// only a transform may be parent to a transform
if( NULL != 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( NULL == aNodeName || 0 == aNodeName[0] )
return NULL;
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 || NULL == m_Parent )
return NULL;
return m_Parent->FindNode( aNodeName, this );
}
void SCENEGRAPH::unlinkNode( const SGNODE* aNode, bool isChild )
{
if( NULL == 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;
}
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unlinkNode() did not find its target";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return;
}
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 )
{
if( NULL == aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aNode";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return 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 );
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] object '" << aNode->GetName();
ostr << "' is not a valid type for this object (" << aNode->GetNodeType() << ")";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
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);
return;
}
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( NULL == parentNode && NULL != m_Parent )
{
SGNODE* np = m_Parent;
while( NULL != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, NULL ) )
{
m_written = true;
return true;
}
return false;
}
if( parentNode != m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; parentNode != m_aParent";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( NULL == m_Parent )
{
// ensure unique node names
ResetNodeIndex();
ReNameNodes();
}
if( aFile.fail() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad stream";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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 ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad stream while writing child transforms";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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 ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad stream while writing child shapes";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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 )
{
if( !m_Transforms.empty() || !m_RTransforms.empty()
|| !m_Shape.empty() || !m_RShape.empty() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] non-empty node";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
std::string name; // name of the node
if( NULL == parentNode )
{
// we need to read the tag and verify its type
if( S3D::SGTYPE_TRANSFORM != S3D::ReadTag( aFile, name ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; tag mismatch at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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 ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; bad child transform tag at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SCENEGRAPH* sp = new SCENEGRAPH( this );
sp->SetName( name.c_str() );
if( !sp->ReadCache( aFile, this ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data while reading transform '";
ostr << name << "' pos " << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
}
// read referenced transforms
for( i = 0; i < sizeRT; ++i )
{
if( S3D::SGTYPE_TRANSFORM != S3D::ReadTag( aFile, name ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; bad ref transform tag at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* sp = FindNode( name.c_str(), this );
if( !sp )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data: cannot find ref transform '";
ostr << name << "' pos " << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( S3D::SGTYPE_TRANSFORM != sp->GetNodeType() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data: type is not TRANSFORM '";
ostr << name << "' pos " << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
AddRefNode( sp );
}
// read child shapes
for( i = 0; i < sizeCS; ++i )
{
if( S3D::SGTYPE_SHAPE != S3D::ReadTag( aFile, name ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; bad child shape tag at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGSHAPE* sp = new SGSHAPE( this );
sp->SetName( name.c_str() );
if( !sp->ReadCache( aFile, this ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data while reading shape '";
ostr << name << "' pos " << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
}
// read referenced shapes
for( i = 0; i < sizeRS; ++i )
{
if( S3D::SGTYPE_SHAPE != S3D::ReadTag( aFile, name ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; bad ref shape tag at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* sp = FindNode( name.c_str(), this );
if( !sp )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data: cannot find ref shape '";
ostr << name << "' pos " << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( S3D::SGTYPE_SHAPE != sp->GetNodeType() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data: type is not SGSHAPE '";
ostr << name << "' pos " << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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( NULL != 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;
}
+105
View File
@@ -0,0 +1,105 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines 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.
*/
#ifndef SCENE_GRAPH_H
#define SCENE_GRAPH_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
class SGSHAPE;
class SCENEGRAPH : public SGNODE
{
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
void unlinkNode( const SGNODE* aNode, bool isChild );
bool addNode( SGNODE* aNode, bool isChild );
public:
void unlinkChildNode( const SGNODE* aNode ) override;
void unlinkRefNode( const SGNODE* aNode ) override;
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
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 );
};
/*
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
+452
View File
@@ -0,0 +1,452 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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.05317, 0.17879, 0.01804 );
shininess = 0.2;
transparency = 0.0;
diffuse.SetColor( 0.8, 0.8, 0.8 );
if( NULL != aParent && S3D::SGTYPE_SHAPE != aParent->GetNodeType() )
{
m_Parent = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] inappropriate parent to SGAPPEARANCE (type ";
ostr << aParent->GetNodeType() << ")";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
}
else if( NULL != aParent && S3D::SGTYPE_SHAPE == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
return;
}
SGAPPEARANCE::~SGAPPEARANCE()
{
return;
}
bool SGAPPEARANCE::SetParent( SGNODE* aParent, bool notify )
{
if( NULL != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = NULL;
if( NULL == aParent )
return true;
}
// only a SGSHAPE may be parent to a SGAPPEARANCE
if( NULL != 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 )
{
if( NULL == aRGBColor )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aRGBColor";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
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 )
{
if( NULL == aRGBColor )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aRGBColor";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
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 )
{
if( NULL == aRGBColor )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aRGBColor";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
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 )
{
if( NULL == aRGBColor )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aRGBColor";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return ambient.SetColor( aRGBColor );
}
bool SGAPPEARANCE::SetAmbient( const SGCOLOR& aRGBColor )
{
return ambient.SetColor( aRGBColor );
}
SGNODE* SGAPPEARANCE::FindNode(const char *aNodeName, const SGNODE *aCaller)
{
if( NULL == aNodeName || 0 == aNodeName[0] )
return NULL;
if( !m_Name.compare( aNodeName ) )
return this;
return NULL;
}
void SGAPPEARANCE::unlinkChildNode( const SGNODE* aCaller )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unexpected code branch; node should have no children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
void SGAPPEARANCE::unlinkRefNode( const SGNODE* aCaller )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unexpected code branch; node should have no children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
bool SGAPPEARANCE::AddRefNode( SGNODE* aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] this node does not accept children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
bool SGAPPEARANCE::AddChildNode( SGNODE* aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] this node does not accept children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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.004 )
den = 0.004;
amb /= den;
if( amb > 1.0 )
amb = 1.0;
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( NULL == parentNode )
{
if( NULL == m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; m_aParent is NULL";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* np = m_Parent;
while( NULL != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, NULL ) )
{
m_written = true;
return true;
}
return false;
}
if( parentNode != m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; parentNode != m_aParent";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( !aFile.good() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad stream";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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;
}
+80
View File
@@ -0,0 +1,80 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines the generic material appearance of a scenegraph object
*/
#ifndef SG_APPEARANCE_H
#define SG_APPEARANCE_H
#include "3d_cache/sg/sg_node.h"
class SGAPPEARANCE : public SGNODE
{
public:
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
void unlinkChildNode( const SGNODE* aNode ) override;
void unlinkRefNode( const SGNODE* aNode ) override;
public:
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) 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;
};
#endif // SG_APPEARANCE_H
+340
View File
@@ -0,0 +1,340 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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;
return;
}
SGCOLOR::SGCOLOR( float aRVal, float aGVal, float aBVal )
{
if( !checkRange( aRVal, aGVal, aBVal ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid value passed to constructor";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
red = 0.0;
green = 0.0;
blue = 0.0;
return;
}
red = aRVal;
green = aGVal;
blue = aBVal;
return;
}
void SGCOLOR::GetColor( float& aRedVal, float& aGreenVal, float& aBlueVal ) const
{
aRedVal = red;
aGreenVal = green;
aBlueVal = blue;
return;
}
void SGCOLOR::GetColor( SGCOLOR& aColor ) const
{
aColor.red = red;
aColor.green = green;
aColor.blue = blue;
return;
}
void SGCOLOR::GetColor( SGCOLOR* aColor ) const
{
if( NULL == aColor )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aColor";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
aColor->red = red;
aColor->green = green;
aColor->blue = blue;
return;
}
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 )
{
red = aColor.red;
green = aColor.green;
blue = aColor.blue;
return true;
}
bool SGCOLOR::SetColor( const SGCOLOR* aColor )
{
if( NULL == aColor )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aColor";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
red = aColor->red;
green = aColor->green;
blue = aColor->blue;
return true;
}
bool SGCOLOR::checkRange( float aRedVal, float aGreenVal, float aBlueVal ) const
{
bool ok = true;
if( aRedVal < 0.0 || aRedVal > 1.0 )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid RED value: " << aRedVal;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
ok = false;
}
if( aGreenVal < 0.0 || aGreenVal > 1.0 )
{
#ifdef DEBUG
if( ok )
{
wxLogTrace( MASK_3D_SG, "%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__ );
}
wxLogTrace( MASK_3D_SG, " * [BUG] invalid GREEN value: %f\n", aGreenVal );
#endif
ok = false;
}
if( aBlueVal < 0.0 || aBlueVal > 1.0 )
{
#ifdef DEBUG
if( ok )
{
wxLogTrace( MASK_3D_SG, "%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__ );
}
wxLogTrace( MASK_3D_SG, " * [BUG] invalid BLUE value: %f\n", aBlueVal );
#endif
ok = false;
}
return ok;
}
SGPOINT::SGPOINT()
{
x = 0.0;
y = 0.0;
z = 0.0;
return;
}
SGPOINT::SGPOINT( double aXVal, double aYVal, double aZVal )
{
x = aXVal;
y = aYVal;
z = aZVal;
}
void SGPOINT::GetPoint( double& aXVal, double& aYVal, double& aZVal )
{
x = aXVal;
y = aYVal;
z = aZVal;
return;
}
void SGPOINT::GetPoint( SGPOINT& aPoint )
{
x = aPoint.x;
y = aPoint.y;
z = aPoint.z;
return;
}
void SGPOINT::GetPoint( SGPOINT* aPoint )
{
if( NULL == aPoint )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aPoint";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
x = aPoint->x;
y = aPoint->y;
z = aPoint->z;
return;
}
void SGPOINT::SetPoint( double aXVal, double aYVal, double aZVal )
{
x = aXVal;
y = aYVal;
z = aZVal;
return;
}
void SGPOINT::SetPoint( const SGPOINT& aPoint )
{
x = aPoint.x;
y = aPoint.y;
z = aPoint.z;
return;
}
SGVECTOR::SGVECTOR()
{
vx = 0.0;
vy = 0.0;
vz = 1.0;
return;
}
SGVECTOR::SGVECTOR( double aXVal, double aYVal, double aZVal )
{
vx = aXVal;
vy = aYVal;
vz = aZVal;
normalize();
return;
}
void SGVECTOR::GetVector( double& aXVal, double& aYVal, double& aZVal ) const
{
aXVal = vx;
aYVal = vy;
aZVal = vz;
return;
}
void SGVECTOR::SetVector( double aXVal, double aYVal, double aZVal )
{
vx = aXVal;
vy = aYVal;
vz = aZVal;
normalize();
return;
}
void SGVECTOR::SetVector( const SGVECTOR& aVector )
{
aVector.GetVector( vx, vy, vz );
return;
}
void SGVECTOR::normalize( void )
{
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;
return;
}
SGVECTOR& SGVECTOR::operator=( const SGVECTOR& source )
{
vx = source.vx;
vy = source.vy;
vz = source.vz;
return *this;
}
+367
View File
@@ -0,0 +1,367 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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( NULL != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
{
m_Parent = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] inappropriate parent to SGCOLORS (type ";
ostr << aParent->GetNodeType() << ")";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
}
else if( NULL != aParent && S3D::SGTYPE_FACESET == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
return;
}
SGCOLORS::~SGCOLORS()
{
colors.clear();
return;
}
bool SGCOLORS::SetParent( SGNODE* aParent, bool notify )
{
if( NULL != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = NULL;
if( NULL == aParent )
return true;
}
// only a SGFACESET may be parent to a SGCOLORS
if( NULL != 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)
{
if( NULL == aNodeName || 0 == aNodeName[0] )
return NULL;
if( !m_Name.compare( aNodeName ) )
return this;
return NULL;
}
void SGCOLORS::unlinkChildNode( const SGNODE* aCaller )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unexpected code branch; node should have no children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
void SGCOLORS::unlinkRefNode( const SGNODE* aCaller )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unexpected code branch; node should have no children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
bool SGCOLORS::AddRefNode( SGNODE* aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] this node does not accept children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
bool SGCOLORS::AddChildNode( SGNODE* aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] this node does not accept children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
bool SGCOLORS::GetColorList( size_t& aListSize, SGCOLOR*& aColorList )
{
if( colors.empty() )
{
aListSize = 0;
aColorList = NULL;
return false;
}
aListSize = colors.size();
aColorList = &colors[0];
return true;
}
void SGCOLORS::SetColorList( size_t aListSize, const SGCOLOR* aColorList )
{
colors.clear();
if( 0 == aListSize || NULL == 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.push_back( SGCOLOR( 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( NULL == parentNode )
{
if( NULL == m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; m_aParent is NULL";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* np = m_Parent;
while( NULL != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, NULL ) )
{
m_written = true;
return true;
}
return false;
}
if( parentNode != m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; parentNode != m_aParent";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( !aFile.good() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad stream";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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 )
{
if( !colors.empty() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] non-empty node";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return 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;
}
+65
View File
@@ -0,0 +1,65 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines an RGB color set for a scenegraph object
*/
#ifndef SG_COLORS_H
#define SG_COLORS_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
class SGCOLORS : public SGNODE
{
public:
std::vector< SGCOLOR > colors;
void unlinkChildNode( const SGNODE* aNode ) override;
void unlinkRefNode( const SGNODE* aNode ) override;
public:
SGCOLORS( SGNODE* aParent );
virtual ~SGCOLORS();
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 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;
};
#endif // SG_COLORS_H
+54
View File
@@ -0,0 +1,54 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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( NULL != aParent && S3D::SGTYPE_FACESET == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
return;
}
SGCOORDINDEX::~SGCOORDINDEX()
{
return;
}
void SGCOORDINDEX::GatherCoordIndices( std::vector< int >& aIndexList )
{
if( index.empty() )
return;
aIndexList.insert( aIndexList.end(), index.begin(), index.end() );
return;
}
+58
View File
@@ -0,0 +1,58 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines an coordinate index set for a scenegraph object
*/
#ifndef SG_COORDINDEX_H
#define SG_COORDINDEX_H
#include "3d_cache/sg/sg_index.h"
/**
* Class SGCOORDINDEX
* is a class which maintains 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();
/**
* Function GatherCoordIndices
* adds all coordinate indices to the given list
* in preparation for a normals calculation
*/
void GatherCoordIndices( std::vector< int >& aIndexList );
};
#endif // SG_COORDINDEX_H
+431
View File
@@ -0,0 +1,431 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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( NULL != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
{
m_Parent = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] inappropriate parent to SGCOORDS (type ";
ostr << aParent->GetNodeType() << ")";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
}
else if( NULL != aParent && S3D::SGTYPE_FACESET == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
return;
}
SGCOORDS::~SGCOORDS()
{
coords.clear();
return;
}
bool SGCOORDS::SetParent( SGNODE* aParent, bool notify )
{
if( NULL != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = NULL;
if( NULL == aParent )
return true;
}
// only a SGFACESET may be parent to a SGCOORDS
if( NULL != 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)
{
if( NULL == aNodeName || 0 == aNodeName[0] )
return NULL;
if( !m_Name.compare( aNodeName ) )
return this;
return NULL;
}
void SGCOORDS::unlinkChildNode( const SGNODE* aCaller )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unexpected code branch; node should have no children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
void SGCOORDS::unlinkRefNode( const SGNODE* aCaller )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unexpected code branch; node should have no children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
bool SGCOORDS::AddRefNode( SGNODE* aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] this node does not accept children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
bool SGCOORDS::AddChildNode( SGNODE* aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] this node does not accept children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
bool SGCOORDS::GetCoordsList( size_t& aListSize, SGPOINT*& aCoordsList )
{
if( coords.empty() )
{
aListSize = 0;
aCoordsList = NULL;
return false;
}
aListSize = coords.size();
aCoordsList = &coords[0];
return true;
}
void SGCOORDS::SetCoordsList( size_t aListSize, const SGPOINT* aCoordsList )
{
coords.clear();
if( 0 == aListSize || NULL == aCoordsList )
return;
for( size_t i = 0; i < aListSize; ++i )
coords.push_back( aCoordsList[i] );
return;
}
void SGCOORDS::AddCoord( double aXValue, double aYValue, double aZValue )
{
coords.push_back( SGPOINT( aXValue, aYValue, aZValue ) );
return;
}
void SGCOORDS::AddCoord( const SGPOINT& aPoint )
{
coords.push_back( aPoint );
return;
}
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( NULL == parentNode )
{
if( NULL == m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; m_aParent is NULL";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* np = m_Parent;
while( NULL != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, NULL ) )
{
m_written = true;
return true;
}
return false;
}
if( parentNode != m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; parentNode != m_aParent";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( !aFile.good() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad stream";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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 )
{
if( !coords.empty() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] non-empty node";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return 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 = NULL;
if( NULL == m_Parent || NULL == callingNode )
return false;
// the parent and all references must have indices; collect all
// indices into one std::vector<>
std::vector< int > ilist;
SGNORMALS* np = NULL;
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;
}
+74
View File
@@ -0,0 +1,74 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines a vertex coordinate set for a scenegraph object
*/
#ifndef SG_COORDS_H
#define SG_COORDS_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
class SGFACESET;
class SGCOORDS : public SGNODE
{
public:
std::vector< SGPOINT > coords;
void unlinkChildNode( const SGNODE* aNode ) override;
void unlinkRefNode( const SGNODE* aNode ) override;
public:
SGCOORDS( SGNODE* aParent );
virtual ~SGCOORDS();
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 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 );
/**
* Function CalcNormals
* calculates normals for this coordinate list and sets the
* normals list in the parent SGFACESET
*/
bool CalcNormals( SGFACESET* callingNode, SGNODE** aPtr = NULL );
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;
};
#endif // SG_COORDS_H
File diff suppressed because it is too large Load Diff
+114
View File
@@ -0,0 +1,114 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines an indexed face set for a scenegraph
*/
#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;
class SGFACESET : public SGNODE
{
private:
bool valid;
bool validated;
void unlinkNode( const SGNODE* aNode, bool isChild );
bool addNode( SGNODE* aNode, bool isChild );
public:
// 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;
void unlinkChildNode( const SGNODE* aNode ) override;
void unlinkRefNode( const SGNODE* aNode ) override;
// validate the data held by this face set
bool validate( void );
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;
/**
* Function GatherCoordIndices
* adds all internal coordinate indices to the given list
* in preparation for a normals calculation
*/
void GatherCoordIndices( std::vector< int >& aIndexList );
};
/*
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
+539
View File
@@ -0,0 +1,539 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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"
// formats a floating point number for text output to a VRML file
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 );
return;
}
// format orientation data for VRML output
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 );
return;
}
// format point data for VRML output
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 );
return;
}
// format vector data for VRML output
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 );
return;
}
// format Color data for VRML output
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 );
return;
}
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 )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; missing left bracket at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return S3D::SGTYPE_END;
}
std::string name;
aFile.get( schar );
while( ']' != schar && aFile.good() )
{
name.push_back( schar );
aFile.get( schar );
}
if( schar != ']' )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; could not find right bracket";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return S3D::SGTYPE_END;
}
aName = name;
size_t upos = name.find( '_' );
if( std::string::npos == upos )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; no underscore in name '";
ostr << name << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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];
}
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; no node type matching '";
ostr << name << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
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 )
{
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] );
return;
}
bool S3D::CalcTriangleNormals( std::vector< SGPOINT > coords,
std::vector< int >& index, std::vector< SGVECTOR >& norms )
{
size_t vsize = coords.size();
if( vsize < 3 )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] invalid vertex set (fewer than 3 vertices)";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
size_t isize = index.size();
if( 0 != isize % 3 || index.empty() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] invalid index set (not multiple of 3)";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( !norms.empty() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] normals set is not empty";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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, "%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.insert( std::pair < int, std::list < glm::dvec3 > >
( p1, std::list < glm::dvec3 >( 1, tri ) ) );
}
ip = vmap.find( p2 );
if( ip != vmap.end() )
{
ip->second.push_back( tri );
}
else
{
vmap.insert( std::pair < int, std::list < glm::dvec3 > >
( p2, std::list < glm::dvec3 >( 1, tri ) ) );
}
ip = vmap.find( p3 );
if( ip != vmap.end() )
{
ip->second.push_back( tri );
}
else
{
vmap.insert( std::pair < int, std::list < glm::dvec3 > >
( 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.push_back( SGVECTOR( 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.push_back( SGVECTOR( norm.x, norm.y, norm.z ) );
++idx;
++sM;
}
if( norms.size() != coords.size() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] number of normals does not equal number of vertices";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
return true;
}
+247
View File
@@ -0,0 +1,247 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines a number of macro functions 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( NULL, 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( NULL != 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( NULL == 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 = NULL; \
while( sLA != eLA ) { \
if( (SGNODE*)*sLA != aCallingNode ) { \
psg = (SGNODE*) (*sLA)->FindNode( aName, this ); \
if( NULL != psg) \
return psg; \
} \
++sLA; \
} } while ( 0 )
namespace S3D
{
bool degenerate( glm::dvec3* pts );
//
// Normals calculations from triangles
//
/*
* Function CalcTriangleNormals
* takes 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:
* (a) 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.
* (b) 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 );
//
// VRML related functions
//
// 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 );
//
// Cache related READ functions
//
/**
* Function ReadTag
* reads 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
+398
View File
@@ -0,0 +1,398 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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( NULL != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
{
m_Parent = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] inappropriate parent to SGINDEX (type ";
ostr << aParent->GetNodeType() << ")";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
}
return;
}
SGINDEX::~SGINDEX()
{
index.clear();
return;
}
bool SGINDEX::SetParent( SGNODE* aParent, bool notify )
{
if( NULL != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = NULL;
if( NULL == aParent )
return true;
}
// only a SGFACESET may be parent to a SGINDEX and derived types
if( NULL != 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)
{
if( NULL == aNodeName || 0 == aNodeName[0] )
return NULL;
if( !m_Name.compare( aNodeName ) )
return this;
return NULL;
}
void SGINDEX::unlinkChildNode( const SGNODE* aCaller )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unexpected code branch; node should have no children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
void SGINDEX::unlinkRefNode( const SGNODE* aCaller )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unexpected code branch; node should have no children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
bool SGINDEX::AddRefNode( SGNODE* aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] this node does not accept children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
bool SGINDEX::AddChildNode( SGNODE* aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] this node does not accept children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
bool SGINDEX::GetIndices( size_t& nIndices, int*& aIndexList )
{
if( index.empty() )
{
nIndices = 0;
aIndexList = NULL;
return false;
}
nIndices = index.size();
aIndexList = & index[0];
return true;
}
void SGINDEX::SetIndices( size_t nIndices, int* aIndexList )
{
index.clear();
if( 0 == nIndices || NULL == 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 );
return;
}
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();
if( n % 3 )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] coord index is not divisible by three (violates triangle constraint)";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
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( NULL == parentNode )
{
if( NULL == m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; m_aParent is NULL";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* np = m_Parent;
while( NULL != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, NULL ) )
{
m_written = true;
return true;
}
return false;
}
if( parentNode != m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; parentNode != m_aParent";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( !aFile.good() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad stream";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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 )
{
if( !index.empty() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] non-empty node";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return 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;
}
+97
View File
@@ -0,0 +1,97 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines a generic Index interface for a scenegraph object
*/
#ifndef SG_INDEX_H
#define SG_INDEX_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
class SGINDEX : public SGNODE
{
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;
void unlinkChildNode( const SGNODE* aCaller ) override;
void unlinkRefNode( const SGNODE* aCaller ) override;
public:
SGINDEX( SGNODE* aParent );
virtual ~SGINDEX();
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;
/**
* Function GetIndices
* retrieves 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 [out] will hold the number of indices in the list
* @param aIndexList [out] 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 );
/**
* Function SetIndices
* sets the number of indices and creates a copy of the given index data.
*
* @param nIndices [in] the number of indices to be stored
* @param aIndexList [in] the index data
*/
void SetIndices( size_t nIndices, int* aIndexList );
/**
* Function AddIndex
* adds 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;
};
#endif // SG_INDEX_H
+442
View File
@@ -0,0 +1,442 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 )
{
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();
return;
}
SGNODE::SGNODE( SGNODE* aParent )
{
m_Parent = aParent;
m_Association = NULL;
m_written = false;
m_SGtype = S3D::SGTYPE_END;
return;
}
SGNODE::~SGNODE()
{
if( m_Parent )
m_Parent->unlinkChildNode( this );
if( m_Association )
*m_Association = NULL;
std::list< SGNODE* >::iterator sBP = m_BackPointers.begin();
std::list< SGNODE* >::iterator eBP = m_BackPointers.end();
while( sBP != eBP )
{
(*sBP)->unlinkRefNode( this );
++sBP;
}
return;
}
S3D::SGTYPES SGNODE::GetNodeType( void ) const
{
return m_SGtype;
}
SGNODE* SGNODE::GetParent( void ) const
{
return m_Parent;
}
bool SGNODE::SwapParent( SGNODE* aNewParent )
{
if( aNewParent == m_Parent )
return true;
if( NULL == aNewParent )
return false;
if( NULL == 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 = NULL;
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( NULL == aName || 0 == aName[0] )
getNodeName( m_SGtype, m_Name );
else
m_Name = aName;
return;
}
const char * SGNODE::GetNodeTypeName( S3D::SGTYPES aNodeType ) const
{
return node_names[aNodeType].c_str();
}
void SGNODE::addNodeRef( SGNODE* aNode )
{
if( NULL == 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 );
return;
}
void SGNODE::delNodeRef( const SGNODE* aNode )
{
if( NULL == 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;
}
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] delNodeRef() did not find its target\n";
ostr << " * This Node Type: " << m_SGtype << ", Referenced node type: ";
ostr << aNode->GetNodeType() << "\n";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
void SGNODE::AssociateWrapper( SGNODE** aWrapperRef )
{
if( NULL == aWrapperRef )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL handle";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
if( *aWrapperRef != this )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] handle value does not match this object's pointer";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
// 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 = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [WARNING] association being broken with previous wrapper";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
}
m_Association = aWrapperRef;
return;
}
void SGNODE::DisassociateWrapper( SGNODE** aWrapperRef )
{
if( !m_Association )
return;
if( !aWrapperRef )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] invalid handle value aWrapperRef";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
if( *aWrapperRef != *m_Association || aWrapperRef != m_Association )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] *aWrapperRef (" << *aWrapperRef;
ostr << ") does not match *m_Association (" << *m_Association << ") in type ";
ostr << node_names[ m_SGtype] << "\n";
ostr << " * [INFO] OR aWrapperRef(" << aWrapperRef << ") != m_Association(";
ostr << m_Association << ")\n";
ostr << " * [INFO] node name: " << GetName();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
m_Association = NULL;
return;
}
void SGNODE::ResetNodeIndex( void )
{
for( int i = 0; i < (int)S3D::SGTYPE_END; ++i )
node_counts[i] = 1;
return;
}
bool S3D::GetMatIndex( MATLIST& aList, SGNODE* aNode, int& aIndex )
{
aIndex = 0;
if( NULL == aNode || S3D::SGTYPE_APPEARANCE != aNode->GetNodeType() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
ostr.str( "" );
if( NULL == aNode )
{
wxLogTrace( MASK_3D_SG, " * [BUG] aNode is NULL\n" );
}
else
{
ostr << " * [BUG] invalid node type (" << aNode->GetNodeType();
ostr << "), expected " << S3D::SGTYPE_APPEARANCE;
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
}
#endif
return 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.insert( std::pair< SGAPPEARANCE const*, int >( node, idx ) );
aIndex = idx;
return true;
}
void S3D::INIT_SMATERIAL( SMATERIAL& aMaterial )
{
memset( &aMaterial, 0, sizeof( aMaterial ) );
return;
}
void S3D::INIT_SMESH( SMESH& aMesh )
{
memset( &aMesh, 0, sizeof( aMesh ) );
return;
}
void S3D::INIT_S3DMODEL( S3DMODEL& aModel )
{
memset( &aModel, 0, sizeof( aModel ) );
return;
}
void S3D::FREE_SMESH( SMESH& aMesh)
{
if( NULL != aMesh.m_Positions )
{
delete [] aMesh.m_Positions;
aMesh.m_Positions = NULL;
}
if( NULL != aMesh.m_Normals )
{
delete [] aMesh.m_Normals;
aMesh.m_Normals = NULL;
}
if( NULL != aMesh.m_Texcoords )
{
delete [] aMesh.m_Texcoords;
aMesh.m_Texcoords = NULL;
}
if( NULL != aMesh.m_Color )
{
delete [] aMesh.m_Color;
aMesh.m_Color = NULL;
}
if( NULL != aMesh.m_FaceIdx )
{
delete [] aMesh.m_FaceIdx;
aMesh.m_FaceIdx = NULL;
}
aMesh.m_VertexSize = 0;
aMesh.m_FaceIdxSize = 0;
aMesh.m_MaterialIdx = 0;
return;
}
void S3D::FREE_S3DMODEL( S3DMODEL& aModel )
{
if( NULL != aModel.m_Materials )
{
delete [] aModel.m_Materials;
aModel.m_Materials = NULL;
}
aModel.m_MaterialsSize = 0;
if( NULL != 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 = NULL;
}
aModel.m_MeshesSize = 0;
return;
}
+250
View File
@@ -0,0 +1,250 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines the base class of the intermediate scene graph NODE
*/
#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
{
/**
* Function GetNodeTypeName
* returns the name of the given type of node
*/
char const* GetNodeTypeName( S3D::SGTYPES aType );
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 );
void INIT_S3DMODEL( S3DMODEL& aModel );
void FREE_SMESH( SMESH& aMesh);
void FREE_S3DMODEL( S3DMODEL& aModel );
}
/**
* Class SGNODE
* represents the base class of all Scene Graph nodes
*/
class SGNODE
{
private:
SGNODE** m_Association; // handle to the instance held by a wrapper
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 SG node
std::string m_Name; // name to use for referencing the entity by name
bool m_written; // set true when the object has been written after a ReNameNodes()
public:
/**
* Function unlinkChild
* removes references to an owned child; it 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;
/**
* Function unlinkRef
* removes pointers to a referenced node; it 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;
/**
* Function addNodeRef
* adds a pointer to a node which references, but does not own, this node.
* 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 );
/**
* Function delNodeRef
* removes a pointer to a node which references, but does not own, this node.
*
* @param aNode is the node holding a reference to this object
*/
void delNodeRef( const SGNODE* aNode );
/**
* Function IsWritten
* returns true if the object had already been written to a
* cache file or VRML file; for internal use only.
*/
bool isWritten( void )
{
return m_written;
}
public:
SGNODE( SGNODE* aParent );
virtual ~SGNODE();
/**
* Function GetNodeType
* returns the type of this node instance
*/
S3D::SGTYPES GetNodeType( void ) const;
/**
* Function GetParent
* 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;
/**
* Function SetParent
* sets 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;
/**
* Function SwapParent
* swaps the ownership with the given parent. This operation
* may be required when reordering nodes for optimization.
*
* @param aNewParent [in] 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;
/**
* Function FindNode searches the tree of linked nodes and returns 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;
/**
* Function AssociateWrapper
* associates this object with a handle to itself; this 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 );
/**
* Function DisassociateWrapper
* removes the association between an IFSG* wrapper
* object and this object.
*/
void DisassociateWrapper( SGNODE** aWrapperRef );
/**
* Function ResetNodeIndex
* resets the global SG* node indices in preparation for
* Write() operations
*/
void ResetNodeIndex( void );
/**
* Function ReNameNodes
* renames a node and all its child nodes in preparation for
* Write() operations
*/
virtual void ReNameNodes( void ) = 0;
/**
* Function WriteVRML
* 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;
/**
* Function WriteCache
* write's 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;
/**
* Function ReadCache
* 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;
};
#endif // SG_NODE_H
+366
View File
@@ -0,0 +1,366 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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( NULL != aParent && S3D::SGTYPE_FACESET != aParent->GetNodeType() )
{
m_Parent = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] inappropriate parent to SGNORMALS (type ";
ostr << aParent->GetNodeType() << ")";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
}
else if( NULL != aParent && S3D::SGTYPE_FACESET == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
return;
}
SGNORMALS::~SGNORMALS()
{
norms.clear();
return;
}
bool SGNORMALS::SetParent( SGNODE* aParent, bool notify )
{
if( NULL != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = NULL;
if( NULL == aParent )
return true;
}
// only a SGFACESET may be parent to a SGNORMALS
if( NULL != 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)
{
if( NULL == aNodeName || 0 == aNodeName[0] )
return NULL;
if( !m_Name.compare( aNodeName ) )
return this;
return NULL;
}
void SGNORMALS::unlinkChildNode( const SGNODE* aCaller )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unexpected code branch; node should have no children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
void SGNORMALS::unlinkRefNode( const SGNODE* aCaller )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unexpected code branch; node should have no children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return;
}
bool SGNORMALS::AddRefNode( SGNODE* aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] this node does not accept children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
bool SGNORMALS::AddChildNode( SGNODE* aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] this node does not accept children or refs";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
bool SGNORMALS::GetNormalList( size_t& aListSize, SGVECTOR*& aNormalList )
{
if( norms.empty() )
{
aListSize = 0;
aNormalList = NULL;
return false;
}
aListSize = norms.size();
aNormalList = &norms[0];
return true;
}
void SGNORMALS::SetNormalList( size_t aListSize, const SGVECTOR* aNormalList )
{
norms.clear();
if( 0 == aListSize || NULL == aNormalList )
return;
for( int i = 0; i < (int)aListSize; ++i )
norms.push_back( aNormalList[i] );
return;
}
void SGNORMALS::AddNormal( double aXValue, double aYValue, double aZValue )
{
norms.push_back( SGVECTOR( aXValue, aYValue, aZValue ) );
return;
}
void SGNORMALS::AddNormal( const SGVECTOR& aNormal )
{
norms.push_back( aNormal );
return;
}
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( NULL == parentNode )
{
if( NULL == m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; m_aParent is NULL";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* np = m_Parent;
while( NULL != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, NULL ) )
{
m_written = true;
return true;
}
return false;
}
if( parentNode != m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; parentNode != m_aParent";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( !aFile.good() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad stream";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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 )
{
if( !norms.empty() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] non-empty node";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return 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;
}
+65
View File
@@ -0,0 +1,65 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines a set of vertex normals for a scene graph object
*/
#ifndef SG_NORMALS_H
#define SG_NORMALS_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
class SGNORMALS : public SGNODE
{
public:
std::vector< SGVECTOR > norms;
void unlinkChildNode( const SGNODE* aNode ) override;
void unlinkRefNode( const SGNODE* aNode ) override;
public:
SGNORMALS( SGNODE* aParent );
virtual ~SGNORMALS();
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 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;
};
#endif // SG_NORMALS_H
+900
View File
@@ -0,0 +1,900 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 = NULL;
m_RAppearance = NULL;
m_FaceSet = NULL;
m_RFaceSet = NULL;
if( NULL != aParent && S3D::SGTYPE_TRANSFORM != aParent->GetNodeType() )
{
m_Parent = NULL;
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] inappropriate parent to SGSHAPE (type ";
ostr << aParent->GetNodeType() << ")";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
}
else if( NULL != aParent && S3D::SGTYPE_TRANSFORM == aParent->GetNodeType() )
{
m_Parent->AddChildNode( this );
}
return;
}
SGSHAPE::~SGSHAPE()
{
// drop references
if( m_RAppearance )
{
m_RAppearance->delNodeRef( this );
m_RAppearance = NULL;
}
if( m_RFaceSet )
{
m_RFaceSet->delNodeRef( this );
m_RFaceSet = NULL;
}
// delete objects
if( m_Appearance )
{
m_Appearance->SetParent( NULL, false );
delete m_Appearance;
m_Appearance = NULL;
}
if( m_FaceSet )
{
m_FaceSet->SetParent( NULL, false );
delete m_FaceSet;
m_FaceSet = NULL;
}
return;
}
bool SGSHAPE::SetParent( SGNODE* aParent, bool notify )
{
if( NULL != m_Parent )
{
if( aParent == m_Parent )
return true;
// handle the change in parents
if( notify )
m_Parent->unlinkChildNode( this );
m_Parent = NULL;
if( NULL == aParent )
return true;
}
// only a SGTRANSFORM may be parent to a SGSHAPE
if( NULL != 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( NULL == aNodeName || 0 == aNodeName[0] )
return NULL;
if( !m_Name.compare( aNodeName ) )
return this;
SGNODE* tmp = NULL;
if( NULL != m_Appearance )
{
tmp = m_Appearance->FindNode( aNodeName, this );
if( tmp )
{
return tmp;
}
}
if( NULL != m_FaceSet )
{
tmp = m_FaceSet->FindNode( aNodeName, this );
if( tmp )
{
return tmp;
}
}
// query the parent if appropriate
if( aCaller == m_Parent || NULL == m_Parent )
return NULL;
return m_Parent->FindNode( aNodeName, this );
}
void SGSHAPE::unlinkNode( const SGNODE* aNode, bool isChild )
{
if( NULL == aNode )
return;
if( isChild )
{
if( aNode == m_Appearance )
{
m_Appearance = NULL;
return;
}
if( aNode == m_FaceSet )
{
m_FaceSet = NULL;
return;
}
}
else
{
if( aNode == m_RAppearance )
{
delNodeRef( this );
m_RAppearance = NULL;
return;
}
if( aNode == m_RFaceSet )
{
delNodeRef( this );
m_RFaceSet = NULL;
return;
}
}
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] unlinkNode() did not find its target";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
return;
}
void SGSHAPE::unlinkChildNode( const SGNODE* aNode )
{
unlinkNode( aNode, true );
return;
}
void SGSHAPE::unlinkRefNode( const SGNODE* aNode )
{
unlinkNode( aNode, false );
return;
}
bool SGSHAPE::addNode( SGNODE* aNode, bool isChild )
{
if( NULL == aNode )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] NULL pointer passed for aNode";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( S3D::SGTYPE_APPEARANCE == aNode->GetNodeType() )
{
if( m_Appearance || m_RAppearance )
{
if( aNode != m_Appearance && aNode != m_RAppearance )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] assigning multiple Appearance nodes";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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 )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] assigning multiple FaceSet nodes";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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;
}
#ifdef DEBUG
do {
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] object '" << aNode->GetName();
ostr << "' is not a valid type for this object (" << aNode->GetNodeType() << ")";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
} while( 0 );
#endif
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();
return;
}
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( NULL == parentNode )
{
if( NULL == m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; m_aParent is NULL";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* np = m_Parent;
while( NULL != np->GetParent() )
np = np->GetParent();
if( np->WriteCache( aFile, NULL ) )
{
m_written = true;
return true;
}
return false;
}
if( parentNode != m_Parent )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] corrupt data; parentNode != m_aParent";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( !aFile.good() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad stream";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
// check if any references are unwritten and swap parents if so
if( NULL != m_RAppearance && !m_RAppearance->isWritten() )
m_RAppearance->SwapParent(this);
if( NULL != 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( NULL != m_Appearance )
items[i] = true;
++i;
if( NULL != m_RAppearance )
items[i] = true;
++i;
if( NULL != m_FaceSet )
items[i] = true;
++i;
if( NULL != 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 )
{
if( m_Appearance || m_RAppearance || m_FaceSet || m_RFaceSet )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [BUG] non-empty node";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return 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] ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; multiple item definitions at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
std::string name;
if( items[0] )
{
if( S3D::SGTYPE_APPEARANCE != S3D::ReadTag( aFile, name ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; bad child apperance tag at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
m_Appearance = new SGAPPEARANCE( this );
m_Appearance->SetName( name.c_str() );
if( !m_Appearance->ReadCache( aFile, this ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data while reading appearance '";
ostr << name << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
}
if( items[1] )
{
if( S3D::SGTYPE_APPEARANCE != S3D::ReadTag( aFile, name ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; bad ref appearance tag at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* np = FindNode( name.c_str(), this );
if( !np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data: cannot find ref appearance '";
ostr << name << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( S3D::SGTYPE_APPEARANCE != np->GetNodeType() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data: type is not SGAPPEARANCE '";
ostr << name << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
m_RAppearance = (SGAPPEARANCE*)np;
m_RAppearance->addNodeRef( this );
}
if( items[2] )
{
if( S3D::SGTYPE_FACESET != S3D::ReadTag( aFile, name ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; bad child face set tag at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
m_FaceSet = new SGFACESET( this );
m_FaceSet->SetName( name.c_str() );
if( !m_FaceSet->ReadCache( aFile, this ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data while reading face set '";
ostr << name << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
}
if( items[3] )
{
if( S3D::SGTYPE_FACESET != S3D::ReadTag( aFile, name ) )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data; bad ref face set tag at position ";
ostr << aFile.tellg();
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
SGNODE* np = FindNode( name.c_str(), this );
if( !np )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data: cannot find ref face set '";
ostr << name << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return false;
}
if( S3D::SGTYPE_FACESET != np->GetNodeType() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] corrupt data: type is not SGFACESET '";
ostr << name << "'";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
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( NULL == pa )
pa = m_RAppearance;
if( NULL == pf )
pf = m_RFaceSet;
// no face sets = nothing to render, which is valid though pointless
if( NULL == pf )
return true;
if( !pf->validate() )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad model; inconsistent data";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return true;
}
if( NULL == 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( NULL == pc )
pc = pf->m_RColors;
if( NULL == pv )
pv = pf->m_RCoords;
if( NULL == pn )
pn = pf->m_RNormals;
// set the vertex points and indices
size_t nCoords = 0;
SGPOINT* pCoords = NULL;
pv->GetCoordsList( nCoords, pCoords );
size_t nColors = 0;
SGCOLOR* pColors = NULL;
if( pc )
{
// check the vertex colors
pc->GetColorList( nColors, pColors );
if( nColors < nCoords )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad model; not enough colors per vertex (";
ostr << nColors << " vs " << nCoords << ")";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return true;
}
}
// set the vertex indices
size_t nvidx = 0;
int* lv = NULL;
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.insert( std::pair< int, unsigned int >( lv[i], vertices.size() ) );
vertices.push_back( lv[i] );
}
}
if( vertices.size() < 3 )
{
#ifdef DEBUG
std::ostringstream ostr;
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
ostr << " * [INFO] bad model; not enough vertices";
wxLogTrace( MASK_3D_SG, "%s\n", ostr.str().c_str() );
#endif
return true;
}
// construct the final vertex/color list
SFVEC3F* lColors = NULL;
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 = NULL;
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;
}
+85
View File
@@ -0,0 +1,85 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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
* defines a complex 3D shape for a scenegraph object
*/
#ifndef SG_SHAPE_H
#define SG_SHAPE_H
#include <vector>
#include "3d_cache/sg/sg_node.h"
class SGAPPEARANCE;
class SGFACESET;
class SGSHAPE : public SGNODE
{
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;
void unlinkChildNode( const SGNODE* aNode ) override;
void unlinkRefNode( const SGNODE* aNode ) override;
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 );
};
/*
p.107
Shape {
appearance NULL
geometry NULL
}
*/
#endif // SG_SHAPE_H
+87
View File
@@ -0,0 +1,87 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
*
* 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 str_rsort.h
* provides a wxString sorting functino which works from the
* end of the string towards the beginning
*/
#ifndef STR_RSORT_H
#define STR_RSORT_H
#include <wx/string.h>
namespace S3D
{
struct rsort_wxString
{
bool operator() (const wxString& strA, const wxString& strB ) const
{
// sort a wxString using the reverse character order; for 3d model
// filenames this will typically be a much faster operation than
// a normal alphabetic sort
wxString::const_reverse_iterator sA = strA.rbegin();
wxString::const_reverse_iterator eA = strA.rend();
wxString::const_reverse_iterator sB = strB.rbegin();
wxString::const_reverse_iterator eB = strB.rend();
if( strA.empty() )
{
if( strB.empty() )
return false;
// note: this rule implies that a null string is first in the sort order
return true;
}
if( strB.empty() )
return false;
while( sA != eA && sB != eB )
{
if( (*sA) == (*sB) )
{
++sA;
++sB;
continue;
}
if( (*sA) < (*sB) )
return true;
else
return false;
}
if( sB == eB )
return false;
return true;
}
};
} // end NAMESPACE
#endif // STR_RSORT_H
-727
View File
@@ -1,727 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2014 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_canvas.cpp
*/
#include <fctsys.h>
#include <trigo.h>
#include <project.h>
#include <gestfich.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>
#ifdef __WINDOWS__
#include <GL/glew.h> // must be included before gl.h
#endif
#include <3d_viewer.h>
#include <3d_canvas.h>
#include <info3d_visu.h>
#include <trackball.h>
#include <3d_viewer_id.h>
#include <textures/text_silk.h>
#include <textures/text_pcb.h>
/*
* 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 )
#ifdef USE_OSX_MAGNIFY_EVENT
EVT_MAGNIFY( EDA_3D_CANVAS::OnMagnify )
#endif
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()
// Define an invalid value for some unsigned int indexes
#define INVALID_INDEX GL_INVALID_VALUE
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;
m_reportWarnings = true;
m_shadow_init = false;
// set an invalide value to not yet initialized indexes managing
// textures created to enhance 3D rendering
m_text_pcb = m_text_silk = INVALID_INDEX;
m_text_fake_shadow_front = INVALID_INDEX;
m_text_fake_shadow_back = INVALID_INDEX;
m_text_fake_shadow_board = INVALID_INDEX;
// position of the front and back layers
// (will be initialized to a better value later)
m_ZBottom = 0.0;
m_ZTop = 0.0;
m_lightPos = S3D_VERTEX(0.0f, 0.0f, 30.0f);
// 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;
// Free the list of parsers list
for( unsigned int i = 0; i < m_model_parsers_list.size(); i++ )
if( m_model_parsers_list[i] )
delete m_model_parsers_list[i];
}
void EDA_3D_CANVAS::ClearLists( int 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;
}
// When m_text_fake_shadow_??? is set to INVALID_INDEX, textures are no yet
// created.
if( m_text_fake_shadow_front != INVALID_INDEX )
glDeleteTextures( 1, &m_text_fake_shadow_front );
if( m_text_fake_shadow_back != INVALID_INDEX )
glDeleteTextures( 1, &m_text_fake_shadow_back );
if( m_text_fake_shadow_board != INVALID_INDEX )
glDeleteTextures( 1, &m_text_fake_shadow_board );
m_shadow_init = false;
}
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 * GetPrm3DVisu().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:
GetPrm3DVisu().m_Zoom = 1.0;
m_draw3dOffset.x = m_draw3dOffset.y = 0;
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
break;
case WXK_END:
break;
case WXK_F1:
GetPrm3DVisu().m_Zoom /= 1.4;
if( GetPrm3DVisu().m_Zoom <= 0.01 )
GetPrm3DVisu().m_Zoom = 0.01;
break;
case WXK_F2:
GetPrm3DVisu().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++ )
GetPrm3DVisu().m_Rot[ii] = 0.0;
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
break;
case 'x':
for( ii = 0; ii < 4; ii++ )
GetPrm3DVisu().m_Rot[ii] = 0.0;
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
GetPrm3DVisu().m_ROTZ = -90;
GetPrm3DVisu().m_ROTX = -90;
break;
case 'X':
for( ii = 0; ii < 4; ii++ )
GetPrm3DVisu().m_Rot[ii] = 0.0;
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
GetPrm3DVisu().m_ROTZ = 90;
GetPrm3DVisu().m_ROTX = -90;
break;
case 'y':
for( ii = 0; ii < 4; ii++ )
GetPrm3DVisu().m_Rot[ii] = 0.0;
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
GetPrm3DVisu().m_ROTX = -90;
break;
case 'Y':
for( ii = 0; ii < 4; ii++ )
GetPrm3DVisu().m_Rot[ii] = 0.0;
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
GetPrm3DVisu().m_ROTX = -90;
GetPrm3DVisu().m_ROTZ = -180;
break;
case 'z':
for( ii = 0; ii < 4; ii++ )
GetPrm3DVisu().m_Rot[ii] = 0.0;
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
break;
case 'Z':
for( ii = 0; ii < 4; ii++ )
GetPrm3DVisu().m_Rot[ii] = 0.0;
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
GetPrm3DVisu().m_ROTX = -180;
break;
default:
return;
}
DisplayStatus();
Refresh( false );
}
void EDA_3D_CANVAS::OnMouseWheel( wxMouseEvent& event )
{
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
{
if( event.GetWheelRotation() > 0 )
{
GetPrm3DVisu().m_Zoom /= 1.4;
if( GetPrm3DVisu().m_Zoom <= 0.01 )
GetPrm3DVisu().m_Zoom = 0.01;
}
else
GetPrm3DVisu().m_Zoom *= 1.4;
DisplayStatus();
Refresh( false );
}
GetPrm3DVisu().m_Beginx = event.GetX();
GetPrm3DVisu().m_Beginy = event.GetY();
}
#ifdef USE_OSX_MAGNIFY_EVENT
void EDA_3D_CANVAS::OnMagnify( wxMouseEvent& event )
{
double magnification = ( event.GetMagnification() + 1.0f );
GetPrm3DVisu().m_Zoom /= magnification;
if( GetPrm3DVisu().m_Zoom <= 0.01 )
GetPrm3DVisu().m_Zoom = 0.01;
DisplayStatus();
Refresh( false );
}
#endif
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 * GetPrm3DVisu().m_Beginx - size.x) / size.x,
(size.y - 2.0 * GetPrm3DVisu().m_Beginy) / size.y,
( 2.0 * event.GetX() - size.x) / size.x,
( size.y - 2.0 * event.GetY() ) / size.y );
add_quats( spin_quat, GetPrm3DVisu().m_Quat, GetPrm3DVisu().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 * GetPrm3DVisu().m_Zoom;
m_draw3dOffset.x -= PAN_FACTOR *
( GetPrm3DVisu().m_Beginx - event.GetX() ) / size.x;
m_draw3dOffset.y -= PAN_FACTOR *
(event.GetY() - GetPrm3DVisu().m_Beginy) / size.y;
}
/* orientation has changed, redraw mesh */
DisplayStatus();
Refresh( false );
}
GetPrm3DVisu().m_Beginx = event.GetX();
GetPrm3DVisu().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( _( "Zoom: %3.1f" ), 45 * GetPrm3DVisu().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.
}
typedef struct s_sImage
{
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
unsigned char pixel_data[64 * 64 * 4 + 1];
}tsImage;
GLuint load_and_generate_texture( tsImage *image )
{
GLuint texture;
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glPixelStorei (GL_PACK_ALIGNMENT, 1);
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGBA, image->width, image->height,
GL_RGBA, GL_UNSIGNED_BYTE, image->pixel_data );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
return texture;
}
/* Initialize broad parameters for OpenGL */
void EDA_3D_CANVAS::InitGL()
{
if( !m_init )
{
m_init = true;
m_text_pcb = load_and_generate_texture( (tsImage *)&text_pcb );
m_text_silk = load_and_generate_texture( (tsImage *)&text_silk );
GetPrm3DVisu().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
glEnable( GL_NORMALIZE );
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 );
}
}
/* Initialize OpenGL light sources. */
void EDA_3D_CANVAS::SetLights()
{
// activate light. the source is above the xy plane, at source_pos
GLfloat source_pos[4] = { m_lightPos.x, m_lightPos.y, m_lightPos.z, 0.0f };
GLfloat light_color[4]; // color of lights (RGBA values)
light_color[3] = 1.0;
// Light above the xy plane
light_color[0] = light_color[1] = light_color[2] = 0.0;
glLightfv( GL_LIGHT0, GL_AMBIENT, light_color );
light_color[0] = light_color[1] = light_color[2] = 1.0;
glLightfv( GL_LIGHT0, GL_DIFFUSE, light_color );
light_color[0] = light_color[1] = light_color[2] = 1.0;
glLightfv( GL_LIGHT0, GL_SPECULAR, light_color );
glLightfv( GL_LIGHT0, GL_POSITION, source_pos );
light_color[0] = light_color[1] = light_color[2] = 0.2;
glLightModelfv( GL_LIGHT_MODEL_AMBIENT, light_color );
glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
glEnable( GL_LIGHT0 ); // White spot on Z axis ( top )
glEnable( GL_LIGHTING );
}
void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
{
static wxFileName fn; // Remember path between saves during this session only.
wxString FullFileName;
wxString file_ext, mask;
bool fmt_is_jpeg = false;
// First time path is set to the project path.
if( !fn.IsOk() )
fn = Parent()->Prj().GetProjectFullName();
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;
fn.SetExt( file_ext );
FullFileName = EDA_FILE_SELECTOR( _( "3D Image File Name:" ), fn.GetPath(),
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT, true );
if( FullFileName.IsEmpty() )
return;
fn = FullFileName;
// 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 viewport_params
{
GLint originx;
GLint originy;
GLint x;
GLint y;
} viewport;
// Be sure we have the latest 3D view (remember 3D view is buffered)
Refresh();
wxYield();
// 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 )
{
if( wxTheClipboard->Open() )
{
wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
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();
}
}
-375
View File
@@ -1,375 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* 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_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>
#include <modelparsers.h>
#include <class_module.h>
#include <CBBox.h>
class BOARD_DESIGN_SETTINGS;
class EDA_3D_FRAME;
class SHAPE_POLY_SET;
class REPORTER;
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_FRONT, // List id for 3D shapes, non transparent entities
GL_ID_3DSHAPES_TRANSP_FRONT,// List id for 3D shapes, transparent entities
GL_ID_3DSHAPES_SOLID_BACK, // List id for 3D shapes, non transparent entities
GL_ID_3DSHAPES_TRANSP_BACK, // List id for 3D shapes, transparent entities
GL_ID_SHADOW_FRONT,
GL_ID_SHADOW_BACK,
GL_ID_SHADOW_BOARD,
GL_ID_BODY, // Body only list
GL_ID_END
};
class EDA_3D_CANVAS : public wxGLCanvas
{
private:
bool m_init;
bool m_reportWarnings; ///< true to report all warnings when building the 3D scene
///< false to report errors only
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
GLuint m_text_pcb; ///< an index to the texture generated for pcb texts
GLuint m_text_silk; ///< an index to the texture generated for silk layers
// Index to the textures generated for shadows
bool m_shadow_init;
GLuint m_text_fake_shadow_front;
GLuint m_text_fake_shadow_back;
GLuint m_text_fake_shadow_board;
CBBOX m_boardAABBox; ///< Axis Align Bounding Box of the board
CBBOX m_fastAABBox; ///< Axis Align Bounding Box that contain the other bounding boxes
CBBOX m_fastAABBox_Shadow; ///< A bit scalled version of the m_fastAABBox
S3D_VERTEX m_lightPos;
/// Stores the list of parsers for each new file name (dont repeat files already loaded)
std::vector<S3D_MODEL_PARSER *> m_model_parsers_list;
std::vector<wxString> m_model_filename_list;
void create_and_render_shadow_buffer( GLuint *aDst_gl_texture,
GLuint aTexture_size, bool aDraw_body, int aBlurPasses );
void calcBBox();
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( int aGlList = 0 );
// Event functions:
void OnPaint( wxPaintEvent& event );
void OnEraseBackground( wxEraseEvent& event );
void OnChar( wxKeyEvent& event );
void OnMouseWheel( wxMouseEvent& event );
#ifdef USE_OSX_MAGNIFY_EVENT
void OnMagnify( wxMouseEvent& event );
#endif
void OnMouseMove( wxMouseEvent& event );
void OnRightClick( wxMouseEvent& event );
void OnPopUpMenu( wxCommandEvent& event );
/**
* Function TakeScreenshot
*
* creates a screenshot of the current 3D view and save to file as png or jpeg or image
* is copied to the clipboard
*/
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 ...)
* @param aErrorMessages = a REPORTER which will filled with error messages,
* if any
* @param aActivity = a REPORTER to display activity state
*/
void CreateDrawGL_List( REPORTER* aErrorMessages, REPORTER* aActivity );
void InitGL();
void ReportWarnings( bool aReport ) { m_reportWarnings = aReport; }
void SetLights();
void SetOffset(double aPosX, double aPosY)
{
m_draw3dOffset.x = aPosX;
m_draw3dOffset.y = aPosY;
}
/** @return the INFO3D_VISU which contains the current parameters
* to draw the 3D view og the board
*/
INFO3D_VISU& GetPrm3DVisu() const;
private:
/**
* return true if we are in realistic mode render
*/
bool isRealisticMode() const;
/**
* @return true if aItem should be displayed
* @param aItem = an item of DISPLAY3D_FLG enum
*/
bool isEnabled( DISPLAY3D_FLG aItem ) const;
/** Helper function
* @return true if aLayer should be displayed, false otherwise
*/
bool is3DLayerEnabled( LAYER_ID aLayer ) const;
/**
* @return the size of the board in pcb units
*/
wxSize getBoardSize() const;
/**
* @return the position of the board center in pcb units
*/
wxPoint getBoardCenter() const;
/**
* Helper function setGLTechLayersColor
* Initialize the color to draw the non copper layers
* in realistic mode and normal mode.
*/
void setGLTechLayersColor( LAYER_NUM aLayer );
/**
* Helper function setGLCopperColor
* Initialize the copper color to draw the board
* in realistic mode (a golden yellow color )
*/
void setGLCopperColor();
/**
* Helper function setGLEpoxyColor
* Initialize the color to draw the epoxy body board in realistic mode.
*/
void setGLEpoxyColor( float aTransparency = 1.0 );
/**
* Helper function setGLSolderMaskColor
* Initialize the color to draw the solder mask layers in realistic mode.
*/
void setGLSolderMaskColor( float aTransparency = 1.0 );
/**
* 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
* Fills aErrorMessages with error messages created by some calculation function
* display activity state
* @param aBoardList =
* @param aBodyOnlyList =
* @param aErrorMessages = a REPORTER to add error and warning messages
* created by the build process (can be NULL)
* @param aActivity = a REPORTER to display activity state
*/
void buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
REPORTER* aErrorMessages, REPORTER* aActivity );
/**
* Function buildTechLayers3DView
* Called by CreateDrawGL_List()
* Populates the OpenGL GL_ID_TECH_LAYERS draw list with items on tech layers
* @param aErrorMessages = a REPORTER to add error and warning messages
* created by the build process (can be NULL)
* @param aActivity = a REPORTER to display activity state
*/
void buildTechLayers3DView( REPORTER* aErrorMessages, REPORTER* aActivity );
/**
* Function buildBoardThroughHolesPolygonList
* Helper funtion to build the list of the board through holes polygons
* @param allBoardHoles = the SHAPE_POLY_SET to populate
* @param aSegCountPerCircle = the number of segments to approximate a circle
* @param aOptimizeLargeCircles = true to use more than aSegCountPerCircle
* for large circles (a large circle dimatere is > 1mm )
*/
void buildBoardThroughHolesPolygonList( SHAPE_POLY_SET& allBoardHoles,
int aSegCountPerCircle, bool aOptimizeLargeCircles );
/**
* Function buildShadowList
* Called by CreateDrawGL_List()
*/
void buildShadowList( GLuint aFrontList, GLuint aBacklist, GLuint aBoardList );
/**
* 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,
* @param aErrorMessages = a REPORTER to add error and warning messages
* created by the build process (can be NULL)
* @param aActivity = a REPORTER to display activity state
* which need to be drawn after all other items
*/
void buildFootprintShape3DList( GLuint aOpaqueList,
GLuint aTransparentList,
REPORTER* aErrorMessages, REPORTER* aActivity );
/**
* Function buildBoard3DAuxLayers
* Called by CreateDrawGL_List()
* Fills the OpenGL GL_ID_AUX_LAYERS draw list
* with items on aux layers only
* @param aErrorMessages = a REPORTER to add error and warning messages
* created by the build process (can be NULL)
* @param aActivity = a REPORTER to display activity state
* which need to be drawn after all other items
*/
void buildBoard3DAuxLayers( REPORTER* aErrorMessages, REPORTER* aActivity );
void draw3DGrid( double aGriSizeMM );
void draw3DAxis();
/**
* Helper function BuildPadShapeThickOutlineAsPolygon:
* Build a pad outline as non filled polygon, to draw pads on silkscreen layer
* with a line thickness = aWidth
* Used only to draw pads outlines on silkscreen layers.
*/
void buildPadShapeThickOutlineAsPolygon( const D_PAD* aPad,
SHAPE_POLY_SET& aCornerBuffer,
int aWidth,
int aCircleToSegmentsCount,
double aCorrectionFactor );
/**
* Helper function draw3DViaHole:
* Draw the via hole:
* Build a vertical hole (a cylinder) between the first and the last via layers
*/
void draw3DViaHole( const VIA * aVia );
/**
* Helper function draw3DPadHole:
* Draw the pad hole:
* Build a vertical hole (round or oblong) between the front and back layers
*/
void draw3DPadHole( const D_PAD * aPad );
/**
* function render3DComponentShape
* insert mesh in gl list
* @param module
* @param aIsRenderingJustNonTransparentObjects = true to load non transparent objects
* @param aIsRenderingJustTransparentObjects = true to load non transparent objects
* in openGL, transparent objects should be drawn *after* non transparent objects
*/
void render3DComponentShape( MODULE* module,
bool aIsRenderingJustNonTransparentObjects,
bool aIsRenderingJustTransparentObjects );
/**
* function read3DComponentShape
* read the 3D component shape(s) of the footprint (physical shape).
* @param module
* @return true if load was succeeded, false otherwise
*/
bool read3DComponentShape( MODULE* module );
/**
* function generateFakeShadowsTextures
* creates shadows of the board an footprints
* for aesthetical purpose
* @param aErrorMessages = a REPORTER to add error and warning messages
* created by the build process (can be NULL)
* @param aActivity = a REPORTER to display activity state
*/
void generateFakeShadowsTextures( REPORTER* aErrorMessages, REPORTER* aActivity );
DECLARE_EVENT_TABLE()
};
void CheckGLError(const char *aFileName, int aLineNumber);
#endif /* _3D_CANVAS_H_ */
+547
View File
@@ -0,0 +1,547 @@
/*
* 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 cinfo3d_visu.cpp
* @brief Handles data related with the board to be visualized
*/
#include "../3d_rendering/ccamera.h"
#include "cinfo3d_visu.h"
#include <3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.h>
#include <class_board.h>
#include <3d_math.h>
#include "3d_fastmath.h"
/**
* 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.
*/
const wxChar *CINFO3D_VISU::m_logTrace = wxT( "KI_TRACE_EDA_CINFO3D_VISU" );
CINFO3D_VISU G_null_CINFO3D_VISU;
CINFO3D_VISU::CINFO3D_VISU() :
m_currentCamera( m_trackBallCamera ),
m_trackBallCamera( RANGE_SCALE_3D )
{
wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::CINFO3D_VISU" ) );
m_board = NULL;
m_3d_model_manager = NULL;
m_3D_grid_type = GRID3D_NONE;
m_drawFlags.resize( FL_LAST, false );
m_render_engine = RENDER_ENGINE_OPENGL_LEGACY;
m_material_mode = MATERIAL_MODE_NORMAL;
m_boardPos = wxPoint();
m_boardSize = wxSize();
m_boardCenter = SFVEC3F();
m_boardBoudingBox.Reset();
m_board2dBBox3DU.Reset();
m_layers_container2D.clear();
m_layers_holes2D.clear();
m_through_holes_inner.Clear();
m_through_holes_outer.Clear();
m_copperLayersCount = -1;
m_epoxyThickness3DU = 0.0f;
m_copperThickness3DU = 0.0f;
m_nonCopperLayerThickness3DU = 0.0f;
m_biuTo3Dunits = 1.0;
m_stats_nr_tracks = 0;
m_stats_nr_vias = 0;
m_stats_via_med_hole_diameter = 0.0f;
m_stats_nr_holes = 0;
m_stats_hole_med_diameter = 0.0f;
m_stats_track_med_width = 0.0f;
m_calc_seg_min_factor3DU = 0.0f;
m_calc_seg_max_factor3DU = 0.0f;
memset( m_layerZcoordTop, 0, sizeof( m_layerZcoordTop ) );
memset( m_layerZcoordBottom, 0, sizeof( m_layerZcoordBottom ) );
SetFlag( FL_USE_REALISTIC_MODE, true );
SetFlag( FL_MODULE_ATTRIBUTES_NORMAL, true );
SetFlag( FL_SHOW_BOARD_BODY, true );
SetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS, true );
SetFlag( FL_MODULE_ATTRIBUTES_NORMAL, true );
SetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT, true );
SetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL, true );
SetFlag( FL_ZONE, true );
SetFlag( FL_SILKSCREEN, true );
SetFlag( FL_SOLDERMASK, true );
m_BgColorBot = SFVEC3D( 0.4, 0.4, 0.5 );
m_BgColorTop = SFVEC3D( 0.8, 0.8, 0.9 );
m_BoardBodyColor = SFVEC3D( 0.4, 0.4, 0.5 );
m_SolderMaskColor = SFVEC3D( 0.1, 0.2, 0.1 );
m_SolderPasteColor = SFVEC3D( 0.4, 0.4, 0.4 );
m_SilkScreenColor = SFVEC3D( 0.9, 0.9, 0.9 );
m_CopperColor = SFVEC3D( 0.75, 0.61, 0.23 );
}
CINFO3D_VISU::~CINFO3D_VISU()
{
destroyLayers();
}
bool CINFO3D_VISU::Is3DLayerEnabled( PCB_LAYER_ID aLayer ) const
{
wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
DISPLAY3D_FLG flg;
// see if layer needs to be shown
// check the flags
switch( aLayer )
{
case B_Adhes:
case F_Adhes:
flg = FL_ADHESIVE;
break;
case B_Paste:
case F_Paste:
flg = FL_SOLDERPASTE;
break;
case B_SilkS:
case F_SilkS:
flg = FL_SILKSCREEN;
break;
case B_Mask:
case F_Mask:
flg = FL_SOLDERMASK;
break;
case Dwgs_User:
case Cmts_User:
if( GetFlag( FL_USE_REALISTIC_MODE ) )
return false;
flg = FL_COMMENTS;
break;
case Eco1_User:
case Eco2_User:
if( GetFlag( FL_USE_REALISTIC_MODE ) )
return false;
flg = FL_ECO;
break;
case Edge_Cuts:
if( GetFlag( FL_SHOW_BOARD_BODY ) || GetFlag( FL_USE_REALISTIC_MODE ) )
return false;
return true;
break;
case Margin:
if( GetFlag( FL_USE_REALISTIC_MODE ) )
return false;
return true;
break;
case B_Cu:
case F_Cu:
return m_board->GetDesignSettings().IsLayerVisible( aLayer ) ||
GetFlag( FL_USE_REALISTIC_MODE );
break;
default:
// the layer is an internal copper layer, used the visibility
if( GetFlag( FL_SHOW_BOARD_BODY ) &&
(m_render_engine == RENDER_ENGINE_OPENGL_LEGACY) )
{
// Do not render internal layers if it is overlap with the board
// (on OpenGL render)
return false;
}
return m_board->GetDesignSettings().IsLayerVisible( aLayer );
}
// The layer has a flag, return the flag
return GetFlag( flg );
}
bool CINFO3D_VISU::GetFlag( DISPLAY3D_FLG aFlag ) const
{
wxASSERT( aFlag < FL_LAST );
return m_drawFlags[aFlag];
}
void CINFO3D_VISU::SetFlag( DISPLAY3D_FLG aFlag, bool aState )
{
wxASSERT( aFlag < FL_LAST );
m_drawFlags[aFlag] = aState;
}
bool CINFO3D_VISU::ShouldModuleBeDisplayed( MODULE_ATTR_T aModuleAttributs ) const
{
if( ( ( aModuleAttributs == MOD_DEFAULT ) &&
GetFlag( FL_MODULE_ATTRIBUTES_NORMAL ) ) ||
( ( ( aModuleAttributs & MOD_CMS) == MOD_CMS ) &&
GetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT ) ) ||
( ( ( aModuleAttributs & MOD_VIRTUAL) == MOD_VIRTUAL ) &&
GetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL ) ) )
{
return true;
}
return false;
}
// !TODO: define the actual copper thickness by user
#define COPPER_THICKNESS KiROUND( 0.035 * IU_PER_MM ) // for 35 um
#define TECH_LAYER_THICKNESS KiROUND( 0.04 * IU_PER_MM )
int CINFO3D_VISU::GetCopperThicknessBIU() const
{
return COPPER_THICKNESS;
}
// Constant factors used for number of segments approximation calcs
#define MIN_SEG_PER_CIRCLE 12
#define MAX_SEG_PER_CIRCLE 48
#define SEG_MIN_FACTOR_BIU ( 0.10f * IU_PER_MM )
#define SEG_MAX_FACTOR_BIU ( 6.00f * IU_PER_MM )
unsigned int CINFO3D_VISU::GetNrSegmentsCircle( float aDiameter3DU ) const
{
wxASSERT( aDiameter3DU > 0.0f );
unsigned int result = mapf( aDiameter3DU,
m_calc_seg_min_factor3DU, m_calc_seg_max_factor3DU,
(float)MIN_SEG_PER_CIRCLE, (float)MAX_SEG_PER_CIRCLE );
wxASSERT( result > 1 );
return result;
}
unsigned int CINFO3D_VISU::GetNrSegmentsCircle( int aDiameterBUI ) const
{
wxASSERT( aDiameterBUI > 0 );
unsigned int result = mapf( (float)aDiameterBUI,
(float)SEG_MIN_FACTOR_BIU, (float)SEG_MAX_FACTOR_BIU,
(float)MIN_SEG_PER_CIRCLE, (float)MAX_SEG_PER_CIRCLE );
wxASSERT( result > 1 );
return result;
}
double CINFO3D_VISU::GetCircleCorrectionFactor( int aNrSides ) const
{
wxASSERT( aNrSides >= 3 );
return 1.0 / cos( M_PI / ( (double)aNrSides * 2.0 ) );
}
void CINFO3D_VISU::InitSettings( REPORTER *aStatusTextReporter )
{
wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::InitSettings" ) );
// Calculates the board bounding box
// First, use only the board outlines
EDA_RECT bbbox = m_board->ComputeBoundingBox( true );
// If no outlines, use the board with items
if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
bbbox = m_board->ComputeBoundingBox( false );
// Gives a non null size to avoid issues in zoom / scale calculations
if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
bbbox.Inflate( Millimeter2iu( 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->GetCopperLayerCount();
// 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 convertion to apply to all positions.
m_biuTo3Dunits = RANGE_SCALE_3D / std::max( m_boardSize.x, m_boardSize.y );
// Calculate factors for cicle segment approximation
m_calc_seg_min_factor3DU = (float)( SEG_MIN_FACTOR_BIU * m_biuTo3Dunits );
m_calc_seg_max_factor3DU = (float)( SEG_MAX_FACTOR_BIU * m_biuTo3Dunits );
m_epoxyThickness3DU = m_board->GetDesignSettings().GetBoardThickness() *
m_biuTo3Dunits;
// !TODO: use value defined by user (currently use default values by ctor
m_copperThickness3DU = COPPER_THICKNESS * m_biuTo3Dunits;
m_nonCopperLayerThickness3DU = TECH_LAYER_THICKNESS * m_biuTo3Dunits;
// Init Z position of each layer
// calculate z position for each copper layer
// Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = 31)
// Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
// all unused copper layer z position are set to 0
// ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
// | | Top = Bottom + m_copperThickness
// |__________________________________|
// == == == == <- Bottom = -m_epoxyThickness / 2.0,
// Top = Bottom - m_copperThickness
unsigned int layer;
for( layer = 0; layer < m_copperLayersCount; ++layer )
{
m_layerZcoordBottom[layer] = m_epoxyThickness3DU / 2.0f -
(m_epoxyThickness3DU * layer / (m_copperLayersCount - 1) );
if( layer < (m_copperLayersCount / 2) )
m_layerZcoordTop[layer] = m_layerZcoordBottom[layer] + m_copperThickness3DU;
else
m_layerZcoordTop[layer] = m_layerZcoordBottom[layer] - m_copperThickness3DU;
}
#define layerThicknessMargin 1.1
const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
// Fill remaining unused copper layers and back layer zpos
// with -m_epoxyThickness / 2.0
for( ; layer < MAX_CU_LAYERS; layer++ )
{
m_layerZcoordBottom[layer] = -(m_epoxyThickness3DU / 2.0f);
m_layerZcoordTop[layer] = -(m_epoxyThickness3DU / 2.0f) - m_copperThickness3DU;
}
// This is the top of the copper layer thickness.
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:
case B_Paste:
zposBottom = zpos_copperTop_back;
zposTop = zpos_copperTop_back - m_nonCopperLayerThickness3DU;
break;
case F_Mask:
case F_Paste:
zposTop = zpos_copperTop_front + m_nonCopperLayerThickness3DU;
zposBottom = zpos_copperTop_front;
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_boardBoudingBox = CBBOX( boardMin, boardMax );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Build board body" ) );
createBoardPolygon();
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_stopCreateBoardPolyTime = GetRunningMicroSecs();
unsigned stats_startCreateLayersTime = stats_stopCreateBoardPolyTime;
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Create layers" ) );
createLayers( aStatusTextReporter );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_stopCreateLayersTime = GetRunningMicroSecs();
printf( "CINFO3D_VISU::InitSettings times\n" );
printf( " CreateBoardPoly: %.3f ms\n",
(float)( stats_stopCreateBoardPolyTime - stats_startCreateBoardPolyTime ) / 1e3 );
printf( " CreateLayers and holes: %.3f ms\n",
(float)( stats_stopCreateLayersTime - stats_startCreateLayersTime ) / 1e3 );
printf( "\n" );
#endif
}
void CINFO3D_VISU::createBoardPolygon()
{
m_board_poly.RemoveAllContours();
wxString errmsg;
if( !m_board->GetBoardPolygonOutlines( m_board_poly, /*allLayerHoles,*/ &errmsg ) )
{
errmsg.append( wxT( "\n\n" ) );
errmsg.append( _( "Cannot determine the board outline." ) );
wxLogMessage( errmsg );
}
// Be sure the polygon is strictly simple to avoid issues.
m_board_poly.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
Polygon_Calc_BBox_3DU( m_board_poly, m_board2dBBox3DU, m_biuTo3Dunits );
}
float CINFO3D_VISU::GetModulesZcoord3DIU( bool aIsFlipped ) const
{
if( aIsFlipped )
{
if( GetFlag( FL_SOLDERPASTE ) )
return m_layerZcoordBottom[B_SilkS];
else
return m_layerZcoordBottom[B_Paste];
}
else
{
if( GetFlag( FL_SOLDERPASTE ) )
return m_layerZcoordTop[F_SilkS];
else
return m_layerZcoordTop[F_Paste];
}
}
void CINFO3D_VISU::CameraSetType( CAMERA_TYPE aCameraType )
{
switch( aCameraType )
{
case CAMERA_TRACKBALL:
m_currentCamera = m_trackBallCamera;
break;
default:
wxLogMessage( wxT( "CINFO3D_VISU::CameraSetType() error: unknown camera type %d" ),
(int)aCameraType );
break;
}
}
SFVEC3F CINFO3D_VISU::GetLayerColor( PCB_LAYER_ID aLayerId ) const
{
wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
const COLOR4D color = m_board->Colors().GetLayerColor( aLayerId );
return SFVEC3F( color.r, color.g, color.b );
}
SFVEC3F CINFO3D_VISU::GetItemColor( int aItemId ) const
{
return GetColor( m_board->Colors().GetItemColor( aItemId ) );
}
SFVEC3F CINFO3D_VISU::GetColor( COLOR4D aColor ) const
{
return SFVEC3F( aColor.r, aColor.g, aColor.b );
}
+680
View File
@@ -0,0 +1,680 @@
/*
* 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 cinfo3d_visu.h
* @brief Handles data related with the board to be visualized
*/
#ifndef CINFO3D_VISU_H
#define CINFO3D_VISU_H
#include <vector>
#include "../3d_rendering/3d_render_raytracing/accelerators/ccontainer2d.h"
#include "../3d_rendering/3d_render_raytracing/accelerators/ccontainer.h"
#include "../3d_rendering/3d_render_raytracing/shapes3D/cbbox.h"
#include "../3d_rendering/ccamera.h"
#include "../3d_rendering/ctrack_ball.h"
#include "../3d_enums.h"
#include "../3d_cache/3d_cache.h"
#include <layers_id_colors_and_visibility.h>
#include <class_pad.h>
#include <class_track.h>
#include <wx/gdicmn.h>
#include <pcb_base_frame.h>
#include <class_pcb_text.h>
#include <class_drawsegment.h>
#include <class_dimension.h>
#include <class_zone.h>
#include <class_module.h>
#include <reporter.h>
/// A type that stores a container of 2d objects for each layer id
typedef std::map< PCB_LAYER_ID, CBVHCONTAINER2D *> MAP_CONTAINER_2D;
/// 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
/**
* Class CINFO3D_VISU
* Helper class to handle information needed to display 3D board
*/
class CINFO3D_VISU
{
public:
CINFO3D_VISU();
~CINFO3D_VISU();
/**
* @brief Set3DCacheManager - Update the Cache manager pointer
* @param aCachePointer: the pointer to the 3d cache manager
*/
void Set3DCacheManager( S3D_CACHE *aCachePointer ) { m_3d_model_manager = aCachePointer; }
/**
* @brief Get3DCacheManager - Return the 3d cache manager pointer
* @return
*/
S3D_CACHE *Get3DCacheManager( ) const { return m_3d_model_manager; }
/**
* @brief GetFlag - get a configuration status of a flag
* @param aFlag: the flag to get the status
* @return true if flag is set, false if not
*/
bool GetFlag( DISPLAY3D_FLG aFlag ) const ;
/**
* @brief SetFlag - set the status of a flag
* @param aFlag: the flag to get the status
* @param aState: status to set
*/
void SetFlag( DISPLAY3D_FLG aFlag, bool aState );
/**
* @brief Is3DLayerEnabled - Check if a layer is enabled
* @param aLayer: layer ID to get status
* @return true if layer should be displayed, false if not
*/
bool Is3DLayerEnabled( PCB_LAYER_ID aLayer ) const;
/**
* @brief ShouldModuleBeDisplayed - Test if module should be displayed in
* relation to attributs and the flags
* @return true if module should be displayed, false if not
*/
bool ShouldModuleBeDisplayed( MODULE_ATTR_T aModuleAttributs ) const;
/**
* @brief SetBoard - Set current board to be rendered
* @param aBoard: board to process
*/
void SetBoard( BOARD *aBoard ) { m_board = aBoard; }
/**
* @brief GetBoard - Get current board to be rendered
* @return BOARD pointer
*/
const BOARD *GetBoard() const { return m_board; }
/**
* @brief InitSettings - Function to be called by the render when it need to
* reload the settings for the board.
* @param aStatusTextReporter: the pointer for the status reporter
*/
void InitSettings( REPORTER *aStatusTextReporter );
/**
* @brief BiuTo3Dunits - Board integer units To 3D units
* @return the conversion factor to transform a position from the board to 3d units
*/
double BiuTo3Dunits() const { return m_biuTo3Dunits; }
/**
* @brief GetBBox3DU - Get the bbox of the pcb board
* @return the board bbox in 3d units
*/
const CBBOX &GetBBox3DU() const { return m_boardBoudingBox; }
/**
* @brief GetEpoxyThickness3DU - Get the current epoxy thickness
* @return thickness in 3d unities
*/
float GetEpoxyThickness3DU() const { return m_epoxyThickness3DU; }
/**
* @brief GetNonCopperLayerThickness3DU - Get the current non copper layers thickness
* @return thickness in 3d unities of non copperlayers
*/
float GetNonCopperLayerThickness3DU() const { return m_nonCopperLayerThickness3DU; }
/**
* @brief GetCopperThickness3DU - Get the current copper layer thickness
* @return thickness in 3d unities of copperlayers
*/
float GetCopperThickness3DU() const { return m_copperThickness3DU; }
/**
* @brief GetCopperThicknessBIU - Get the current copper layer thickness
* @return thickness in board unities
*/
int GetCopperThicknessBIU() const;
/**
* @brief GetBoardSizeBIU - Get the board size
* @return size in BIU unities
*/
wxSize GetBoardSizeBIU() const { return m_boardSize; }
/**
* @brief GetBoardPosBIU - Get the board size
* @return size in BIU unities
*/
wxPoint GetBoardPosBIU() const { return m_boardPos; }
/**
* @brief GetBoardCenter - the board center position in 3d units
* @return board center vector position in 3d units
*/
const SFVEC3F &GetBoardCenter3DU() const { return m_boardCenter; }
/**
* @brief GetModulesZcoord3DIU - Get the position of the module in 3d integer units
* considering if it is flipped or not.
* @param aIsFlipped: true for use in modules on Front (top) layer, false
* if module is on back (bottom) layer
* @return the Z position of 3D shapes, in 3D integer units
*/
float GetModulesZcoord3DIU( bool aIsFlipped ) const ;
/**
* @brief CameraSetType - Set the camera type to use
* @param aCameraType: camera type to use in this canvas
*/
void CameraSetType( CAMERA_TYPE aCameraType );
/**
* @brief CameraGet - get current camera in use
* @return a camera
*/
CCAMERA &CameraGet() const { return m_currentCamera; }
/**
* @brief GridGet - get the current grid
* @return space type of the grid
*/
GRID3D_TYPE GridGet() const { return m_3D_grid_type; }
/**
* @brief GridSet - set the current grid
* @param aGridType = the type space of the grid
*/
void GridSet( GRID3D_TYPE aGridType ) { m_3D_grid_type = aGridType; }
/**
* @brief RenderEngineSet
* @param aRenderEngine = the render engine mode selected
*/
void RenderEngineSet( RENDER_ENGINE aRenderEngine ) { m_render_engine = aRenderEngine; }
/**
* @brief RenderEngineGet
* @return render engine on use
*/
RENDER_ENGINE RenderEngineGet() const { return m_render_engine; }
/**
* @brief MaterialModeSet
* @param aMaterialMode = the render material mode
*/
void MaterialModeSet( MATERIAL_MODE aMaterialMode ) { m_material_mode = aMaterialMode; }
/**
* @brief MaterialModeGet
* @return material rendering mode
*/
MATERIAL_MODE MaterialModeGet() const { return m_material_mode; }
/**
* @brief GetBoardPoly - Get the current polygon of the epoxy board
* @return the shape polygon
*/
const SHAPE_POLY_SET &GetBoardPoly() const { return m_board_poly; }
/**
* @brief GetLayerColor - get the technical color of a layer
* @param aLayerId: the layer to get the color information
* @return the color in SFVEC3F format
*/
SFVEC3F GetLayerColor( PCB_LAYER_ID aLayerId ) const;
/**
* @brief GetItemColor - get the technical color of a layer
* @param aItemId: the item id to get the color information
* @return the color in SFVEC3F format
*/
SFVEC3F GetItemColor( int aItemId ) const;
/**
* @brief GetColor
* @param aColor: the color mapped
* @return the color in SFVEC3F format
*/
SFVEC3F GetColor( COLOR4D aColor ) const;
/**
* @brief GetLayerTopZpos3DU - Get the top z position
* @param aLayerId: layer id
* @return position in 3D unities
*/
float GetLayerTopZpos3DU( PCB_LAYER_ID aLayerId ) const { return m_layerZcoordTop[aLayerId]; }
/**
* @brief GetLayerBottomZpos3DU - Get the bottom z position
* @param aLayerId: layer id
* @return position in 3D unities
*/
float GetLayerBottomZpos3DU( PCB_LAYER_ID aLayerId ) const { return m_layerZcoordBottom[aLayerId]; }
/**
* @brief GetMapLayers - Get the map of container that have the objects per layer
* @return the map containers of this board
*/
const MAP_CONTAINER_2D &GetMapLayers() const { return m_layers_container2D; }
/**
* @brief GetMapLayersHoles -Get the map of container that have the holes per layer
* @return the map containers of holes from this board
*/
const MAP_CONTAINER_2D &GetMapLayersHoles() const { return m_layers_holes2D; }
/**
* @brief GetThroughHole_Outer - Get the inflated ThroughHole container
* @return a container with holes
*/
const CBVHCONTAINER2D &GetThroughHole_Outer() const { return m_through_holes_outer; }
/**
* @brief GetThroughHole_Outer_poly -
* @return
*/
const SHAPE_POLY_SET &GetThroughHole_Outer_poly() const { return m_through_outer_holes_poly; }
/**
* @brief GetThroughHole_Outer_poly_NPTH -
* @return
*/
const SHAPE_POLY_SET &GetThroughHole_Outer_poly_NPTH() const {
return m_through_outer_holes_poly_NPTH; }
/**
* @brief GetThroughHole_Vias_Outer -
* @return a container with via THT holes only
*/
const CBVHCONTAINER2D &GetThroughHole_Vias_Outer() const { return m_through_holes_vias_outer; }
/**
* @brief GetThroughHole_Vias_Inner -
* @return a container with via THT holes only
*/
const CBVHCONTAINER2D &GetThroughHole_Vias_Inner() const { return m_through_holes_vias_inner; }
/**
* @brief GetThroughHole_Vias_Outer_poly -
* @return
*/
const SHAPE_POLY_SET &GetThroughHole_Vias_Outer_poly() const {
return m_through_outer_holes_vias_poly; }
/**
* @brief GetThroughHole_Vias_Inner_poly -
* @return
*/
const SHAPE_POLY_SET &GetThroughHole_Vias_Inner_poly() const {
return m_through_inner_holes_vias_poly; }
/**
* @brief GetThroughHole_Inner - Get the ThroughHole container
* @return a container with holes
*/
const CBVHCONTAINER2D &GetThroughHole_Inner() const { return m_through_holes_inner; }
/**
* @brief GetThroughHole_Inner_poly -
* @return
*/
const SHAPE_POLY_SET &GetThroughHole_Inner_poly() const { return m_through_inner_holes_poly; }
/**
* @brief GetStats_Nr_Vias - Get statistics of the nr of vias
* @return number of vias
*/
unsigned int GetStats_Nr_Vias() const { return m_stats_nr_vias; }
/**
* @brief GetStats_Nr_Holes - Get statistics of the nr of holes
* @return number of holes
*/
unsigned int GetStats_Nr_Holes() const { return m_stats_nr_holes; }
/**
* @brief GetStats_Med_Via_Hole_Diameter3DU - Average diameter of the via holes
* @return dimension in 3D units
*/
float GetStats_Med_Via_Hole_Diameter3DU() const { return m_stats_via_med_hole_diameter; }
/**
* @brief GetStats_Med_Hole_Diameter3DU - Average diameter of holes
* @return dimension in 3D units
*/
float GetStats_Med_Hole_Diameter3DU() const { return m_stats_hole_med_diameter; }
/**
* @brief GetStats_Med_Track_Width - Average width of the tracks
* @return dimensions in 3D units
*/
float GetStats_Med_Track_Width() const { return m_stats_track_med_width; }
/**
* @brief GetNrSegmentsCircle
* @param aDiameter3DU: diameter in 3DU
* @return number of sides that should be used in that circle
*/
unsigned int GetNrSegmentsCircle( float aDiameter3DU ) const;
/**
* @brief GetNrSegmentsCircle
* @param aDiameterBUI: diameter in board unities
* @return number of sides that should be used in that circle
*/
unsigned int GetNrSegmentsCircle( int aDiameterBUI ) const;
/**
* @brief GetCircleCorrectionFactor - computes a angle correction
* factor used when creating circles
* @param aNrSides: the number of segments sides of the circle
* @return a factor to apply to contour creation
*/
double GetCircleCorrectionFactor( int aNrSides ) const;
/**
* @brief GetPolyMap - Get maps of polygons's layers
* @return the map with polygons's layers
*/
const MAP_POLY &GetPolyMap() const { return m_layers_poly; }
const MAP_POLY &GetPolyMapHoles_Inner() const { return m_layers_inner_holes_poly; }
const MAP_POLY &GetPolyMapHoles_Outer() const { return m_layers_outer_holes_poly; }
private:
void createBoardPolygon();
void createLayers( REPORTER *aStatusTextReporter );
void destroyLayers();
// Helper functions to create the board
COBJECT2D *createNewTrack( const TRACK* aTrack , int aClearanceValue ) const;
void createNewPad( const D_PAD* aPad,
CGENERICCONTAINER2D *aDstContainer,
const wxSize &aInflateValue ) const;
void createNewPadWithClearance( const D_PAD *aPad,
CGENERICCONTAINER2D *aDstContainer,
int aClearanceValue ) const;
COBJECT2D *createNewPadDrill( const D_PAD* aPad, int aInflateValue );
void AddPadsShapesWithClearanceToContainer( const MODULE *aModule,
CGENERICCONTAINER2D *aDstContainer,
PCB_LAYER_ID aLayerId,
int aInflateValue,
bool aSkipNPTHPadsWihNoCopper );
void AddGraphicsShapesWithClearanceToContainer( const MODULE *aModule,
CGENERICCONTAINER2D *aDstContainer,
PCB_LAYER_ID aLayerId,
int aInflateValue );
void AddShapeWithClearanceToContainer( const TEXTE_PCB *aTextPCB,
CGENERICCONTAINER2D *aDstContainer,
PCB_LAYER_ID aLayerId,
int aClearanceValue );
void AddShapeWithClearanceToContainer( const DRAWSEGMENT *aDrawSegment,
CGENERICCONTAINER2D *aDstContainer,
PCB_LAYER_ID aLayerId,
int aClearanceValue );
void AddShapeWithClearanceToContainer( const DIMENSION *aDimension,
CGENERICCONTAINER2D *aDstContainer,
PCB_LAYER_ID aLayerId,
int aClearanceValue );
void AddSolidAreasShapesToContainer( const ZONE_CONTAINER *aZoneContainer,
CGENERICCONTAINER2D *aDstContainer,
PCB_LAYER_ID aLayerId );
void TransformArcToSegments( const wxPoint &aCentre,
const wxPoint &aStart,
double aArcAngle,
int aCircleToSegmentsCount,
int aWidth,
CGENERICCONTAINER2D *aDstContainer,
const BOARD_ITEM &aBoardItem );
void buildPadShapeThickOutlineAsSegments( const D_PAD *aPad,
CGENERICCONTAINER2D *aDstContainer,
int aWidth );
// Helper functions to create poly contours
void buildPadShapeThickOutlineAsPolygon( const D_PAD *aPad,
SHAPE_POLY_SET &aCornerBuffer,
int aWidth) const;
void transformPadsShapesWithClearanceToPolygon( const DLIST<D_PAD> &aPads,
PCB_LAYER_ID aLayer,
SHAPE_POLY_SET &aCornerBuffer,
int aInflateValue,
bool aSkipNPTHPadsWihNoCopper) const;
void transformGraphicModuleEdgeToPolygonSet( const MODULE *aModule,
PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer ) const;
void buildPadShapePolygon( const D_PAD *aPad,
SHAPE_POLY_SET &aCornerBuffer,
wxSize aInflateValue,
int aSegmentsPerCircle,
double aCorrectionFactor ) const;
public:
SFVEC3D m_BgColorBot; ///< background bottom color
SFVEC3D m_BgColorTop; ///< background top color
SFVEC3D m_BoardBodyColor; ///< in realistic mode: FR4 board color
SFVEC3D m_SolderMaskColor; ///< in realistic mode: solder mask color
SFVEC3D m_SolderPasteColor; ///< in realistic mode: solder paste color
SFVEC3D m_SilkScreenColor; ///< in realistic mode: SilkScreen color
SFVEC3D m_CopperColor; ///< in realistic mode: copper color
private:
/// Current board
BOARD *m_board;
/// pointer to the 3d model manager
S3D_CACHE *m_3d_model_manager;
// Render options
/// options flags to render the board
std::vector< bool > m_drawFlags;
/// Stores the current grid type
GRID3D_TYPE m_3D_grid_type;
/// render engine currently on use
RENDER_ENGINE m_render_engine;
/// mode to render the 3d shape models material
MATERIAL_MODE m_material_mode;
// Pcb board position
/// center board actual position in board units
wxPoint m_boardPos;
/// board actual size in board units
wxSize m_boardSize;
/// 3d center position of the pcb board in 3d units
SFVEC3F m_boardCenter;
// Pcb board bounding boxes
/// 3d bouding box of the pcb board in 3d units
CBBOX m_boardBoudingBox;
/// 2d bouding box of the pcb board in 3d units
CBBOX2D m_board2dBBox3DU;
/// It contains polygon contours for each layer
MAP_POLY m_layers_poly;
/// It contains polygon contours for holes of each layer (outer holes)
MAP_POLY m_layers_outer_holes_poly;
/// It contains polygon contours for holes of each layer (inner holes)
MAP_POLY m_layers_inner_holes_poly;
/// It contains polygon contours for (just) non plated through holes (outer cylinder)
SHAPE_POLY_SET m_through_outer_holes_poly_NPTH;
/// It contains polygon contours for through holes (outer cylinder)
SHAPE_POLY_SET m_through_outer_holes_poly;
/// It contains polygon contours for through holes (inner cylinder)
SHAPE_POLY_SET m_through_inner_holes_poly;
/// It contains polygon contours for through holes vias (outer cylinder)
SHAPE_POLY_SET m_through_outer_holes_vias_poly;
/// It contains polygon contours for through holes vias (inner cylinder)
SHAPE_POLY_SET m_through_inner_holes_vias_poly;
/// PCB board outline polygon
SHAPE_POLY_SET m_board_poly;
// 2D element containers
/// It contains the 2d elements of each layer
MAP_CONTAINER_2D m_layers_container2D;
/// It contains the holes per each layer
MAP_CONTAINER_2D m_layers_holes2D;
/// It contains the list of throughHoles of the board,
/// the radius of the hole is inflated with the copper tickness
CBVHCONTAINER2D m_through_holes_outer;
/// It contains the list of throughHoles of the board,
/// the radius is the inner hole
CBVHCONTAINER2D m_through_holes_inner;
/// It contains the list of throughHoles vias of the board,
/// the radius of the hole is inflated with the copper tickness
CBVHCONTAINER2D m_through_holes_vias_outer;
/// It contains the list of throughHoles vias of the board,
/// the radius of the hole
CBVHCONTAINER2D m_through_holes_vias_inner;
// Layers information
/// Number of copper layers actually used by the board
unsigned int m_copperLayersCount;
/// Normalization scale to convert board internal units to 3D units to
/// normalize 3D units between -1.0 and +1.0
double m_biuTo3Dunits;
/// Top (End) Z position of each layer (normalized)
float m_layerZcoordTop[PCB_LAYER_ID_COUNT];
/// Bottom (Start) Z position of each layer (normalized)
float m_layerZcoordBottom[PCB_LAYER_ID_COUNT];
/// Copper thickness (normalized)
float m_copperThickness3DU;
/// Epoxy thickness (normalized)
float m_epoxyThickness3DU;
/// Non copper layers thickness
float m_nonCopperLayerThickness3DU;
// Cameras
/// Holds a pointer to current camera in use.
CCAMERA &m_currentCamera;
CTRACK_BALL m_trackBallCamera;
/// min factor used for cicle segment approximation calculation
float m_calc_seg_min_factor3DU;
/// max factor used for cicle segment approximation calculation
float m_calc_seg_max_factor3DU;
// Statistics
/// Number of tracks in the board
unsigned int m_stats_nr_tracks;
/// Track average width
float m_stats_track_med_width;
/// Nr of vias
unsigned int m_stats_nr_vias;
/// Computed medium diameter of the via holes in 3D units
float m_stats_via_med_hole_diameter;
/// number of holes in the board
unsigned int m_stats_nr_holes;
/// Computed medium diameter of the holes in 3D units
float m_stats_hole_med_diameter;
/**
* Trace mask used to enable or disable the trace output of this class.
* The debug output can be turned on by setting the WXTRACE environment variable to
* "KI_TRACE_EDA_CINFO3D_VISU". See the wxWidgets documentation on wxLogTrace for
* more information.
*/
static const wxChar *m_logTrace;
};
/// This is a dummy visualization configuration
extern CINFO3D_VISU G_null_CINFO3D_VISU;
#endif // CINFO3D_VISU_H
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+232
View File
@@ -0,0 +1,232 @@
/*
* 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 create_layer_poly.cpp
* @brief This file implements the creation of the pcb board items in the poly
* contours format. It is based on the function found in the files:
* board_items_to_polygon_shape_transform.cpp
* board_items_to_polygon_shape_transform.cpp
*/
#include "cinfo3d_visu.h"
#include <convert_basic_shapes_to_polygon.h>
#include <class_edge_mod.h>
#include <class_module.h>
// This is the same function as in board_items_to_polygon_shape_transform.cpp
// but it adds the rect/trapezoid shapes with a different winding
void CINFO3D_VISU::buildPadShapePolygon( const D_PAD* aPad,
SHAPE_POLY_SET& aCornerBuffer,
wxSize aInflateValue,
int aSegmentsPerCircle,
double aCorrectionFactor ) const
{
wxPoint corners[4];
wxPoint PadShapePos = aPad->ShapePos(); /* Note: for pad having a shape offset,
* the pad position is NOT the shape position */
switch( aPad->GetShape() )
{
case PAD_SHAPE_CIRCLE:
case PAD_SHAPE_OVAL:
case PAD_SHAPE_ROUNDRECT:
aPad->TransformShapeWithClearanceToPolygon( aCornerBuffer, aInflateValue.x,
aSegmentsPerCircle, aCorrectionFactor );
break;
case PAD_SHAPE_TRAPEZOID:
case PAD_SHAPE_RECT:
{
SHAPE_LINE_CHAIN aLineChain;
aPad->BuildPadPolygon( corners, aInflateValue, aPad->GetOrientation() );
for( int ii = 0; ii < 4; ++ii )
{
corners[3-ii] += PadShapePos; // Shift origin to position
aLineChain.Append( corners[3-ii].x, corners[3-ii].y );
}
aLineChain.SetClosed( true );
aCornerBuffer.AddOutline( aLineChain );
}
break;
case PAD_SHAPE_CUSTOM:
{
SHAPE_POLY_SET polyList; // Will contain the pad outlines in board coordinates
polyList.Append( aPad->GetCustomShapeAsPolygon() );
aPad->CustomShapeAsPolygonToBoardPosition( &polyList, aPad->ShapePos(), aPad->GetOrientation() );
aCornerBuffer.Append( polyList );
}
break;
}
}
void CINFO3D_VISU::buildPadShapeThickOutlineAsPolygon( const D_PAD* aPad,
SHAPE_POLY_SET& aCornerBuffer,
int aWidth ) const
{
if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
{
unsigned int nr_sides_per_circle = GetNrSegmentsCircle( ( aPad->GetSize().x / 2 +
aWidth / 2 ) * 2 );
TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(),
aPad->GetSize().x / 2, nr_sides_per_circle, aWidth );
return;
}
// For other shapes, draw polygon outlines
SHAPE_POLY_SET corners;
unsigned int nr_sides_per_circle = GetNrSegmentsCircle( glm::min( aPad->GetSize().x,
aPad->GetSize().y) );
buildPadShapePolygon( aPad, corners, wxSize( 0, 0 ),
nr_sides_per_circle,
GetCircleCorrectionFactor( nr_sides_per_circle ) );
// Add outlines as thick segments in polygon buffer
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 );
TransformRoundedEndsSegmentToPolygon( aCornerBuffer,
wxPoint( a.x, a.y ),
wxPoint( b.x, b.y ),
nr_sides_per_circle,
aWidth );
}
}
// Based on the same function name in board_items_to_polyshape_transform.cpp
// It was implemented here to allow dynamic segments count per pad shape
void CINFO3D_VISU::transformPadsShapesWithClearanceToPolygon( const DLIST<D_PAD>& aPads, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer,
int aInflateValue,
bool aSkipNPTHPadsWihNoCopper ) const
{
const D_PAD* pad = aPads;
wxSize margin;
for( ; pad != NULL; pad = pad->Next() )
{
if( !pad->IsOnLayer(aLayer) )
continue;
// NPTH pads are not drawn on layers if the shape size and pos is the same
// as their hole:
if( aSkipNPTHPadsWihNoCopper && (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
{
if( (pad->GetDrillSize() == pad->GetSize()) &&
(pad->GetOffset() == wxPoint( 0, 0 )) )
{
switch( pad->GetShape() )
{
case PAD_SHAPE_CIRCLE:
if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
continue;
break;
case PAD_SHAPE_OVAL:
if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
continue;
break;
default:
break;
}
}
}
switch( aLayer )
{
case F_Mask:
case B_Mask:
margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
break;
case F_Paste:
case B_Paste:
margin = pad->GetSolderPasteMargin();
margin.x += aInflateValue;
margin.y += aInflateValue;
break;
default:
margin.x = margin.y = aInflateValue;
break;
}
unsigned int aCircleToSegmentsCount = GetNrSegmentsCircle( pad->GetSize().x );
double aCorrectionFactor = GetCircleCorrectionFactor( aCircleToSegmentsCount );
buildPadShapePolygon( pad, aCornerBuffer, margin,
aCircleToSegmentsCount, aCorrectionFactor );
}
}
void CINFO3D_VISU::transformGraphicModuleEdgeToPolygonSet( const MODULE *aModule,
PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer ) const
{
for( const EDA_ITEM* item = aModule->GraphicalItemsList();
item != NULL;
item = item->Next() )
{
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE*outline = (EDGE_MODULE*) item;
if( outline->GetLayer() != aLayer )
break;
unsigned int aCircleToSegmentsCount =
GetNrSegmentsCircle( outline->GetBoundingBox().GetSizeMax() );
double aCorrectionFactor = GetCircleCorrectionFactor( aCircleToSegmentsCount );
outline->TransformShapeWithClearanceToPolygon( aCornerBuffer,
0,
aCircleToSegmentsCount,
aCorrectionFactor );
}
break;
default:
break;
}
}
}
File diff suppressed because it is too large Load Diff
+281
View File
@@ -0,0 +1,281 @@
/*
* 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 eda_3d_canvas.h
* @brief
*/
#ifndef EDA_3D_CANVAS_H
#define EDA_3D_CANVAS_H
#include "cinfo3d_visu.h"
#include "3d_rendering/c3d_render_base.h"
#include "3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h"
#include "3d_rendering/3d_render_raytracing/c3d_render_raytracing.h"
#include "3d_cache/3d_cache.h"
#include <gal/hidpi_gl_canvas.h>
#include <wx/clipbrd.h>
#include <wx/dataobj.h>
#include <wx/image.h>
#include <wx/wupdlock.h>
#include <wx/timer.h>
#include <wx/statusbr.h>
#include <pcb_base_frame.h>
/**
* Class EDA_3D_CANVAS
* Implement a canvas based on a wxGLCanvas
*/
class EDA_3D_CANVAS : public HIDPI_GL_CANVAS
{
public:
/**
* @brief EDA_3D_CANVAS - Creates 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 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 = 0,
BOARD *aBoard = NULL,
CINFO3D_VISU &aSettings = G_null_CINFO3D_VISU,
S3D_CACHE *a3DCachePointer = NULL );
~EDA_3D_CANVAS();
void SetStatusBar( wxStatusBar *aStatusBar ) { m_parentStatusBar = aStatusBar; }
void ReloadRequest( BOARD *aBoard = NULL, S3D_CACHE *aCachePointer = NULL );
/**
* @brief IsReloadRequestPending - 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;
}
/**
* @brief RenderRaytracingRequest - Request to render the current view in Raytracing mode
*/
void RenderRaytracingRequest();
/**
* Request a screenshot and output it to the aDstImage
* @param aDstImage - Screenshot destination image
*/
void GetScreenshot( wxImage &aDstImage );
/**
* @brief SetView3D - Helper function to call view commands
* @param keycode: ascii key commands
*/
void SetView3D( int keycode );
/**
* @brief RenderEngineChanged - Notify that the render engine was changed
*/
void RenderEngineChanged();
/**
* @brief DisplayStatus - Update the status bar with the position information
*/
void DisplayStatus();
/**
* @brief Request_refresh - 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 );
private:
void OnPaint( wxPaintEvent &event );
void OnEraseBackground( wxEraseEvent &event );
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 OnRightClick( wxMouseEvent &event );
void OnPopUpMenu( wxCommandEvent &event );
void OnCharHook( wxKeyEvent& event );
void OnKeyEvent( wxKeyEvent& event );
void OnTimerTimeout_Editing( wxTimerEvent& event );
/**
* @brief OnCloseWindow - called when the frame is closed
* @param event
*/
void OnCloseWindow( wxCloseEvent &event );
void OnResize( wxSizeEvent &event );
void OnTimerTimeout_Redraw( wxTimerEvent& event );
DECLARE_EVENT_TABLE()
private:
/**
* @brief stop_editingTimeOut_Timer - stop the editing time, so it will not timeout
*/
void stop_editingTimeOut_Timer();
/**
* @brief restart_editingTimeOut_Timer - reset the editing timer
*/
void restart_editingTimeOut_Timer();
/**
* @brief request_start_moving_camera - 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 );
/**
* @brief move_pivot_based_on_cur_mouse_position -
* This function hits a ray to the board and start a moviment
*/
void move_pivot_based_on_cur_mouse_position();
/**
* @brief render_pivot - 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 );
/**
* @brief initializeOpenGL
* @return if OpenGL initialization succeed
*/
bool initializeOpenGL();
/**
* @brief releaseOpenGL - free created targets and openGL context
*/
void releaseOpenGL();
private:
/// current OpenGL context
wxGLContext *m_glRC;
/// Parent statusbar to report progress
wxStatusBar *m_parentStatusBar;
/// Time timeout will expires after some time sinalizing that the mouse /
/// keyboard movements are over.
wxTimer m_editing_timeout_timer;
/// This timer will be used to schedule a redraw event
wxTimer m_redraw_trigger_timer;
/// true if mouse activity is on progress
bool m_mouse_is_moving;
/// true if there was some type of activity, it will be used to render in
/// preview mode
bool m_mouse_was_moved;
/// true if camera animation is ongoing
bool m_camera_is_moving;
/// activated the render of pivot while camera moving
bool m_render_pivot;
/// 1.0f will be 1:1
float m_camera_moving_speed;
/// Stores the ticktime when the camera star its movement
unsigned m_strtime_camera_movement;
/// Stores all pre-computed 3D information and visualization settings to render the board
CINFO3D_VISU &m_settings;
/// The current render in used for this canvas
C3D_RENDER_BASE *m_3d_render;
/// Raytracing render class
C3D_RENDER_RAYTRACING *m_3d_render_raytracing;
/// OpenGL legacy render class
C3D_RENDER_OGL_LEGACY *m_3d_render_ogl_legacy;
/// Flag to store if opengl was initialized already
bool m_is_opengl_initialized;
/// Step factor to used with cursor on relation to the current zoom
static const float m_delta_move_step_factor;
/// Flags that the user requested the current view to be render with raytracing
bool m_render_raytracing_was_requested;
/**
* 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
+122
View File
@@ -0,0 +1,122 @@
/*
* 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 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_settings.CameraGet().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_settings.CameraGet().GetProjectionMatrix() ) );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glLoadMatrixf( glm::value_ptr( m_settings.CameraGet().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();
}
@@ -0,0 +1,68 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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 status_text_reporter.h
* @brief
*/
#ifndef STATUS_TEXT_REPORTER_H_
#define STATUS_TEXT_REPORTER_H_
#include <reporter.h>
/**
* Class STATUS_TEXT_REPORTER
* is a wrapper for reporting to a wxString in a wxFrame status text.
*/
class STATUS_TEXT_REPORTER : public REPORTER
{
private:
wxStatusBar *m_parentStatusBar;
int m_position;
bool m_hasMessage;
public:
STATUS_TEXT_REPORTER( wxStatusBar* aParentStatusBar, int aPosition = 0 ) :
REPORTER(),
m_parentStatusBar( aParentStatusBar ), m_position( aPosition )
{
m_hasMessage = false;
}
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED ) override
{
if( !aText.IsEmpty() )
m_hasMessage = true;
if( m_parentStatusBar )
m_parentStatusBar->SetStatusText( aText, m_position );
return *this;
}
bool HasMessage() const override { return m_hasMessage; }
};
#endif // STATUS_TEXT_REPORTER_H_
-185
View File
@@ -1,185 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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_class.cpp
*/
#include <fctsys.h>
#include "3d_viewer.h"
#include "3d_struct.h"
#include "modelparsers.h"
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_3D_Drawings = NULL;
m_Materials = NULL;
m_parser = NULL;
m_ShapeType = FILE3D_NONE;
m_use_modelfile_diffuseColor = true;
m_use_modelfile_emissiveColor = true;
m_use_modelfile_specularColor = true;
m_use_modelfile_ambientIntensity = true;
m_use_modelfile_transparency = true;
m_use_modelfile_shininess = true;
}
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;
m_3D_Drawings = 0;
}
for( ; m_Materials != NULL; m_Materials = nextmat )
{
nextmat = m_Materials->Next();
delete m_Materials;
m_Materials = NULL;
}
}
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;
m_Shape3DNameExtension = fn.GetExt();
if( m_Shape3DNameExtension == wxT( "wrl" ) ||
m_Shape3DNameExtension == wxT( "x3d" ) )
m_ShapeType = FILE3D_VRML;
else if( m_Shape3DNameExtension == wxT( "idf" ) )
m_ShapeType = FILE3D_IDF;
else
m_ShapeType = FILE3D_UNKNOWN;
// 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("${") ) )
m_Shape3DFullFilename = wxExpandEnvVars( m_Shape3DName );
else
m_Shape3DFullFilename = m_Shape3DName;
wxFileName fnFull( m_Shape3DFullFilename );
if( !( fnFull.IsAbsolute() || m_Shape3DFullFilename.StartsWith( wxT(".") ) ) )
{
wxString default_path;
wxGetEnv( KISYS3DMOD, &default_path );
if( !( default_path.IsEmpty() ) )
{
if( !default_path.EndsWith( wxT("/") ) && !default_path.EndsWith( wxT("\\") ) )
default_path += wxT("/");
m_Shape3DFullFilename = default_path + m_Shape3DFullFilename;
}
}
return;
}
const wxString S3D_MASTER::GetShape3DFullFilename()
{
return m_Shape3DFullFilename;
}
const wxString S3D_MASTER::GetShape3DExtension()
{
return m_Shape3DNameExtension;
}
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
-426
View File
@@ -1,426 +0,0 @@
/*
* 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>
#include <modelparsers.h>
// Number of segments to approximate a circle by segments
#define SEGM_PER_CIRCLE 24
#ifndef CALLBACK
#define CALLBACK
#endif
// Variables used to pass a value to call back openGL functions
static float s_textureScale;
static double s_currentZpos;
static double s_biuTo3Dunits;
bool s_useTextures;
// 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 );
void TransfertToGLlist( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits );
/* 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 SHAPE_POLY_SET& 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
for( int idx = 0; idx < aPolysList.OutlineCount(); idx++ )
{
// Each polygon in aPolysList is a polygon with holes
const SHAPE_POLY_SET::POLYGON& curr_polywithholes = aPolysList.CPolygon( idx );
// Draw the outline of each simple polygon inside the polygon with holes:
for( unsigned ipoly = 0; ipoly < curr_polywithholes.size(); ipoly++ )
{
const SHAPE_LINE_CHAIN& path = curr_polywithholes[ipoly]; // a simple polygon
for( int jj = 0; jj < path.PointCount(); jj++ )
{
const VECTOR2I& a = path.CPoint( jj );
const VECTOR2I& b = path.CPoint( jj + 1 );
// Build the 4 vertices of each GL_QUAD
coords[0].x = a.x;
coords[0].y = -a.y;
coords[1].x = coords[0].x;
coords[1].y = coords[0].y; // only z change
coords[2].x = b.x;
coords[2].y = -b.y;
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 )
{
const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];
float red = colordata.m_Red / 255.0;
float blue = colordata.m_Blue / 255.0;
float green = colordata.m_Green / 255.0;
glColor4f( red, green, blue, (float)alpha );
}
void SetGLColor( S3D_COLOR& aColor, float aTransparency )
{
glColor4f( aColor.m_Red, aColor.m_Green, aColor.m_Blue, aTransparency );
}
void SetGLTexture( GLuint text_id, float scale )
{
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, text_id );
s_textureScale = scale; // for Tess callback functions
}
/* 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 SHAPE_POLY_SET& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits,
bool aUseTextures,
float aNormal_Z_Orientation )
{
// for Tess callback functions:
s_biuTo3Dunits = aBiuTo3DUnits;
s_useTextures = aUseTextures;
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.0) ) * aBiuTo3DUnits;
s_currentZpos = zpos; // for Tess callback functions
v_data[2] = zpos;
// Set normal toward positive Z axis, for a solid object on the top side
//gluTessProperty( tess, GLU_TESS_BOUNDARY_ONLY, GL_FALSE );
gluTessProperty( tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD );
glNormal3f( 0.0, 0.0, aNormal_Z_Orientation );
// Draw solid areas contained in this list
SHAPE_POLY_SET polylist = aPolysList; // temporary copy for gluTessVertex
for( int side = 0; side < 2; side++ )
{
for ( int idx = 0; idx < polylist.OutlineCount(); ++idx )
{
gluTessBeginPolygon( tess, NULL );
SHAPE_POLY_SET::POLYGON& curr_polywithholes = polylist.Polygon( idx ); // a polygon with holes
for( unsigned ipoly = 0; ipoly < curr_polywithholes.size(); ipoly++ )
{
SHAPE_LINE_CHAIN& curr_poly = curr_polywithholes[ipoly]; // a simple polygon
gluTessBeginContour( tess );
for( int ipt = 0; ipt < curr_poly.PointCount(); ipt++ )
{
v_data[0] = curr_poly.Point( ipt ).x * aBiuTo3DUnits;
v_data[1] = -curr_poly.Point( ipt ).y * 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, &curr_poly.Point( ipt ) );
}
gluTessEndContour( tess );
}
gluTessEndPolygon( tess );
}
if( aThickness == 0 )
break;
// Prepare the bottom side of solid areas
zpos = ( aZpos - (aThickness / 2.0) ) * aBiuTo3DUnits;
s_currentZpos = zpos; // for Tess callback functions
v_data[2] = zpos;
glNormal3f( 0.0, 0.0, -aNormal_Z_Orientation );
}
gluDeleteTess( tess );
if( aThickness == 0 )
return;
// Build the 3D data : vertical side
Draw3D_VerticalPolygonalCylinder( polylist, aThickness, aZpos - (aThickness / 2.0),
true, 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;
SHAPE_POLY_SET outer_cornerBuffer;
TransformCircleToPolygon( outer_cornerBuffer, aCenterPos,
aRadius + (aThickness / 2), slice );
std::vector<S3D_VERTEX> coords;
coords.resize( 4 );
SHAPE_POLY_SET 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)
outer_cornerBuffer.AddHole( inner_cornerBuffer.COutline( 0 ) );
// draw top (front) horizontal ring
Draw3D_SolidHorizontalPolyPolygons( outer_cornerBuffer, aZpos + aHeight,
0, aBiuTo3DUnits, false, 1.0f );
if( aHeight )
{
// draw bottom (back) horizontal ring
Draw3D_SolidHorizontalPolyPolygons( outer_cornerBuffer, aZpos,
0, aBiuTo3DUnits, false, -1.0f );
}
}
}
/*
* 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
SHAPE_POLY_SET cornerBuffer;
int segm_width = (aRadius * 2) + aThickness;
TransformRoundedEndsSegmentToPolygon( cornerBuffer, aAxis1Pos,
aAxis2Pos, slice, segm_width );
// Draw the oblong outer cylinder
if( aHeight )
Draw3D_VerticalPolygonalCylinder( cornerBuffer, aHeight, aZpos,
false, aBiuTo3DUnits );
if( aThickness )
{
SHAPE_POLY_SET 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)
cornerBuffer.AddHole( inner_cornerBuffer.COutline( 0 ) );
// draw top (front) horizontal side (ring)
Draw3D_SolidHorizontalPolyPolygons( cornerBuffer, aZpos + aHeight, 0, aBiuTo3DUnits, false,
1.0f );
if( aHeight )
{
// draw bottom (back) horizontal side (ring)
Draw3D_SolidHorizontalPolyPolygons( cornerBuffer, aZpos, 0, aBiuTo3DUnits, false,
-1.0f );
}
}
}
/* 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 )
{
SHAPE_POLY_SET cornerBuffer;
const int slice = SEGM_PER_CIRCLE;
TransformRoundedEndsSegmentToPolygon( cornerBuffer, aStart, aEnd, slice, aWidth );
Draw3D_SolidHorizontalPolyPolygons( cornerBuffer, aZpos, aThickness, aBiuTo3DUnits, false, 1.0f );
}
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;
SHAPE_POLY_SET cornerBuffer;
TransformArcToPolygon( cornerBuffer, aCenterPos, aStartPoint, aArcAngle,
slice, aWidth );
Draw3D_SolidHorizontalPolyPolygons( cornerBuffer, aZpos, aThickness, aBiuTo3DUnits, false, 1.0f );
}
// /////////////////////////////////////////////////////////////////////////////
// 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 VECTOR2I* ptr = (const VECTOR2I*) data;
if( s_useTextures )
{
glTexCoord2f( ptr->x * s_biuTo3Dunits * s_textureScale,
-ptr->y * s_biuTo3Dunits * s_textureScale);
}
glVertex3d( ptr->x * s_biuTo3Dunits, -ptr->y * s_biuTo3Dunits, s_currentZpos );
}
void CALLBACK tessErrorCB( GLenum errorCode )
{
#if defined(DEBUG)
const GLubyte* errorStr;
errorStr = gluErrorString( errorCode );
// DEBUG //
DBG( printf( "Tess ERROR: %s\n", errorStr ); )
#endif
}
-134
View File
@@ -1,134 +0,0 @@
/*
* 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
* @param aUseTextures = true to use textxures for the polygons
* @param aNormal_Z_Orientation = the normal Z orientation to apply
* 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 SHAPE_POLY_SET& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits,
bool aUseTextures,
float aNormal_Z_Orientation );
/** 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 );
/**
* Set the current 3D color from a S3D_COLOR color, with optional transparency
* @param aColor = a S3D_COLOR RGB color index
* @param aTransparency = the color transparency (default = 1.0 = no transparency)
*/
void SetGLColor( S3D_COLOR& aColor, float aTransparency );
/**
* Set a texture id and a scale to apply when rendering the polygons
* @param text_id = texture ID created by glGenTextures
* @param scale = scale to apply to texture coords
*/
void SetGLTexture( GLuint text_id, float scale );
#endif // _3D_DRAW_BASIC_FUNCTIONS_H_
-637
View File
@@ -1,637 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2015 Mario Luzeiro <mrluzeiro@gmail.com>
* 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_draw_board_body.cpp
*
*/
#include <fctsys.h>
#include <common.h>
#include <trigo.h>
#include <pcbstruct.h>
#include <drawtxt.h>
#include <layers_id_colors_and_visibility.h>
#include <wxBasePcbFrame.h>
#include <class_board.h>
#include <class_module.h>
#include <class_track.h>
#include <class_edge_mod.h>
#include <class_zone.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <colors_selection.h>
#include <convert_basic_shapes_to_polygon.h>
#define GLM_FORCE_RADIANS
#include <gal/opengl/glm/gtc/matrix_transform.hpp>
#include <gal/opengl/opengl_compositor.h>
#ifdef __WINDOWS__
#include <GL/glew.h> // must be included before gl.h
#endif
#include <3d_viewer.h>
#include <3d_canvas.h>
#include <info3d_visu.h>
#include <trackball.h>
#include <3d_draw_basic_functions.h>
#include <geometry/shape_poly_set.h>
#include <geometry/shape_file_io.h>
#include <CImage.h>
#include <reporter.h>
// An option for all operations on polygons:
// when useFastModeForPolygons = true, calculations can be *a lot* faster.
// but created polygons can be not stricty simple (can share edges)
// Although stricty simple are better for glu tesselation functions, I do not see
// any issue when allowing not stricty simple polygons.
// But I see *very* long calculations when setting useFastMode to false.
// So, be careful if changing thie option
bool useFastModeForPolygons = true;
/* returns the Z orientation parameter 1.0 or -1.0 for aLayer
* Z orientation is 1.0 for all layers but "back" layers:
* B_Cu , B_Adhes, B_Paste ), B_SilkS
* used to calculate the Z orientation parameter for glNormal3f
*/
GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer );
void EDA_3D_CANVAS::buildBoardThroughHolesPolygonList( SHAPE_POLY_SET& allBoardHoles,
int aSegCountPerCircle, bool aOptimizeLargeCircles )
{
// hole diameter value to change seg count by circle:
int small_hole_limit = Millimeter2iu( 1.0 );
int copper_thickness = GetPrm3DVisu().GetCopperThicknessBIU();
BOARD* pcb = GetBoard();
// Build holes of through vias:
for( TRACK* track = pcb->m_Track; track; track = track->Next() )
{
if( track->Type() != PCB_VIA_T )
continue;
VIA *via = static_cast<VIA*>( track );
if( via->GetViaType() != VIA_THROUGH )
continue;
int holediameter = via->GetDrillValue();
int hole_outer_radius = (holediameter + copper_thickness) / 2;
TransformCircleToPolygon( allBoardHoles,
via->GetStart(), hole_outer_radius,
aSegCountPerCircle );
}
// Build holes of through pads:
for( MODULE* footprint = pcb->m_Modules; footprint; footprint = footprint->Next() )
{
for( D_PAD* pad = footprint->Pads(); pad; pad = pad->Next() )
{
// Calculate a factor to apply to segcount for large holes ( > 1 mm)
// (bigger pad drill size -> more segments) because holes in pads can have
// very different sizes and optimizing this segcount gives a better look
// Mainly mounting holes have a size bigger than small_hole_limit
wxSize padHole = pad->GetDrillSize();
if( ! padHole.x ) // Not drilled pad like SMD pad
continue;
// we use the hole diameter to calculate the seg count.
// for round holes, padHole.x == padHole.y
// for oblong holes, the diameter is the smaller of (padHole.x, padHole.y)
int diam = std::min( padHole.x, padHole.y );
int segcount = aSegCountPerCircle;
if( diam > small_hole_limit )
{
double segFactor = (double)diam / small_hole_limit;
segcount = (int)(aSegCountPerCircle * segFactor);
// limit segcount to 48. For a circle this is a very good approx.
if( segcount > 48 )
segcount = 48;
}
// The hole in the body is inflated by copper thickness.
int inflate = copper_thickness;
// If not plated, no copper.
if( pad->GetAttribute () == PAD_ATTRIB_HOLE_NOT_PLATED )
inflate = 0;
pad->BuildPadDrillShapePolygon( allBoardHoles, inflate, segcount );
}
}
allBoardHoles.Simplify( useFastModeForPolygons );
}
void EDA_3D_CANVAS::buildBoard3DView( GLuint aBoardList, GLuint aBodyOnlyList,
REPORTER* aErrorMessages, REPORTER* aActivity )
{
BOARD* pcb = GetBoard();
// If FL_RENDER_SHOW_HOLES_IN_ZONES is true, holes are correctly removed from copper zones areas.
// If FL_RENDER_SHOW_HOLES_IN_ZONES is false, holes are not removed from copper zones areas,
// but the calculation time is twice shorter.
bool remove_Holes = isEnabled( FL_RENDER_SHOW_HOLES_IN_ZONES );
bool realistic_mode = isRealisticMode();
bool useTextures = isRealisticMode() && isEnabled( FL_RENDER_TEXTURES );
// Number of segments to convert a circle to polygon
// We use 2 values: the first gives a good shape (for instanes rond pads)
// the second is used to speed up calculations, when a poor approximation is acceptable (holes)
const int segcountforcircle = 18;
double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle * 2.0) );
const int segcountLowQuality = 12; // segments to draw a circle with low quality
// to reduce time calculations
// for holes and items which do not need
// a fine representation
double correctionFactorLQ = 1.0 / cos( M_PI / (segcountLowQuality * 2.0) );
SHAPE_POLY_SET bufferPolys; // copper areas: tracks, pads and filled zones areas
// when holes are removed from zones
SHAPE_POLY_SET bufferPcbOutlines; // stores the board main outlines
SHAPE_POLY_SET bufferZonesPolys; // copper filled zones areas
// when holes are not removed from zones
SHAPE_POLY_SET currLayerHoles; // Contains holes for the current layer
SHAPE_POLY_SET allLayerHoles; // Contains holes for all layers
// Build a polygon from edge cut items
wxString msg;
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
{
if( aErrorMessages )
{
msg << wxT("\n") << _("Unable to calculate the board outlines.\n"
"Therefore use the board boundary box.") << wxT("\n\n");
aErrorMessages->Report( msg, REPORTER::RPT_WARNING );
}
}
// Build board holes, with optimization of large holes shape.
buildBoardThroughHolesPolygonList( allLayerHoles, segcountLowQuality, true );
LSET cu_set = LSET::AllCuMask( GetPrm3DVisu().m_CopperLayersCount );
glNewList( aBoardList, GL_COMPILE );
for( LSEQ cu = cu_set.CuStack(); cu; ++cu )
{
LAYER_ID layer = *cu;
// Skip non enabled layers in normal mode,
// and internal layers in realistic mode
if( !is3DLayerEnabled( layer ) )
continue;
if( aActivity )
aActivity->Report( wxString::Format( _( "Build layer %s" ), LSET::Name( layer ) ) );
bufferPolys.RemoveAllContours();
bufferZonesPolys.RemoveAllContours();
currLayerHoles.RemoveAllContours();
// Draw track shapes:
for( TRACK* track = pcb->m_Track; track; track = track->Next() )
{
if( !track->IsOnLayer( layer ) )
continue;
track->TransformShapeWithClearanceToPolygon( bufferPolys,
0, segcountforcircle,
correctionFactor );
// Add blind/buried via holes
if( track->Type() == PCB_VIA_T )
{
VIA *via = static_cast<VIA*>( track );
if( via->GetViaType() == VIA_THROUGH )
continue; // already done
int holediameter = via->GetDrillValue();
int thickness = GetPrm3DVisu().GetCopperThicknessBIU();
int hole_outer_radius = (holediameter + thickness) / 2;
TransformCircleToPolygon( currLayerHoles,
via->GetStart(), hole_outer_radius,
segcountLowQuality );
}
}
// draw pad shapes
for( MODULE* module = pcb->m_Modules; module; module = module->Next() )
{
// Note: NPTH pads are not drawn on copper layers when the pad
// has same shape as its hole
module->TransformPadsShapesWithClearanceToPolygon( layer,
bufferPolys,
0,
segcountforcircle,
correctionFactor, true );
// Micro-wave modules may have items on copper layers
module->TransformGraphicShapesWithClearanceToPolygonSet( layer,
bufferPolys,
0,
segcountforcircle,
correctionFactor );
// pad holes are already in list.
}
// Draw copper zones. Note:
// * if the holes are removed from copper zones
// the polygons are stored in bufferPolys (which contains all other polygons)
// * if the holes are NOT removed from copper zones
// the polygons are stored in bufferZonesPolys
if( isEnabled( FL_ZONE ) )
{
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* zone = pcb->GetArea( ii );
LAYER_NUM zonelayer = zone->GetLayer();
if( zonelayer == layer )
{
zone->TransformSolidAreasShapesToPolygonSet(
remove_Holes ? bufferPolys : bufferZonesPolys,
segcountLowQuality, correctionFactorLQ );
}
}
}
// draw graphic items on copper layers (texts)
for( BOARD_ITEM* item = pcb->m_Drawings; item; item = item->Next() )
{
if( !item->IsOnLayer( layer ) )
continue;
switch( item->Type() )
{
case PCB_LINE_T: // should not exist on copper layers
( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
bufferPolys, 0, segcountforcircle, correctionFactor );
break;
case PCB_TEXT_T:
( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
bufferPolys, 0, segcountLowQuality, correctionFactor );
break;
default:
break;
}
}
// bufferPolys contains polygons to merge. Many overlaps .
// Calculate merged polygons
if( bufferPolys.IsEmpty() )
continue;
// Use Clipper lib to subtract holes to copper areas
if( currLayerHoles.OutlineCount() )
{
currLayerHoles.Append(allLayerHoles);
currLayerHoles.Simplify( useFastModeForPolygons );
bufferPolys.BooleanSubtract( currLayerHoles, useFastModeForPolygons );
}
else
bufferPolys.BooleanSubtract( allLayerHoles, useFastModeForPolygons );
int thickness = GetPrm3DVisu().GetLayerObjectThicknessBIU( layer );
int zpos = GetPrm3DVisu().GetLayerZcoordBIU( layer );
float zNormal = 1.0f; // When using thickness it will draw first the top and then botton (with z inverted)
// If we are not using thickness, then the z-normal has to match the layer direction
// because just one plane will be drawn
if( !thickness )
zNormal = Get3DLayer_Z_Orientation( layer );
if( realistic_mode )
{
setGLCopperColor();
}
else
{
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( layer );
SetGLColor( color );
}
// If holes are removed from copper zones, bufferPolys contains all polygons
// to draw (tracks+zones+texts).
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, thickness,
GetPrm3DVisu().m_BiuTo3Dunits, useTextures,
zNormal );
// If holes are not removed from copper zones (for calculation time reasons,
// the zone polygons are stored in bufferZonesPolys and have to be drawn now:
if( !bufferZonesPolys.IsEmpty() )
{
Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos, thickness,
GetPrm3DVisu().m_BiuTo3Dunits, useTextures,
zNormal );
}
}
if( aActivity )
aActivity->Report( _( "Build board body" ) );
// Draw plated vertical holes inside the board, but not always. They are drawn:
// - if the board body is not shown, to show the holes.
// - or if the copper thickness is shown
if( !isEnabled( FL_SHOW_BOARD_BODY ) || isEnabled( FL_USE_COPPER_THICKNESS ) )
{
// Draw vias holes (vertical cylinders)
for( const TRACK* track = pcb->m_Track; track; track = track->Next() )
{
if( track->Type() == PCB_VIA_T )
{
const VIA *via = static_cast<const VIA*>(track);
draw3DViaHole( via );
}
}
// Draw pads holes (vertical cylinders)
for( const MODULE* module = pcb->m_Modules; module; module = module->Next() )
{
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
if( pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED )
draw3DPadHole( pad );
}
}
glEndList();
// Build the body board:
glNewList( aBodyOnlyList, GL_COMPILE );
if( isRealisticMode() )
{
setGLEpoxyColor( 1.00 );
}
else
{
EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( Edge_Cuts );
SetGLColor( color, 0.7 );
}
float copper_thickness = GetPrm3DVisu().GetCopperThicknessBIU();
// a small offset between substrate and external copper layer to avoid artifacts
// when drawing copper items on board
float epsilon = Millimeter2iu( 0.01 );
float zpos = GetPrm3DVisu().GetLayerZcoordBIU( B_Cu );
float board_thickness = GetPrm3DVisu().GetLayerZcoordBIU( F_Cu )
- GetPrm3DVisu().GetLayerZcoordBIU( B_Cu );
// items on copper layers and having a thickness = copper_thickness
// are drawn from zpos - copper_thickness/2 to zpos + copper_thickness
// therefore substrate position is copper_thickness/2 to
// substrate_height - copper_thickness/2
zpos += (copper_thickness + epsilon) / 2.0f;
board_thickness -= copper_thickness + epsilon;
bufferPcbOutlines.BooleanSubtract( allLayerHoles, useFastModeForPolygons );
if( !bufferPcbOutlines.IsEmpty() )
{
Draw3D_SolidHorizontalPolyPolygons( bufferPcbOutlines, zpos + board_thickness / 2.0,
board_thickness, GetPrm3DVisu().m_BiuTo3Dunits, useTextures,
1.0f );
}
glEndList();
}
void EDA_3D_CANVAS::buildTechLayers3DView( REPORTER* aErrorMessages, REPORTER* aActivity )
{
BOARD* pcb = GetBoard();
bool useTextures = isRealisticMode() && isEnabled( FL_RENDER_TEXTURES );
// Number of segments to draw a circle using segments
const int segcountforcircle = 18;
double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle * 2) );
const int segcountLowQuality = 12; // segments to draw a circle with low quality
// to reduce time calculations
// for holes and items which do not need
// a fine representation
double correctionFactorLQ = 1.0 / cos( M_PI / (segcountLowQuality * 2) );
// segments to draw a circle to build texts. Is is used only to build
// the shape of each segment of the stroke font, therefore no need to have
// many segments per circle.
const int segcountInStrokeFont = 8;
SHAPE_POLY_SET bufferPolys;
SHAPE_POLY_SET allLayerHoles; // Contains through holes, calculated only once
SHAPE_POLY_SET bufferPcbOutlines; // stores the board main outlines
// Build a polygon from edge cut items
wxString msg;
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
{
if( aErrorMessages )
{
msg << wxT("\n") <<
_("Unable to calculate the board outlines.\n"
"Therefore use the board boundary box.") << wxT("\n\n");
aErrorMessages->Report( msg, REPORTER::RPT_WARNING );
}
}
// Build board holes, with no optimization of large holes shape.
buildBoardThroughHolesPolygonList( allLayerHoles, segcountLowQuality, false );
// draw graphic items, on technical layers
static const LAYER_ID teckLayerList[] = {
B_Adhes,
F_Adhes,
B_Paste,
F_Paste,
B_SilkS,
F_SilkS,
B_Mask,
F_Mask,
};
// User layers are not drawn here, only technical layers
for( LSEQ seq = LSET::AllTechMask().Seq( teckLayerList, DIM( teckLayerList ) ); seq; ++seq )
{
LAYER_ID layer = *seq;
if( !is3DLayerEnabled( layer ) )
continue;
if( layer == Edge_Cuts && isEnabled( FL_SHOW_BOARD_BODY ) )
continue;
if( aActivity )
aActivity->Report( wxString::Format( _( "Build layer %s" ), LSET::Name( layer ) ) );
bufferPolys.RemoveAllContours();
for( BOARD_ITEM* item = pcb->m_Drawings; item; item = item->Next() )
{
if( !item->IsOnLayer( layer ) )
continue;
switch( item->Type() )
{
case PCB_LINE_T:
( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
bufferPolys, 0, segcountforcircle, correctionFactor );
break;
case PCB_TEXT_T:
( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
bufferPolys, 0, segcountLowQuality, 1.0 );
break;
default:
break;
}
}
for( MODULE* module = pcb->m_Modules; module; module = module->Next() )
{
if( layer == F_SilkS || layer == B_SilkS )
{
// On silk screen layers, the pad shape is only the pad outline
// never a filled shape
D_PAD* pad = module->Pads();
int linewidth = g_DrawDefaultLineThickness;
for( ; pad; pad = pad->Next() )
{
if( !pad->IsOnLayer( layer ) )
continue;
buildPadShapeThickOutlineAsPolygon( pad, bufferPolys,
linewidth, segcountforcircle, correctionFactor );
}
}
else
module->TransformPadsShapesWithClearanceToPolygon( layer,
bufferPolys, 0, segcountforcircle, correctionFactor );
// On tech layers, use a poor circle approximation, only for texts (stroke font)
module->TransformGraphicShapesWithClearanceToPolygonSet( layer,
bufferPolys, 0, segcountforcircle, correctionFactor, segcountInStrokeFont );
}
// Draw non copper zones
if( isEnabled( FL_ZONE ) )
{
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* zone = pcb->GetArea( ii );
if( !zone->IsOnLayer( layer ) )
continue;
zone->TransformSolidAreasShapesToPolygonSet(
bufferPolys, segcountLowQuality, correctionFactorLQ );
}
}
// bufferPolys contains polygons to merge. Many overlaps .
// Calculate merged polygons and remove pads and vias holes
if( bufferPolys.IsEmpty() )
continue;
// Solder mask layers are "negative" layers.
// Shapes should be removed from the full board area.
if( layer == B_Mask || layer == F_Mask )
{
SHAPE_POLY_SET cuts = bufferPolys;
bufferPolys = bufferPcbOutlines;
cuts.Append(allLayerHoles);
cuts.Simplify( useFastModeForPolygons );
bufferPolys.BooleanSubtract( cuts, useFastModeForPolygons );
}
// Remove holes from Solder paste layers and silkscreen
else if( layer == B_Paste || layer == F_Paste
|| layer == B_SilkS || layer == F_SilkS )
{
bufferPolys.BooleanSubtract( allLayerHoles, useFastModeForPolygons );
}
int thickness = 0;
if( layer != B_Mask && layer != F_Mask )
thickness = GetPrm3DVisu().GetLayerObjectThicknessBIU( layer );
int zpos = GetPrm3DVisu().GetLayerZcoordBIU( layer );
if( layer == Edge_Cuts )
{
thickness = GetPrm3DVisu().GetLayerZcoordBIU( F_Cu )
- GetPrm3DVisu().GetLayerZcoordBIU( B_Cu );
zpos = GetPrm3DVisu().GetLayerZcoordBIU( B_Cu )
+ (thickness / 2);
}
else
{
// for Draw3D_SolidHorizontalPolyPolygons, zpos it the middle between bottom and top
// sides.
// However for top layers, zpos should be the bottom layer pos,
// and for bottom layers, zpos should be the top layer pos.
if( Get3DLayer_Z_Orientation( layer ) > 0 )
zpos += thickness/2;
else
zpos -= thickness/2 ;
}
float zNormal = 1.0f; // When using thickness it will draw first the top and then botton (with z inverted)
// If we are not using thickness, then the znormal must face the layer direction
// because it will draw just one plane
if( !thickness )
zNormal = Get3DLayer_Z_Orientation( layer );
setGLTechLayersColor( layer );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness, GetPrm3DVisu().m_BiuTo3Dunits, useTextures,
zNormal );
}
}
-493
View File
@@ -1,493 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2014 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_helper_functions.cpp
*/
#include <fctsys.h>
#include <PolyLine.h>
#include <colors.h>
#include <colors_selection.h>
#include <class_pad.h>
#include <class_track.h>
#include <convert_basic_shapes_to_polygon.h>
#include <3d_viewer.h>
#include <3d_canvas.h>
#include <info3d_visu.h>
#include <3d_draw_basic_functions.h>
#define TEXTURE_PCB_SCALE 5.0
// -----------------
// helper function (from wxWidgets, opengl/cube.cpp sample
// -----------------
void CheckGLError(const char *aFileName, int aLineNumber)
{
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 At: %s, line: %d" ), err,
GetChars( FROM_UTF8( aFileName ) ), aLineNumber );
}
}
INFO3D_VISU& EDA_3D_CANVAS::GetPrm3DVisu() const
{
return Parent()->GetPrm3DVisu();
}
wxSize EDA_3D_CANVAS::getBoardSize() const
{
// return the size of the board in pcb units
return GetPrm3DVisu().m_BoardSize;
}
wxPoint EDA_3D_CANVAS::getBoardCenter() const
{
// return the position of the board center in pcb units
return GetPrm3DVisu().m_BoardPos;
}
// return true if we are in realistic mode render
bool EDA_3D_CANVAS::isRealisticMode() const
{
return GetPrm3DVisu().IsRealisticMode();
}
// return true if aItem should be displayed
bool EDA_3D_CANVAS::isEnabled( DISPLAY3D_FLG aItem ) const
{
return GetPrm3DVisu().GetFlag( aItem );
}
// Helper function: initialize the copper color to draw the board
// in realistic mode.
void EDA_3D_CANVAS::setGLCopperColor()
{
glDisable( GL_TEXTURE_2D );
SetGLColor( GetPrm3DVisu().m_CopperColor, 1.0 );
}
// Helper function: initialize the color to draw the epoxy
// body board in realistic mode.
void EDA_3D_CANVAS::setGLEpoxyColor( float aTransparency )
{
// Generates an epoxy color, near board color
SetGLColor( GetPrm3DVisu().m_BoardBodyColor, aTransparency );
if( isEnabled( FL_RENDER_TEXTURES ) )
{
SetGLTexture( m_text_pcb, TEXTURE_PCB_SCALE );
}
}
// Helper function: initialize the color to draw the
// solder mask layers in realistic mode.
void EDA_3D_CANVAS::setGLSolderMaskColor( float aTransparency )
{
// Generates a solder mask color
SetGLColor( GetPrm3DVisu().m_SolderMaskColor, aTransparency );
if( isEnabled( FL_RENDER_TEXTURES ) )
{
SetGLTexture( m_text_pcb, TEXTURE_PCB_SCALE );
}
}
// Helper function: initialize the color to draw the non copper layers
// in realistic mode and normal mode.
void EDA_3D_CANVAS::setGLTechLayersColor( LAYER_NUM aLayer )
{
EDA_COLOR_T color;
if( isRealisticMode() )
{
switch( aLayer )
{
case B_Paste:
case F_Paste:
SetGLColor( GetPrm3DVisu().m_SolderPasteColor, 1 );
break;
case B_SilkS:
case F_SilkS:
SetGLColor( GetPrm3DVisu().m_SilkScreenColor, 0.96 );
if( isEnabled( FL_RENDER_TEXTURES ) )
{
SetGLTexture( m_text_silk, 10.0f );
}
break;
case B_Mask:
case F_Mask:
setGLSolderMaskColor( 0.90 );
break;
default:
color = g_ColorsSettings.GetLayerColor( aLayer );
SetGLColor( color, 0.7 );
break;
}
}
else
{
color = g_ColorsSettings.GetLayerColor( aLayer );
SetGLColor( color, 0.7 );
}
}
void EDA_3D_CANVAS::draw3DAxis()
{
if( ! m_glLists[GL_ID_AXIS] )
{
m_glLists[GL_ID_AXIS] = glGenLists( 1 );
glNewList( m_glLists[GL_ID_AXIS], GL_COMPILE );
glEnable( GL_COLOR_MATERIAL );
glBegin( GL_LINES );
SetGLColor( RED );
glNormal3f( 0.0f, 0.0f, 1.0f ); // Normal is Z axis
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( -10.0f, 0.0f, 0.0f );
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 10.0f, 0.0f, 0.0f ); // X axis
SetGLColor( GREEN );
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 0.0f, -10.0f, 0.0f ); // Y axis
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 0.0f, 10.0f, 0.0f );
SetGLColor( BLUE );
glNormal3f( 1.0f, 0.0f, 0.0f ); // Normal is Y axis
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 0.0f, 0.0f, -10.0f );
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 0.0f, 0.0f, 10.0f ); // Z axis
glEnd();
glEndList();
}
}
// draw a 3D grid: an horizontal grid (XY plane and Z = 0,
// and a vertical grid (XZ plane and Y = 0)
void EDA_3D_CANVAS::draw3DGrid( double aGriSizeMM )
{
double zpos = 0.0;
EDA_COLOR_T gridcolor = DARKGRAY; // Color of grid lines
EDA_COLOR_T gridcolor_marker = LIGHTGRAY; // Color of grid lines every 5 lines
const double scale = GetPrm3DVisu().m_BiuTo3Dunits;
const double transparency = 0.3;
glNormal3f( 0.0, 0.0, 1.0 );
wxSize brd_size = getBoardSize();
wxPoint brd_center_pos = getBoardCenter();
brd_center_pos.y = -brd_center_pos.y;
int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) ) * 1.2;
int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) ) * 1.2;
// Grid limits, in 3D units
double xmin = (brd_center_pos.x - xsize / 2) * scale;
double xmax = (brd_center_pos.x + xsize / 2) * scale;
double ymin = (brd_center_pos.y - ysize / 2) * scale;
double ymax = (brd_center_pos.y + ysize / 2) * scale;
double zmin = Millimeter2iu( -50 ) * scale;
double zmax = Millimeter2iu( 100 ) * scale;
// Draw horizontal grid centered on 3D origin (center of the board)
for( int ii = 0; ; ii++ )
{
if( (ii % 5) )
SetGLColor( gridcolor, transparency );
else
SetGLColor( gridcolor_marker, transparency );
int delta = KiROUND( ii * aGriSizeMM * IU_PER_MM );
if( delta <= xsize / 2 ) // Draw grid lines parallel to X axis
{
glBegin( GL_LINES );
glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
glEnd();
if( ii != 0 )
{
glBegin( GL_LINES );
glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
glEnd();
}
}
if( delta <= ysize / 2 ) // Draw grid lines parallel to Y axis
{
glBegin( GL_LINES );
glVertex3f( xmin, -(brd_center_pos.y + delta) * scale, zpos );
glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos );
glEnd();
if( ii != 0 )
{
glBegin( GL_LINES );
glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos );
glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos );
glEnd();
}
}
if( ( delta > ysize / 2 ) && ( delta > xsize / 2 ) )
break;
}
// Draw vertical grid on Z axis
glNormal3f( 0.0, -1.0, 0.0 );
// Draw vertical grid lines (parallel to Z axis)
double posy = -brd_center_pos.y * scale;
for( int ii = 0; ; ii++ )
{
if( (ii % 5) )
SetGLColor( gridcolor, transparency );
else
SetGLColor( gridcolor_marker, transparency );
double delta = ii * aGriSizeMM * IU_PER_MM;
glBegin( GL_LINES );
xmax = (brd_center_pos.x + delta) * scale;
glVertex3f( xmax, posy, zmin );
glVertex3f( xmax, posy, zmax );
glEnd();
if( ii != 0 )
{
glBegin( GL_LINES );
xmin = (brd_center_pos.x - delta) * scale;
glVertex3f( xmin, posy, zmin );
glVertex3f( xmin, posy, zmax );
glEnd();
}
if( delta > xsize / 2.0f )
break;
}
// Draw horizontal grid lines on Z axis (parallel to X axis)
for( int ii = 0; ; ii++ )
{
if( (ii % 5) )
SetGLColor( gridcolor, transparency);
else
SetGLColor( gridcolor_marker, transparency );
double delta = ii * aGriSizeMM * IU_PER_MM * scale;
if( delta <= zmax )
{
// Draw grid lines on Z axis (positive Z axis coordinates)
glBegin( GL_LINES );
glVertex3f( xmin, posy, delta );
glVertex3f( xmax, posy, delta );
glEnd();
}
if( delta <= -zmin && ( ii != 0 ) )
{
// Draw grid lines on Z axis (negative Z axis coordinates)
glBegin( GL_LINES );
glVertex3f( xmin, posy, -delta );
glVertex3f( xmax, posy, -delta );
glEnd();
}
if( ( delta > zmax ) && ( delta > -zmin ) )
break;
}
}
// Draw 3D pads.
void EDA_3D_CANVAS::draw3DPadHole( const D_PAD* aPad )
{
// Draw the pad hole
wxSize drillsize = aPad->GetDrillSize();
bool hasHole = drillsize.x && drillsize.y;
if( !hasHole )
return;
// Store here the points to approximate hole by segments
SHAPE_POLY_SET holecornersBuffer;
int thickness = GetPrm3DVisu().GetCopperThicknessBIU();
int height = GetPrm3DVisu().GetLayerZcoordBIU( F_Cu ) -
GetPrm3DVisu().GetLayerZcoordBIU( B_Cu );
if( isRealisticMode() )
setGLCopperColor();
else
SetGLColor( DARKGRAY );
int holeZpoz = GetPrm3DVisu().GetLayerZcoordBIU( B_Cu ) - thickness / 2;
int holeHeight = height + thickness;
if( drillsize.x == drillsize.y ) // usual round hole
{
int hole_radius = ( drillsize.x + thickness ) / 2;
Draw3D_ZaxisCylinder( aPad->GetPosition(),
hole_radius, holeHeight,
thickness, holeZpoz, GetPrm3DVisu().m_BiuTo3Dunits );
}
else // Oblong hole
{
wxPoint ends_offset;
int width;
if( drillsize.x > drillsize.y ) // Horizontal oval
{
ends_offset.x = ( drillsize.x - drillsize.y ) / 2;
width = drillsize.y;
}
else // Vertical oval
{
ends_offset.y = ( drillsize.y - drillsize.x ) / 2;
width = drillsize.x;
}
RotatePoint( &ends_offset, aPad->GetOrientation() );
wxPoint start = aPad->GetPosition() + ends_offset;
wxPoint end = aPad->GetPosition() - ends_offset;
int hole_radius = ( width + thickness ) / 2;
// Draw the hole
Draw3D_ZaxisOblongCylinder( start, end, hole_radius, holeHeight,
thickness, holeZpoz, GetPrm3DVisu().m_BiuTo3Dunits );
}
}
void EDA_3D_CANVAS::draw3DViaHole( const VIA* aVia )
{
LAYER_ID top_layer, bottom_layer;
int thickness = GetPrm3DVisu().GetCopperThicknessBIU();
int inner_radius = (int)((float)aVia->GetDrillValue() * 1.01f) / 2.0f; // This add a bit more in order to correct a draw artifact while using tickness
aVia->LayerPair( &top_layer, &bottom_layer );
// Drawing via hole:
if( isRealisticMode() )
setGLCopperColor();
else
{
EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + aVia->GetViaType() );
SetGLColor( color );
}
int height = GetPrm3DVisu().GetLayerZcoordBIU( top_layer ) -
GetPrm3DVisu().GetLayerZcoordBIU( bottom_layer ) + thickness;
int zpos = GetPrm3DVisu().GetLayerZcoordBIU( bottom_layer ) - thickness / 2;
Draw3D_ZaxisCylinder( aVia->GetStart(), inner_radius, height,
thickness, zpos, GetPrm3DVisu().m_BiuTo3Dunits );
}
/* Build a pad outline as non filled polygon, to draw pads on silkscreen layer
* Used only to draw pads outlines on silkscreen layers.
*/
void EDA_3D_CANVAS::buildPadShapeThickOutlineAsPolygon( const D_PAD* aPad,
SHAPE_POLY_SET& aCornerBuffer,
int aWidth,
int aCircleToSegmentsCount,
double aCorrectionFactor )
{
if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
{
TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(),
aPad->GetSize().x / 2, aCircleToSegmentsCount, aWidth );
return;
}
// For other shapes, draw polygon outlines
SHAPE_POLY_SET corners;
aPad->BuildPadShapePolygon( corners, wxSize( 0, 0 ),
aCircleToSegmentsCount, aCorrectionFactor );
// Add outlines as thick segments in polygon buffer
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 );
TransformRoundedEndsSegmentToPolygon( aCornerBuffer,
wxPoint( a.x, a.y ),
wxPoint( b.x, b.y ),
aCircleToSegmentsCount, aWidth );
}
}
GLfloat Get3DLayer_Z_Orientation( LAYER_NUM aLayer )
{
double nZ = 1.0;
if( ( aLayer == B_Cu )
|| ( aLayer == B_Adhes )
|| ( aLayer == B_Paste )
|| ( aLayer == B_SilkS )
|| ( aLayer == B_Mask ) )
nZ = -1.0;
return nZ;
}
+97
View File
@@ -0,0 +1,97 @@
/*
* 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_enums.h
* @brief declared enumerations and flags
*/
#ifndef _3D_ENUMS_H_
#define _3D_ENUMS_H_
/// Flags used in rendering options
enum DISPLAY3D_FLG {
FL_AXIS=0, FL_ZONE,
FL_ADHESIVE, FL_SILKSCREEN, FL_SOLDERMASK, FL_SOLDERPASTE,
FL_COMMENTS, FL_ECO,
FL_MODULE_ATTRIBUTES_NORMAL,
FL_MODULE_ATTRIBUTES_NORMAL_INSERT,
FL_MODULE_ATTRIBUTES_VIRTUAL,
FL_SHOW_BOARD_BODY,
FL_MOUSEWHEEL_PANNING,
FL_USE_REALISTIC_MODE,
// OpenGL options
FL_RENDER_OPENGL_SHOW_MODEL_BBOX,
FL_RENDER_OPENGL_COPPER_THICKNESS,
// Raytracing options
FL_RENDER_RAYTRACING_SHADOWS,
FL_RENDER_RAYTRACING_BACKFLOOR,
FL_RENDER_RAYTRACING_REFRACTIONS,
FL_RENDER_RAYTRACING_REFLECTIONS,
FL_RENDER_RAYTRACING_POST_PROCESSING,
FL_RENDER_RAYTRACING_ANTI_ALIASING,
FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES,
FL_LAST
};
/// Camera types
enum CAMERA_TYPE
{
CAMERA_TRACKBALL
};
/// Grid types
enum GRID3D_TYPE
{
GRID3D_NONE,
GRID3D_1MM,
GRID3D_2P5MM,
GRID3D_5MM,
GRID3D_10MM
};
/// Render engine mode
enum RENDER_ENGINE
{
RENDER_ENGINE_OPENGL_LEGACY,
RENDER_ENGINE_RAYTRACING,
};
/// Render 3d model shape materials mode
enum MATERIAL_MODE
{
MATERIAL_MODE_NORMAL, ///< Use all material properties from model file
MATERIAL_MODE_DIFFUSE_ONLY, ///< Use only diffuse material properties
MATERIAL_MODE_CAD_MODE ///< Use a gray shading based on diffuse material
};
#endif // _3D_ENUMS_H_
+68
View File
@@ -0,0 +1,68 @@
/*
* 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
@@ -0,0 +1,176 @@
/*
* 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 <string.h>
#include <stdint.h>
#include <cmath>
// 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
-909
View File
@@ -1,909 +0,0 @@
/**
* @file 3d_frame.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
*/
#include <fctsys.h>
#include <kiface_i.h>
#include <pgm_base.h>
#include <macros.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 keyBgColor_Red_Top[] = wxT( "BgColor_Red_Top" );
static const wxChar keyBgColor_Green_Top[] = wxT( "BgColor_Green_Top" );
static const wxChar keyBgColor_Blue_Top[] = wxT( "BgColor_Blue_Top" );
static const wxChar keySMaskColor_Red[] = wxT( "SMaskColor_Red" );
static const wxChar keySMaskColor_Green[] = wxT( "SMaskColor_Green" );
static const wxChar keySMaskColor_Blue[] = wxT( "SMaskColor_Blue" );
static const wxChar keySPasteColor_Red[] = wxT( "SPasteColor_Red" );
static const wxChar keySPasteColor_Green[] = wxT( "SPasteColor_Green" );
static const wxChar keySPasteColor_Blue[] = wxT( "SPasteColor_Blue" );
static const wxChar keySilkColor_Red[] = wxT( "SilkColor_Red" );
static const wxChar keySilkColor_Green[] = wxT( "SilkColor_Green" );
static const wxChar keySilkColor_Blue[] = wxT( "SilkColor_Blue" );
static const wxChar keyCopperColor_Red[] = wxT( "CopperColor_Red" );
static const wxChar keyCopperColor_Green[] = wxT( "CopperColor_Green" );
static const wxChar keyCopperColor_Blue[] = wxT( "CopperColor_Blue" );
static const wxChar keyBoardBodyColor_Red[] = wxT( "BoardBodyColor_Red" );
static const wxChar keyBoardBodyColor_Green[] = wxT( "BoardBodyColor_Green" );
static const wxChar keyBoardBodyColor_Blue[]= wxT( "BoardBodyColor_Blue" );
static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
static const wxChar keyRenderShadows[] = wxT( "Render_Shadows" );
static const wxChar keyRenderRemoveHoles[] = wxT( "Render_RemoveHoles" );
static const wxChar keyRenderTextures[] = wxT( "Render_Textures" );
static const wxChar keyRenderSmoothNormals[] = wxT( "Render_Smooth_Normals" );
static const wxChar keyRenderUseModelNormals[] =wxT( "Render_Use_Model_Normals" );
static const wxChar keyRenderMaterial[] = wxT( "Render_Material" );
static const wxChar keyRenderShowModelBBox[] = wxT( "Render_ShowModelBoudingBoxes" );
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 status_dims[4] = { -1, 130, 130, 170 };
CreateStatusBar( DIM( status_dims ) );
SetStatusWidths( DIM( status_dims ), status_dims );
CreateMenuBar();
ReCreateMainToolbar();
// Make a EDA_3D_CANVAS
// Note: We try to use anti aliasing if the graphic card allows that,
// but only on wxWidgets >= 3.0.0 (this option does not exist on wxWidgets 2.8)
int attrs[] = { // This array should be 2*n+1
// Sadly wxwidgets / glx < 13 allowed
// a thing named "boolean attributes" that don't take a value.
// (See src/unix/glx11.cpp -> wxGLCanvasX11::ConvertWXAttrsToGL() ).
// To avoid problems due to this, just specify those attributes twice.
// Only WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_STEREO are such boolean
// attributes.
// Boolean attributes (using itself at padding):
WX_GL_RGBA, WX_GL_RGBA,
WX_GL_DOUBLEBUFFER, WX_GL_DOUBLEBUFFER,
// Normal attributes with values:
WX_GL_DEPTH_SIZE, 16,
WX_GL_STENCIL_SIZE, 1,
WX_GL_SAMPLE_BUFFERS, 1, // Enable multisampling support (antialiasing).
WX_GL_SAMPLES, 0, // Disable AA for the start.
0 }; // NULL termination
// Check if the canvas supports multisampling.
if( EDA_3D_CANVAS::IsDisplaySupported( attrs ) )
{
// Check for possible sample sizes, start form the top.
int maxSamples = 8; // Any higher doesn't change anything.
int samplesOffset = 0;
for( unsigned int ii = 0; ii < DIM( attrs ); ii += 2 )
{
if( attrs[ii] == WX_GL_SAMPLES )
{
samplesOffset = ii+1;
break;
}
}
attrs[samplesOffset] = maxSamples;
for( ; maxSamples > 0 && !EDA_3D_CANVAS::IsDisplaySupported( attrs );
maxSamples = maxSamples>>1 )
{
attrs[samplesOffset] = maxSamples;
}
}
else
{
// Disable multisampling
for( unsigned int ii = 0; ii < DIM( attrs ); ii += 2 )
{
if( attrs[ii] == WX_GL_SAMPLE_BUFFERS )
{
attrs[ii+1] = 0;
break;
}
}
}
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 = GetPrm3DVisu();
aCfg->Read( keyBgColor_Red, &GetPrm3DVisu().m_BgColor.m_Red, 0.4 );
aCfg->Read( keyBgColor_Green, &GetPrm3DVisu().m_BgColor.m_Green, 0.4 );
aCfg->Read( keyBgColor_Blue, &GetPrm3DVisu().m_BgColor.m_Blue, 0.5 );
aCfg->Read( keyBgColor_Red_Top, &GetPrm3DVisu().m_BgColor_Top.m_Red, 0.8 );
aCfg->Read( keyBgColor_Green_Top, &GetPrm3DVisu().m_BgColor_Top.m_Green, 0.8 );
aCfg->Read( keyBgColor_Blue_Top, &GetPrm3DVisu().m_BgColor_Top.m_Blue, 0.9 );
// m_SolderMaskColor default value = dark grey-green
aCfg->Read( keySMaskColor_Red, &GetPrm3DVisu().m_SolderMaskColor.m_Red, 100.0 * 0.2 / 255.0 );
aCfg->Read( keySMaskColor_Green, &GetPrm3DVisu().m_SolderMaskColor.m_Green, 255.0 * 0.2 / 255.0 );
aCfg->Read( keySMaskColor_Blue, &GetPrm3DVisu().m_SolderMaskColor.m_Blue, 180.0 * 0.2 / 255.0 );
// m_SolderPasteColor default value = light grey
aCfg->Read( keySPasteColor_Red, &GetPrm3DVisu().m_SolderPasteColor.m_Red, 128.0 /255.0 );
aCfg->Read( keySPasteColor_Green, &GetPrm3DVisu().m_SolderPasteColor.m_Green, 128.0 /255.0 );
aCfg->Read( keySPasteColor_Blue, &GetPrm3DVisu().m_SolderPasteColor.m_Blue, 128.0 /255.0 );
// m_SilkScreenColor default value = white
aCfg->Read( keySilkColor_Red, &GetPrm3DVisu().m_SilkScreenColor.m_Red, 0.9 );
aCfg->Read( keySilkColor_Green, &GetPrm3DVisu().m_SilkScreenColor.m_Green, 0.9 );
aCfg->Read( keySilkColor_Blue, &GetPrm3DVisu().m_SilkScreenColor.m_Blue, 0.9 );
// m_CopperColor default value = gold
aCfg->Read( keyCopperColor_Red, &GetPrm3DVisu().m_CopperColor.m_Red, 255.0 * 0.7 / 255.0 );
aCfg->Read( keyCopperColor_Green, &GetPrm3DVisu().m_CopperColor.m_Green, 223.0 * 0.7 / 255.0 );
aCfg->Read( keyCopperColor_Blue, &GetPrm3DVisu().m_CopperColor.m_Blue, 0.0 /255.0 );
// m_BoardBodyColor default value = FR4, in realistic mode
aCfg->Read( keyBoardBodyColor_Red, &GetPrm3DVisu().m_BoardBodyColor.m_Red, 51.0 / 255.0 );
aCfg->Read( keyBoardBodyColor_Green, &GetPrm3DVisu().m_BoardBodyColor.m_Green, 43.0 / 255.0 );
aCfg->Read( keyBoardBodyColor_Blue, &GetPrm3DVisu().m_BoardBodyColor.m_Blue, 22.0 /255.0 );
bool tmp;
aCfg->Read( keyShowRealisticMode, &tmp, false );
prms.SetFlag( FL_USE_REALISTIC_MODE, tmp );
aCfg->Read( keyRenderShadows, &tmp, false );
prms.SetFlag( FL_RENDER_SHADOWS, tmp );
aCfg->Read( keyRenderRemoveHoles, &tmp, false );
prms.SetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES, tmp );
aCfg->Read( keyRenderTextures, &tmp, false );
prms.SetFlag( FL_RENDER_TEXTURES, tmp );
aCfg->Read( keyRenderSmoothNormals, &tmp, false );
prms.SetFlag( FL_RENDER_SMOOTH_NORMALS, tmp );
aCfg->Read( keyRenderUseModelNormals, &tmp, false );
prms.SetFlag( FL_RENDER_USE_MODEL_NORMALS, tmp );
aCfg->Read( keyRenderMaterial, &tmp, false );
prms.SetFlag( FL_RENDER_MATERIAL, tmp );
aCfg->Read( keyRenderShowModelBBox, &tmp, false );
prms.SetFlag( FL_RENDER_SHOW_MODEL_BBOX, 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 );
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 = GetPrm3DVisu();
aCfg->Write( keyBgColor_Red, GetPrm3DVisu().m_BgColor.m_Red );
aCfg->Write( keyBgColor_Green, GetPrm3DVisu().m_BgColor.m_Green );
aCfg->Write( keyBgColor_Blue, GetPrm3DVisu().m_BgColor.m_Blue );
aCfg->Write( keyBgColor_Red_Top, GetPrm3DVisu().m_BgColor_Top.m_Red );
aCfg->Write( keyBgColor_Green_Top, GetPrm3DVisu().m_BgColor_Top.m_Green );
aCfg->Write( keyBgColor_Blue_Top, GetPrm3DVisu().m_BgColor_Top.m_Blue );
aCfg->Write( keySMaskColor_Red, GetPrm3DVisu().m_SolderMaskColor.m_Red );
aCfg->Write( keySMaskColor_Green, GetPrm3DVisu().m_SolderMaskColor.m_Green );
aCfg->Write( keySMaskColor_Blue, GetPrm3DVisu().m_SolderMaskColor.m_Blue );
aCfg->Write( keySPasteColor_Red, GetPrm3DVisu().m_SolderPasteColor.m_Red );
aCfg->Write( keySPasteColor_Green, GetPrm3DVisu().m_SolderPasteColor.m_Green );
aCfg->Write( keySPasteColor_Blue, GetPrm3DVisu().m_SolderPasteColor.m_Blue );
aCfg->Write( keySilkColor_Red, GetPrm3DVisu().m_SilkScreenColor.m_Red );
aCfg->Write( keySilkColor_Green, GetPrm3DVisu().m_SilkScreenColor.m_Green );
aCfg->Write( keySilkColor_Blue, GetPrm3DVisu().m_SilkScreenColor.m_Blue );
aCfg->Write( keyCopperColor_Red, GetPrm3DVisu().m_CopperColor.m_Red );
aCfg->Write( keyCopperColor_Green, GetPrm3DVisu().m_CopperColor.m_Green );
aCfg->Write( keyCopperColor_Blue, GetPrm3DVisu().m_CopperColor.m_Blue );
aCfg->Write( keyBoardBodyColor_Red, GetPrm3DVisu().m_BoardBodyColor.m_Red );
aCfg->Write( keyBoardBodyColor_Green, GetPrm3DVisu().m_BoardBodyColor.m_Green );
aCfg->Write( keyBoardBodyColor_Blue, GetPrm3DVisu().m_BoardBodyColor.m_Blue );
aCfg->Write( keyShowRealisticMode, prms.GetFlag( FL_USE_REALISTIC_MODE ) );
aCfg->Write( keyRenderShadows, prms.GetFlag( FL_RENDER_SHADOWS ) );
aCfg->Write( keyRenderRemoveHoles, prms.GetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES ) );
aCfg->Write( keyRenderTextures, prms.GetFlag( FL_RENDER_TEXTURES ) );
aCfg->Write( keyRenderSmoothNormals, prms.GetFlag( FL_RENDER_SMOOTH_NORMALS ) );
aCfg->Write( keyRenderUseModelNormals, prms.GetFlag( FL_RENDER_USE_MODEL_NORMALS ) );
aCfg->Write( keyRenderMaterial, prms.GetFlag( FL_RENDER_MATERIAL ) );
aCfg->Write( keyRenderShowModelBBox, prms.GetFlag( FL_RENDER_SHOW_MODEL_BBOX ) );
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++ )
GetPrm3DVisu().m_Rot[ii] = 0.0;
GetPrm3DVisu().m_Zoom = 1.0;
m_canvas->SetOffset( 0.0, 0.0 );
trackball( GetPrm3DVisu().m_Quat, 0.0, 0.0, 0.0, 0.0 );
break;
case ID_ZOOM_IN:
GetPrm3DVisu().m_Zoom /= 1.2;
if( GetPrm3DVisu().m_Zoom <= 0.01 )
GetPrm3DVisu().m_Zoom = 0.01;
break;
case ID_ZOOM_OUT:
GetPrm3DVisu().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:
m_reloadRequest = true;
NewDisplay();
return;
break;
case ID_ROTATE3D_X_POS:
GetPrm3DVisu().m_ROTX += ROT_ANGLE;
break;
case ID_ROTATE3D_X_NEG:
GetPrm3DVisu().m_ROTX -= ROT_ANGLE;
break;
case ID_ROTATE3D_Y_POS:
GetPrm3DVisu().m_ROTY += ROT_ANGLE;
break;
case ID_ROTATE3D_Y_NEG:
GetPrm3DVisu().m_ROTY -= ROT_ANGLE;
break;
case ID_ROTATE3D_Z_POS:
GetPrm3DVisu().m_ROTZ += ROT_ANGLE;
break;
case ID_ROTATE3D_Z_NEG:
GetPrm3DVisu().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_BOTTOM_SELECTION:
if( Set3DColorFromUser( GetPrm3DVisu().m_BgColor, _( "Background Color, Bottom" ) ) )
m_canvas->Refresh( true );
return;
case ID_MENU3D_BGCOLOR_TOP_SELECTION:
if( Set3DColorFromUser( GetPrm3DVisu().m_BgColor_Top, _( "Background Color, Top" ) ) )
m_canvas->Refresh( true );
return;
case ID_MENU3D_SILKSCREEN_COLOR_SELECTION:
Set3DSilkScreenColorFromUser();
return;
case ID_MENU3D_SOLDERMASK_COLOR_SELECTION:
Set3DSolderMaskColorFromUser();
return;
case ID_MENU3D_SOLDERPASTE_COLOR_SELECTION:
Set3DSolderPasteColorFromUser();
return;
case ID_MENU3D_COPPER_COLOR_SELECTION:
Set3DCopperColorFromUser();
break;
case ID_MENU3D_PCB_BODY_COLOR_SELECTION:
Set3DBoardBodyColorFromUser();
break;
case ID_MENU3D_REALISTIC_MODE:
GetPrm3DVisu().SetFlag( FL_USE_REALISTIC_MODE, isChecked );
GetMenuBar()->FindItem( ID_MENU3D_COMMENTS_ONOFF )->Enable( !isChecked );
GetMenuBar()->FindItem( ID_MENU3D_ECO_ONOFF )->Enable( !isChecked );
NewDisplay();
return;
case ID_MENU3D_FL_RENDER_SHADOWS:
GetPrm3DVisu().SetFlag( FL_RENDER_SHADOWS, isChecked );
NewDisplay();
return;
case ID_MENU3D_FL_RENDER_SHOW_HOLES_IN_ZONES:
GetPrm3DVisu().SetFlag( FL_RENDER_SHOW_HOLES_IN_ZONES, isChecked );
NewDisplay();
return;
case ID_MENU3D_FL_RENDER_TEXTURES:
GetPrm3DVisu().SetFlag( FL_RENDER_TEXTURES, isChecked );
NewDisplay(GL_ID_BOARD);
NewDisplay(GL_ID_TECH_LAYERS);
return;
case ID_MENU3D_FL_RENDER_SMOOTH_NORMALS:
GetPrm3DVisu().SetFlag( FL_RENDER_SMOOTH_NORMALS, isChecked );
NewDisplay();
return;
case ID_MENU3D_FL_RENDER_USE_MODEL_NORMALS:
GetPrm3DVisu().SetFlag( FL_RENDER_USE_MODEL_NORMALS, isChecked );
NewDisplay();
return;
case ID_MENU3D_FL_RENDER_MATERIAL:
GetPrm3DVisu().SetFlag( FL_RENDER_MATERIAL, isChecked );
NewDisplay();
return;
case ID_MENU3D_FL_RENDER_SHOW_MODEL_BBOX:
GetPrm3DVisu().SetFlag( FL_RENDER_SHOW_MODEL_BBOX, isChecked );
NewDisplay();
return;
case ID_MENU3D_SHOW_BOARD_BODY:
GetPrm3DVisu().SetFlag( FL_SHOW_BOARD_BODY, isChecked );
NewDisplay();
return;
case ID_MENU3D_AXIS_ONOFF:
GetPrm3DVisu().SetFlag( FL_AXIS, isChecked );
m_canvas->Refresh();
return;
case ID_MENU3D_MODULE_ONOFF:
GetPrm3DVisu().SetFlag( FL_MODULE, isChecked );
m_canvas->Refresh();
return;
case ID_MENU3D_USE_COPPER_THICKNESS:
GetPrm3DVisu().SetFlag( FL_USE_COPPER_THICKNESS, isChecked );
NewDisplay( GL_ID_BOARD );
NewDisplay( GL_ID_TECH_LAYERS );
return;
case ID_MENU3D_ZONE_ONOFF:
GetPrm3DVisu().SetFlag( FL_ZONE, isChecked );
NewDisplay( GL_ID_BOARD );
return;
case ID_MENU3D_ADHESIVE_ONOFF:
GetPrm3DVisu().SetFlag( FL_ADHESIVE, isChecked );
NewDisplay( GL_ID_TECH_LAYERS );
return;
case ID_MENU3D_SILKSCREEN_ONOFF:
GetPrm3DVisu().SetFlag( FL_SILKSCREEN, isChecked );
NewDisplay( GL_ID_TECH_LAYERS );
return;
case ID_MENU3D_SOLDER_MASK_ONOFF:
GetPrm3DVisu().SetFlag( FL_SOLDERMASK, isChecked );
NewDisplay( GL_ID_TECH_LAYERS );
return;
case ID_MENU3D_SOLDER_PASTE_ONOFF:
GetPrm3DVisu().SetFlag( FL_SOLDERPASTE, isChecked );
NewDisplay( GL_ID_TECH_LAYERS );
return;
case ID_MENU3D_COMMENTS_ONOFF:
GetPrm3DVisu().SetFlag( FL_COMMENTS, isChecked );
NewDisplay( GL_ID_AUX_LAYERS );
return;
case ID_MENU3D_ECO_ONOFF:
GetPrm3DVisu().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_NOGRID; ii < ID_MENU3D_GRID_END; ii++ )
{
if( event.GetId() == ii )
continue;
GetMenuBar()->Check( ii, false );
}
switch( id )
{
case ID_MENU3D_GRID_NOGRID:
GetPrm3DVisu().SetFlag( FL_GRID, false );
break;
case ID_MENU3D_GRID_10_MM:
GetPrm3DVisu().SetFlag( FL_GRID, true );
GetPrm3DVisu().m_3D_Grid = 10.0;
break;
case ID_MENU3D_GRID_5_MM:
GetPrm3DVisu().SetFlag( FL_GRID, true );
GetPrm3DVisu().m_3D_Grid = 5.0;
break;
case ID_MENU3D_GRID_2P5_MM:
GetPrm3DVisu().SetFlag( FL_GRID, true );
GetPrm3DVisu().m_3D_Grid = 2.5;
break;
case ID_MENU3D_GRID_1_MM:
GetPrm3DVisu().SetFlag( FL_GRID, true );
GetPrm3DVisu().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( int aGlList )
{
m_canvas->ClearLists( aGlList );
// Rebuild the 3D board and refresh the view on reload request:
if( m_reloadRequest )
m_canvas->ReportWarnings( true );
m_canvas->Refresh( true );
m_canvas->DisplayStatus();
m_reloadRequest = false;
}
void EDA_3D_FRAME::OnActivate( wxActivateEvent& event )
{
// Reload data if 3D frame shows a board,
// 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
*/
bool EDA_3D_FRAME::Set3DColorFromUser( S3D_COLOR &aColor, const wxString& aTitle,
wxColourData* aPredefinedColors )
{
wxColour newcolor, oldcolor;
oldcolor.Set( KiROUND( aColor.m_Red * 255 ),
KiROUND( aColor.m_Green * 255 ),
KiROUND( aColor.m_Blue * 255 ) );
wxColourData emptyColorSet; // Provides a empty predefined set of colors
// if no color set available to avoid use of an
// old color set
if( aPredefinedColors == NULL )
aPredefinedColors = &emptyColorSet;
newcolor = wxGetColourFromUser( this, oldcolor, aTitle, aPredefinedColors );
if( !newcolor.IsOk() ) // Cancel command
return false;
if( newcolor != oldcolor )
{
aColor.m_Red = (double) newcolor.Red() / 255.0;
aColor.m_Green = (double) newcolor.Green() / 255.0;
aColor.m_Blue = (double) newcolor.Blue() / 255.0;
}
return true;
}
/* called to set the silkscreen color. Sets up a number of default colors
*/
bool EDA_3D_FRAME::Set3DSilkScreenColorFromUser()
{
wxColourData definedColors;
definedColors.SetCustomColour(0, wxColour( 241, 241, 241 ) ); // White
definedColors.SetCustomColour(1, wxColour( 180, 180, 180 ) ); // Gray
bool change = Set3DColorFromUser( GetPrm3DVisu().m_SilkScreenColor,
_( "Silk Screen Color" ),
&definedColors );
if( change )
NewDisplay( GL_ID_TECH_LAYERS );
return change;
}
/* called to set the soldermask color. Sets up a number of default colors
*/
bool EDA_3D_FRAME::Set3DSolderMaskColorFromUser()
{
wxColourData definedColors;
definedColors.SetCustomColour(0, wxColour( 20, 51, 36 ) ); // Green
definedColors.SetCustomColour(1, wxColour( 43, 10, 65 ) ); // Purple
definedColors.SetCustomColour(2, wxColour( 117, 19, 21 ) ); // Red
definedColors.SetCustomColour(3, wxColour( 54, 79, 116) ); // Light blue
definedColors.SetCustomColour(4, wxColour( 11, 11, 11 ) ); // Black
definedColors.SetCustomColour(5, wxColour( 241, 241,241) ); // White
bool change = Set3DColorFromUser( GetPrm3DVisu().m_SolderMaskColor,
_( "Solder Mask Color" ),
&definedColors );
if( change )
NewDisplay( GL_ID_TECH_LAYERS );
return change;
}
/* called to set the copper surface color. Sets up a number of default colors
*/
bool EDA_3D_FRAME::Set3DCopperColorFromUser()
{
wxColourData definedColors;
definedColors.SetCustomColour( 0, wxColour( 184, 115, 50 ) ); // Copper
definedColors.SetCustomColour( 1, wxColour( 233, 221, 82 ) ); // Gold
definedColors.SetCustomColour( 2, wxColour( 213, 213, 213) ); // Silver
definedColors.SetCustomColour( 3, wxColour( 160, 160, 160) ); // tin
bool change = Set3DColorFromUser( GetPrm3DVisu().m_CopperColor,
_( "Copper Color" ),
&definedColors );
if( change )
NewDisplay( GL_ID_BOARD );
return change;
}
/* called to set the board body color. Sets up a number of default colors
*/
bool EDA_3D_FRAME::Set3DBoardBodyColorFromUser()
{
wxColourData definedColors;
definedColors.SetCustomColour( 0, wxColour( 51, 43, 22 ) ); // FR4 natural, dark
definedColors.SetCustomColour( 1, wxColour( 109, 116, 75 ) ); // FR4 natural
definedColors.SetCustomColour( 2, wxColour( 78, 14, 5 ) ); // brown/red
definedColors.SetCustomColour( 3, wxColour( 146, 99, 47 ) ); // brown 1
definedColors.SetCustomColour( 4, wxColour( 160, 123, 54 ) ); // brown 2
definedColors.SetCustomColour( 5, wxColour( 146, 99, 47 ) ); // brown 3
definedColors.SetCustomColour( 6, wxColour( 63, 126, 71 ) ); // green 1
definedColors.SetCustomColour( 7, wxColour( 117, 122, 90 ) ); // green 2
bool change = Set3DColorFromUser( GetPrm3DVisu().m_BoardBodyColor,
_( "Board Body Color" ),
&definedColors );
if( change )
NewDisplay( GL_ID_BOARD );
return change;
}
/* called to set the solder paste layer color. Sets up a number of default colors
*/
bool EDA_3D_FRAME::Set3DSolderPasteColorFromUser()
{
wxColourData definedColors;
definedColors.SetCustomColour(0, wxColour( 128, 128, 128 ) ); // grey
definedColors.SetCustomColour(1, wxColour( 213, 213, 213 ) ); // Silver
definedColors.SetCustomColour(2, wxColour( 90, 90, 90 ) ); // grey 2
bool change = Set3DColorFromUser( GetPrm3DVisu().m_SolderPasteColor,
_( "Solder Paste Color" ),
&definedColors );
if( change )
NewDisplay( GL_ID_TECH_LAYERS );
return change;
}
BOARD* EDA_3D_FRAME::GetBoard()
{
return Parent()->GetBoard();
}
INFO3D_VISU& EDA_3D_FRAME::GetPrm3DVisu() const
{
// return the INFO3D_VISU which contains the current parameters
// to draw the 3D view of the board
return g_Parm_3D_Visu;
}
bool EDA_3D_FRAME::IsEnabled( DISPLAY3D_FLG aItem ) const
{
// return true if aItem must be displayed
return GetPrm3DVisu().GetFlag( aItem );
}
-156
View File
@@ -1,156 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2015 Mario Luzeiro <mrluzeiro@gmail.com>
* 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_class.cpp
*/
#include <fctsys.h>
#include <3d_struct.h>
#include <3d_material.h>
#include <info3d_visu.h>
#ifdef __WXMAC__
# ifdef __DARWIN__
# include <OpenGL/glu.h>
# else
# include <glu.h>
# endif
#else
# include <GL/glu.h>
#endif
S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) :
EDA_ITEM( father, NOT_USED )
{
m_Name = name;
m_AmbientColor.clear();
m_DiffuseColor.clear();
m_EmissiveColor.clear();
m_SpecularColor.clear();
m_Shininess.clear();
m_Transparency.clear();
m_ColorPerVertex = false;
}
void SetOpenGlDefaultMaterial()
{
glm::vec4 ambient( 0.2f, 0.2f, 0.2f, 1.0f );
glm::vec4 specular( 0.0f, 0.0f, 0.0f, 1.0f );
glm::vec4 emissive( 0.0f, 0.0f, 0.0f, 1.0f );
glm::vec4 diffuse( 0.0f, 0.0f, 0.0f, 1.0f );
GLint shininess_value = 0;
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
glMateriali ( GL_FRONT_AND_BACK, GL_SHININESS, shininess_value );
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.x );
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x );
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.x );
glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.x );
}
bool S3D_MATERIAL::SetOpenGLMaterial( unsigned int aMaterialIndex, bool aUseMaterial )
{
if( aUseMaterial )
{
float transparency_value = 0.0f;
if( m_Transparency.size() > aMaterialIndex )
{
transparency_value = m_Transparency[aMaterialIndex];
}
else
{
if( m_Transparency.size() > 0 )
transparency_value = m_Transparency[0];
}
if( m_DiffuseColor.size() > aMaterialIndex )
{
glm::vec3 color = m_DiffuseColor[aMaterialIndex];
glColor4f( color.x, color.y, color.z, 1.0f - transparency_value );
}
else
{
if( m_DiffuseColor.size() == 0 )
{
glColor4f( 0.8f, 0.8f, 0.8f, 1.0f );
}
}
if( m_Shininess.size() > 0 )
{
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, m_Shininess[0] );
}
// emissive
if( m_EmissiveColor.size() > aMaterialIndex )
{
glm::vec4 emissive;
emissive[0] = m_EmissiveColor[aMaterialIndex].x;
emissive[1] = m_EmissiveColor[aMaterialIndex].y;
emissive[2] = m_EmissiveColor[aMaterialIndex].z;
emissive[3] = 1.0f;
glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.x );
}
// specular
if( m_SpecularColor.size() > aMaterialIndex )
{
glm::vec4 specular;
specular[0] = m_SpecularColor[aMaterialIndex].x;
specular[1] = m_SpecularColor[aMaterialIndex].y;
specular[2] = m_SpecularColor[aMaterialIndex].z;
specular[3] = 1.0f;
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x );
}
// ambient
if( m_AmbientColor.size() > aMaterialIndex )
{
glm::vec4 ambient;
ambient[0] = m_AmbientColor[aMaterialIndex].x;
ambient[1] = m_AmbientColor[aMaterialIndex].y;
ambient[2] = m_AmbientColor[aMaterialIndex].z;
ambient[3] = 1.0f;
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.x );
}
return (transparency_value != 0.0f);
}
else
{
if( m_DiffuseColor.size() > aMaterialIndex )
{
glm::vec3 color = m_DiffuseColor[aMaterialIndex];
glColor4f( color.x, color.y, color.z, 1.0 );
}
}
return false;
}
-83
View File
@@ -1,83 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2015 Mario Luzeiro <mrluzeiro@gmail.com>
* Copyright (C) 1992-2014 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_material.h
*/
#ifndef STRUCT_3D_MATERIAL_H
#define STRUCT_3D_MATERIAL_H
#include <common.h>
#include <base_struct.h>
#define GLM_FORCE_RADIANS
#include <gal/opengl/glm/glm.hpp>
class S3D_MASTER;
class S3D_MATERIAL : public EDA_ITEM // openGL "material" data
{
public:
wxString m_Name;
// Material list
std::vector< glm::vec3 > m_AmbientColor;
std::vector< glm::vec3 > m_DiffuseColor;
std::vector< glm::vec3 > m_EmissiveColor;
std::vector< glm::vec3 > m_SpecularColor;
std::vector< float > m_Shininess;
std::vector< float > m_Transparency;
bool m_ColorPerVertex;
public:
S3D_MATERIAL( S3D_MASTER* father, const wxString& name );
S3D_MATERIAL* Next() const { return (S3D_MATERIAL*) Pnext; }
S3D_MATERIAL* Back() const { return (S3D_MATERIAL*) Pback; }
/**
* Initialize the material prms.
* @param aMaterialIndex = the index in list of available materials
* @param aUseMaterial = true to use the values found in the available material
* = false to use only the color, and other prms are fixed
* @return true if the material is transparency
*/
bool SetOpenGLMaterial(unsigned int aMaterialIndex, bool aUseMaterial);
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif
/** Get class name
* @return string "S3D_MATERIAL"
*/
virtual wxString GetClass() const
{
return wxT( "S3D_MATERIAL" );
}
};
void SetOpenGlDefaultMaterial();
#endif
+31
View File
@@ -0,0 +1,31 @@
/*
* 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"
+193
View File
@@ -0,0 +1,193 @@
/*
* 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_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
/**
* @brief SphericalToCartesian
* @param aInclination θ ∈ [0, π]
* @param aAzimuth φ ∈ [0, 2π]
* @return Cartesian cordinates
*/
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 ) );
}
// https://pathtracing.wordpress.com/2011/03/03/cosine-weighted-hemisphere/
// !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 );
}
/**
* @brief Refract
* 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
File diff suppressed because it is too large Load Diff
-107
View File
@@ -1,107 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2015 Mario Luzeiro <mrluzeiro@gmail.com>
* Copyright (C) 1992-2014 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_mesh_model.h
* @brief
*/
#ifndef __3D_MESH_MODEL_H__
#define __3D_MESH_MODEL_H__
#include <memory>
#include <boost/shared_ptr.hpp>
#include <vector>
#define GLM_FORCE_RADIANS
#include <gal/opengl/glm/glm.hpp>
#include "3d_struct.h"
#include "3d_material.h"
#include "CBBox.h"
class S3D_MESH;
/** A smart pointer to an S3D_MESH object */
typedef boost::shared_ptr<S3D_MESH> S3D_MESH_PTR;
/** A container of smar S3D_MESH object pointers */
typedef std::vector<S3D_MESH_PTR> S3D_MESH_PTRS;
class S3D_MESH
{
public:
S3D_MESH();
~S3D_MESH();
void openGL_RenderAllChilds( bool aIsRenderingJustNonTransparentObjects,
bool aIsRenderingJustTransparentObjects );
S3D_MATERIAL *m_Materials;
// Point and index list
std::vector< S3D_VERTEX > m_Point;
std::vector< std::vector<int> > m_CoordIndex;
std::vector< std::vector<int> > m_NormalIndex;
std::vector< S3D_VERTEX > m_PerFaceColor;
std::vector< S3D_VERTEX > m_PerFaceNormalsNormalized;
std::vector< S3D_VERTEX > m_PerVertexNormalsNormalized;
std::vector< int > m_MaterialIndexPerFace;
std::vector< std::vector<int> > m_MaterialIndexPerVertex;
S3D_MESH_PTRS childs;
S3D_VERTEX m_translation;
glm::vec4 m_rotation;
S3D_VERTEX m_scale;
CBBOX &getBBox();
private:
std::vector< S3D_VERTEX > m_PerFaceNormalsRaw_X_PerFaceSquaredArea;
std::vector< std::vector< S3D_VERTEX > > m_PerFaceVertexNormals;
std::vector< S3D_VERTEX > m_PointNormalized;
std::vector< std::vector<int> > m_InvalidCoordIndexes; //!TODO: check for invalid CoordIndex in file and remove the index and the same material index
bool isPerFaceNormalsComputed;
void calcPerFaceNormals ();
bool isPointNormalizedComputed;
void calcPointNormalized();
bool isPerPointNormalsComputed;
void calcPerPointNormals();
bool isPerVertexNormalsVerified;
void perVertexNormalsVerify_and_Repair();
void calcBBox();
void calcBBoxAllChilds();
CBBOX m_BBox;
void openGL_Render( bool aIsRenderingJustNonTransparentObjects,
bool aIsRenderingJustTransparentObjects );
};
#endif
@@ -0,0 +1,471 @@
/*
* 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-2017 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.cpp
* @brief Implements a model viewer canvas. The propose of model viewer is to
* render 3d models that come in the original data from the files without any
* transformations.
*/
#include <iostream>
#include "3d_rendering/3d_render_ogl_legacy/c_ogl_3dmodel.h"
#include "c3d_model_viewer.h"
#include "../3d_rendering/3d_render_ogl_legacy/ogl_legacy_utils.h"
#include "../3d_cache/3d_cache.h"
#include "common_ogl/ogl_utils.h"
#include <wx/dcclient.h>
#include <base_units.h>
#include <gl_context_mgr.h>
/**
* Scale convertion from 3d model units to pcb units
*/
#define UNITS3D_TO_UNITSPCB (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.
*/
const wxChar * C3D_MODEL_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_MODEL_VIEWER" );
BEGIN_EVENT_TABLE( C3D_MODEL_VIEWER, wxGLCanvas )
EVT_PAINT( C3D_MODEL_VIEWER::OnPaint )
// mouse events
EVT_LEFT_DOWN( C3D_MODEL_VIEWER::OnLeftDown )
EVT_LEFT_UP( C3D_MODEL_VIEWER::OnLeftUp )
EVT_MIDDLE_UP( C3D_MODEL_VIEWER::OnMiddleUp )
EVT_MIDDLE_DOWN(C3D_MODEL_VIEWER::OnMiddleDown)
EVT_RIGHT_DOWN( C3D_MODEL_VIEWER::OnRightClick )
EVT_MOUSEWHEEL( C3D_MODEL_VIEWER::OnMouseWheel )
EVT_MOTION( C3D_MODEL_VIEWER::OnMouseMove )
#ifdef USE_OSX_MAGNIFY_EVENT
EVT_MAGNIFY( C3D_MODEL_VIEWER::OnMagnify )
#endif
// other events
EVT_ERASE_BACKGROUND( C3D_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
C3D_MODEL_VIEWER::C3D_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 * 2.0f ),
m_cacheManager(aCacheManager)
{
wxLogTrace( m_logTrace, wxT( "C3D_MODEL_VIEWER::C3D_MODEL_VIEWER" ) );
m_ogl_initialized = false;
m_reload_is_needed = false;
m_ogl_3dmodel = NULL;
m_3d_model = NULL;
m_BiuTo3Dunits = 1.0;
m_glRC = NULL;
}
C3D_MODEL_VIEWER::~C3D_MODEL_VIEWER()
{
wxLogTrace( m_logTrace, wxT( "C3D_MODEL_VIEWER::~C3D_MODEL_VIEWER" ) );
if( m_glRC )
{
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
delete m_ogl_3dmodel;
m_ogl_3dmodel = NULL;
GL_CONTEXT_MANAGER::Get().UnlockCtx( m_glRC );
GL_CONTEXT_MANAGER::Get().DestroyCtx( m_glRC );
}
}
void C3D_MODEL_VIEWER::Set3DModel( const S3DMODEL &a3DModel )
{
wxLogTrace( m_logTrace, wxT( "C3D_MODEL_VIEWER::Set3DModel with a S3DMODEL" ) );
// Validate a3DModel pointers
wxASSERT( a3DModel.m_Materials != NULL );
wxASSERT( a3DModel.m_Meshes != NULL );
wxASSERT( a3DModel.m_MaterialsSize > 0 );
wxASSERT( a3DModel.m_MeshesSize > 0 );
// Delete the old model
delete m_ogl_3dmodel;
m_ogl_3dmodel = NULL;
m_3d_model = NULL;
if( (a3DModel.m_Materials != NULL) && (a3DModel.m_Meshes != NULL) &&
(a3DModel.m_MaterialsSize > 0) && (a3DModel.m_MeshesSize > 0) )
{
m_3d_model = &a3DModel;
m_reload_is_needed = true;
}
Refresh();
}
void C3D_MODEL_VIEWER::Set3DModel(const wxString &aModelPathName)
{
wxLogTrace( m_logTrace, wxT( "C3D_MODEL_VIEWER::Set3DModel with a wxString" ) );
if( m_cacheManager )
{
const S3DMODEL* model = m_cacheManager->GetModel( aModelPathName );
if( model )
Set3DModel( (const S3DMODEL &)*model );
else
Clear3DModel();
}
}
void C3D_MODEL_VIEWER::Clear3DModel()
{
// Delete the old model
m_reload_is_needed = false;
delete m_ogl_3dmodel;
m_ogl_3dmodel = NULL;
m_3d_model = NULL;
Refresh();
}
void C3D_MODEL_VIEWER::ogl_initialize()
{
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 );
//glDepthFunc( GL_LEQUAL );
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 C3D_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 C3D_MODEL_VIEWER::OnPaint( wxPaintEvent &event )
{
wxPaintDC( this );
event.Skip( false );
// SwapBuffer requires the window to be shown before calling
if( !IsShownOnScreen() )
{
wxLogTrace( m_logTrace, wxT( "C3D_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 == NULL )
m_glRC = GL_CONTEXT_MANAGER::Get().CreateCtx( this );
GL_CONTEXT_MANAGER::Get().LockCtx( m_glRC, this );
// Set the OpenGL viewport according to the client size of this canvas.
// This is done here rather than in a wxSizeEvent handler because our
// 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 = GetClientSize();
if( !m_ogl_initialized )
{
m_ogl_initialized = true;
ogl_initialize();
}
if( m_reload_is_needed )
{
wxLogTrace( m_logTrace, wxT( "C3D_MODEL_VIEWER::OnPaint m_reload_is_needed" ) );
m_reload_is_needed = false;
m_ogl_3dmodel = new C_OGL_3DMODEL( *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 matrixes
// /////////////////////////////////////////////////////////////////////////
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->Draw_opaque();
m_ogl_3dmodel->Draw_transparent();
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 );
OGL_draw_arrow( 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 );
OGL_draw_arrow( 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 );
OGL_draw_arrow( 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 C3D_MODEL_VIEWER::OnEraseBackground( wxEraseEvent &event )
{
wxLogTrace( m_logTrace, wxT( "C3D_MODEL_VIEWER::OnEraseBackground" ) );
// Do nothing, to avoid flashing.
}
void C3D_MODEL_VIEWER::OnMouseWheel( wxMouseEvent &event )
{
wxLogTrace( m_logTrace, wxT( "C3D_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 C3D_MODEL_VIEWER::OnMagnify( wxMouseEvent& event )
{
/*
double magnification = ( event.GetMagnification() + 1.0f );
GetPrm3DVisu().m_Zoom /= magnification;
if( GetPrm3DVisu().m_Zoom <= 0.01 )
GetPrm3DVisu().m_Zoom = 0.01;
DisplayStatus();
Refresh( false );
*/
}
#endif
void C3D_MODEL_VIEWER::OnMouseMove( wxMouseEvent &event )
{
m_trackBallCamera.SetCurWindowSize( GetClientSize() );
if( event.Dragging() )
{
if( event.LeftIsDown() ) // Drag
m_trackBallCamera.Drag( event.GetPosition() );
//else if( event.MiddleIsDown() ) // Pan
// m_trackBallCamera.Pan( event.GetPosition() );
// orientation has changed, redraw mesh
Refresh( false );
}
m_trackBallCamera.SetCurMousePosition( event.GetPosition() );
}
void C3D_MODEL_VIEWER::OnLeftDown( wxMouseEvent &event )
{
//m_is_moving_mouse = true;
event.Skip();
}
void C3D_MODEL_VIEWER::OnLeftUp( wxMouseEvent &event )
{
//m_is_moving_mouse = false;
//Refresh( false );
event.Skip();
}
void C3D_MODEL_VIEWER::OnMiddleDown( wxMouseEvent &event )
{
//m_is_moving_mouse = true;
event.Skip();
}
void C3D_MODEL_VIEWER::OnMiddleUp( wxMouseEvent &event )
{
//m_is_moving_mouse = false;
//Refresh( false );
event.Skip();
}
void C3D_MODEL_VIEWER::OnRightClick( wxMouseEvent &event )
{
event.Skip();
}
@@ -0,0 +1,147 @@
/*
* 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-2019 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 propose 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/ctrack_ball.h"
#include <gal/hidpi_gl_canvas.h>
class S3D_CACHE;
class C_OGL_3DMODEL;
/**
* Class C3D_MODEL_VIEWER
* Implement a canvas based on a wxGLCanvas
*/
class C3D_MODEL_VIEWER : public HIDPI_GL_CANVAS
{
public:
/**
* Creates 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
* COGL_ATT_LIST::GetAttributesList
*/
C3D_MODEL_VIEWER( wxWindow *aParent,
const int *aAttribList = 0,
S3D_CACHE *aCacheManager = NULL );
~C3D_MODEL_VIEWER();
/**
* @brief Set3DModel - Set this model to be displayed
* @param a3DModel - 3d model data
*/
void Set3DModel( const S3DMODEL &a3DModel );
/**
* @brief Set3DModel - Set this model to be displayed
* @param aModelPathName - 3d model path name
*/
void Set3DModel( wxString const& aModelPathName );
/**
* @brief Clear3DModel - Unloads the displayed 3d model
*/
void Clear3DModel();
private:
void ogl_initialize();
void ogl_set_arrow_material();
private:
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()
private:
/// openGL context
wxGLContext *m_glRC;
/// Camera used in this canvas
CTRACK_BALL m_trackBallCamera;
/// Original 3d model data
const S3DMODEL *m_3d_model;
/// Class holder for 3d model to display on openGL
C_OGL_3DMODEL *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_
+1
View File
@@ -0,0 +1 @@
#define PLUGINDIR "@CMAKE_INSTALL_LIBDIR@"
-179
View File
@@ -1,179 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Mario Luzeiro <mrluzeiro@gmail.com>
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras@wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* 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_read_mesh.cpp
*/
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <kicad_string.h>
#include <pgm_base.h>
#define GLM_FORCE_RADIANS
#include <gal/opengl/glm/gtc/matrix_transform.hpp>
#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 );
return NULL;
}
int S3D_MASTER::ReadData( S3D_MODEL_PARSER* aParser )
{
if( m_Shape3DFullFilename.IsEmpty() || aParser == NULL )
return -1;
wxString filename = m_Shape3DFullFilename;
#ifdef __WINDOWS__
filename.Replace( wxT( "/" ), wxT( "\\" ) );
#else
filename.Replace( wxT( "\\" ), wxT( "/" ) );
#endif
if( wxFileName::FileExists( filename ) )
{
wxFileName fn( filename );
if( aParser->Load( filename ) )
{
// Invalidate bounding boxes
m_fastAABBox.Reset();
m_BBox.Reset();
m_parser = aParser;
return 0;
}
}
wxLogDebug( wxT( "3D shape '%s' not found, even tried '%s' after env var substitution." ),
GetChars( m_Shape3DName ),
GetChars( filename ) );
return -1;
}
void S3D_MASTER::Render( bool aIsRenderingJustNonTransparentObjects,
bool aIsRenderingJustTransparentObjects )
{
if( m_parser == NULL )
return;
double aVrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
glScalef( aVrmlunits_to_3Dunits, aVrmlunits_to_3Dunits, aVrmlunits_to_3Dunits );
glTranslatef( m_MatPosition.x * SCALE_3D_CONV,
m_MatPosition.y * SCALE_3D_CONV,
m_MatPosition.z * SCALE_3D_CONV );
glRotatef( -m_MatRotation.z, 0.0f, 0.0f, 1.0f );
glRotatef( -m_MatRotation.y, 0.0f, 1.0f, 0.0f );
glRotatef( -m_MatRotation.x, 1.0f, 0.0f, 0.0f );
glScalef( m_MatScale.x, m_MatScale.y, m_MatScale.z );
for( unsigned int idx = 0; idx < m_parser->childs.size(); idx++ )
m_parser->childs[idx]->openGL_RenderAllChilds( aIsRenderingJustNonTransparentObjects,
aIsRenderingJustTransparentObjects );
}
CBBOX &S3D_MASTER::getBBox( )
{
if( !m_BBox.IsInitialized() )
calcBBox();
return m_BBox;
}
CBBOX &S3D_MASTER::getFastAABBox( )
{
if( !m_fastAABBox.IsInitialized() )
calcBBox();
return m_fastAABBox;
}
void S3D_MASTER::calcBBox()
{
if( m_parser == NULL )
return;
bool firstBBox = true;
for( unsigned int idx = 0; idx < m_parser->childs.size(); idx++ )
if( firstBBox )
{
firstBBox = false;
m_BBox = m_parser->childs[idx]->getBBox();
}
else
m_BBox.Union( m_parser->childs[idx]->getBBox() );
// Calc transformation matrix to apply in AABBox
float aVrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
glm::mat4 fullTransformMatrix;
fullTransformMatrix = glm::scale( glm::mat4(), S3D_VERTEX( aVrmlunits_to_3Dunits,
aVrmlunits_to_3Dunits,
aVrmlunits_to_3Dunits ) );
fullTransformMatrix = glm::translate( fullTransformMatrix, S3D_VERTEX( m_MatPosition.x * SCALE_3D_CONV,
m_MatPosition.y * SCALE_3D_CONV,
m_MatPosition.z * SCALE_3D_CONV) );
if( m_MatRotation.z != 0.0 )
fullTransformMatrix = glm::rotate( fullTransformMatrix, glm::radians(-(float)m_MatRotation.z), S3D_VERTEX( 0.0f, 0.0f, 1.0f ) );
if( m_MatRotation.y != 0.0 )
fullTransformMatrix = glm::rotate( fullTransformMatrix, glm::radians(-(float)m_MatRotation.y), S3D_VERTEX( 0.0f, 1.0f, 0.0f ) );
if( m_MatRotation.x != 0.0 )
fullTransformMatrix = glm::rotate( fullTransformMatrix, glm::radians(-(float)m_MatRotation.x), S3D_VERTEX( 1.0f, 0.0f, 0.0f ) );
fullTransformMatrix = glm::scale( fullTransformMatrix, S3D_VERTEX( m_MatScale.x, m_MatScale.y, m_MatScale.z ) );
// Apply transformation
m_fastAABBox = m_BBox;
m_fastAABBox.ApplyTransformationAA( fullTransformMatrix );
}
@@ -0,0 +1,970 @@
/*
* 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 c3d_render_createscene_ogl_legacy.cpp
* @brief
*/
#include "c3d_render_ogl_legacy.h"
#include "ogl_legacy_utils.h"
#include <class_board.h>
#include <class_module.h>
#include "../../3d_math.h"
#include "../../3d_fastmath.h"
#include <trigo.h>
#include <project.h>
#include <profile.h> // To use GetRunningMicroSecs or an other profiling utility
void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CFILLEDCIRCLE2D * aFilledCircle,
CLAYER_TRIANGLES *aDstLayer,
float aZtop,
float aZbot )
{
const SFVEC2F &center = aFilledCircle->GetCenter();
const float radius = aFilledCircle->GetRadius() *
2.0f; // Double because the render triangle
// This is a small adjustment to the circle texture
const float texture_factor = (8.0f / (float)SIZE_OF_CIRCLE_TEXTURE) + 1.0f;
const float f = (sqrtf(2.0f) / 2.0f) * radius * texture_factor;
// Top and Bot segments ends are just triangle semi-circles, so need to add
// it in duplicated
aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZtop ),
SFVEC3F( center.x - f, center.y, aZtop ),
SFVEC3F( center.x,
center.y - f, aZtop ) );
aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x - f, center.y, aZtop ),
SFVEC3F( center.x + f, center.y, aZtop ),
SFVEC3F( center.x,
center.y + f, aZtop ) );
aDstLayer->m_layer_bot_segment_ends->AddTriangle( SFVEC3F( center.x - f, center.y, aZbot ),
SFVEC3F( center.x + f, center.y, aZbot ),
SFVEC3F( center.x,
center.y - f, aZbot ) );
aDstLayer->m_layer_bot_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZbot ),
SFVEC3F( center.x - f, center.y, aZbot ),
SFVEC3F( center.x,
center.y + f, aZbot ) );
}
void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CPOLYGON4PTS2D * aPoly,
CLAYER_TRIANGLES *aDstLayer,
float aZtop,
float aZbot )
{
const SFVEC2F &v0 = aPoly->GetV0();
const SFVEC2F &v1 = aPoly->GetV1();
const SFVEC2F &v2 = aPoly->GetV2();
const SFVEC2F &v3 = aPoly->GetV3();
add_triangle_top_bot( aDstLayer, v0, v2, v1, aZtop, aZbot );
add_triangle_top_bot( aDstLayer, v2, v0, v3, aZtop, aZbot );
}
void C3D_RENDER_OGL_LEGACY::generate_ring_contour( const SFVEC2F &aCenter,
float aInnerRadius,
float aOuterRadius,
unsigned int aNr_sides_per_circle,
std::vector< SFVEC2F > &aInnerContourResult,
std::vector< SFVEC2F > &aOuterContourResult,
bool aInvertOrder )
{
aInnerContourResult.clear();
aInnerContourResult.reserve( aNr_sides_per_circle + 2 );
aOuterContourResult.clear();
aOuterContourResult.reserve( aNr_sides_per_circle + 2 );
const int delta = 3600 / aNr_sides_per_circle;
for( int ii = 0; ii < 3600; ii += delta )
{
float angle = (float)( aInvertOrder ? ( 3600 - ii ) : ii )
* 2.0f * glm::pi<float>() / 3600.0f;
const SFVEC2F rotatedDir = SFVEC2F( cos( angle ), sin( angle ) );
aInnerContourResult.push_back( SFVEC2F( aCenter.x + rotatedDir.x * aInnerRadius,
aCenter.y + rotatedDir.y * aInnerRadius ) );
aOuterContourResult.push_back( SFVEC2F( aCenter.x + rotatedDir.x * aOuterRadius,
aCenter.y + rotatedDir.y * aOuterRadius ) );
}
aInnerContourResult.push_back( aInnerContourResult[0] );
aOuterContourResult.push_back( aOuterContourResult[0] );
wxASSERT( aInnerContourResult.size() == aOuterContourResult.size() );
}
void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CRING2D * aRing,
CLAYER_TRIANGLES *aDstLayer,
float aZtop,
float aZbot )
{
const SFVEC2F &center = aRing->GetCenter();
const float inner = aRing->GetInnerRadius();
const float outer = aRing->GetOuterRadius();
std::vector< SFVEC2F > innerContour;
std::vector< SFVEC2F > outerContour;
generate_ring_contour( center,
inner,
outer,
m_settings.GetNrSegmentsCircle( outer * 2.0f ),
innerContour,
outerContour,
false );
// This will add the top and bot quads that will form the approximated ring
for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
{
const SFVEC2F &vi0 = innerContour[i + 0];
const SFVEC2F &vi1 = innerContour[i + 1];
const SFVEC2F &vo0 = outerContour[i + 0];
const SFVEC2F &vo1 = outerContour[i + 1];
aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
SFVEC3F( vi0.x, vi0.y, aZtop ),
SFVEC3F( vo0.x, vo0.y, aZtop ),
SFVEC3F( vo1.x, vo1.y, aZtop ) );
aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
SFVEC3F( vo1.x, vo1.y, aZbot ),
SFVEC3F( vo0.x, vo0.y, aZbot ),
SFVEC3F( vi0.x, vi0.y, aZbot ) );
}
}
void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CTRIANGLE2D * aTri,
CLAYER_TRIANGLES *aDstLayer,
float aZtop,
float aZbot )
{
const SFVEC2F &v1 = aTri->GetP1();
const SFVEC2F &v2 = aTri->GetP2();
const SFVEC2F &v3 = aTri->GetP3();
add_triangle_top_bot( aDstLayer, v1, v2, v3, aZtop, aZbot );
}
void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CROUNDSEGMENT2D * aSeg,
CLAYER_TRIANGLES *aDstLayer,
float aZtop,
float aZbot )
{
const SFVEC2F leftStart = aSeg->GetLeftStar();
const SFVEC2F leftEnd = aSeg->GetLeftEnd();
const SFVEC2F leftDir = aSeg->GetLeftDir();
const SFVEC2F rightStart = aSeg->GetRightStar();
const SFVEC2F rightEnd = aSeg->GetRightEnd();
const SFVEC2F rightDir = aSeg->GetRightDir();
const float radius = aSeg->GetRadius();
const SFVEC2F start = aSeg->GetStart();
const SFVEC2F end = aSeg->GetEnd();
const float texture_factor = (12.0f / (float)SIZE_OF_CIRCLE_TEXTURE) + 1.0f;
const float texture_factorF= ( 6.0f / (float)SIZE_OF_CIRCLE_TEXTURE) + 1.0f;
const float radius_of_the_square = sqrtf( aSeg->GetRadiusSquared() * 2.0f );
const float radius_triangle_factor = (radius_of_the_square - radius) / radius;
const SFVEC2F factorS = SFVEC2F( -rightDir.y * radius * radius_triangle_factor,
rightDir.x * radius * radius_triangle_factor );
const SFVEC2F factorE = SFVEC2F( -leftDir.y * radius * radius_triangle_factor,
leftDir.x * radius * radius_triangle_factor );
// Top end segment triangles (semi-circles)
aDstLayer->m_layer_top_segment_ends->AddTriangle(
SFVEC3F( rightEnd.x + texture_factor * factorS.x,
rightEnd.y + texture_factor * factorS.y,
aZtop ),
SFVEC3F( leftStart.x + texture_factor * factorE.x,
leftStart.y + texture_factor * factorE.y,
aZtop ),
SFVEC3F( start.x - texture_factorF * leftDir.x * radius * sqrtf( 2.0f ),
start.y - texture_factorF * leftDir.y * radius * sqrtf( 2.0f ),
aZtop ) );
aDstLayer->m_layer_top_segment_ends->AddTriangle(
SFVEC3F( leftEnd.x + texture_factor * factorE.x,
leftEnd.y + texture_factor * factorE.y, aZtop ),
SFVEC3F( rightStart.x + texture_factor * factorS.x,
rightStart.y + texture_factor * factorS.y, aZtop ),
SFVEC3F( end.x - texture_factorF * rightDir.x * radius * sqrtf( 2.0f ),
end.y - texture_factorF * rightDir.y * radius * sqrtf( 2.0f ),
aZtop ) );
// Bot end segment triangles (semi-circles)
aDstLayer->m_layer_bot_segment_ends->AddTriangle(
SFVEC3F( leftStart.x + texture_factor * factorE.x,
leftStart.y + texture_factor * factorE.y,
aZbot ),
SFVEC3F( rightEnd.x + texture_factor * factorS.x,
rightEnd.y + texture_factor * factorS.y,
aZbot ),
SFVEC3F( start.x - texture_factorF * leftDir.x * radius * sqrtf( 2.0f ),
start.y - texture_factorF * leftDir.y * radius * sqrtf( 2.0f ),
aZbot ) );
aDstLayer->m_layer_bot_segment_ends->AddTriangle(
SFVEC3F( rightStart.x + texture_factor * factorS.x,
rightStart.y + texture_factor * factorS.y, aZbot ),
SFVEC3F( leftEnd.x + texture_factor * factorE.x,
leftEnd.y + texture_factor * factorE.y, aZbot ),
SFVEC3F( end.x - texture_factorF * rightDir.x * radius * sqrtf( 2.0f ),
end.y - texture_factorF * rightDir.y * radius * sqrtf( 2.0f ),
aZbot ) );
// Segment top and bot planes
aDstLayer->m_layer_top_triangles->AddQuad(
SFVEC3F( rightEnd.x, rightEnd.y, aZtop ),
SFVEC3F( rightStart.x, rightStart.y, aZtop ),
SFVEC3F( leftEnd.x, leftEnd.y, aZtop ),
SFVEC3F( leftStart.x, leftStart.y, aZtop ) );
aDstLayer->m_layer_bot_triangles->AddQuad(
SFVEC3F( rightEnd.x, rightEnd.y, aZbot ),
SFVEC3F( leftStart.x, leftStart.y, aZbot ),
SFVEC3F( leftEnd.x, leftEnd.y, aZbot ),
SFVEC3F( rightStart.x, rightStart.y, aZbot ) );
}
CLAYERS_OGL_DISP_LISTS *C3D_RENDER_OGL_LEGACY::generate_holes_display_list(
const LIST_OBJECT2D &aListHolesObject2d,
const SHAPE_POLY_SET &aPoly,
float aZtop,
float aZbot,
bool aInvertFaces )
{
CLAYERS_OGL_DISP_LISTS *ret = NULL;
if( aListHolesObject2d.size() > 0 )
{
CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( aListHolesObject2d.size() * 2 );
// Convert the list of objects(filled circles) to triangle layer structure
for( LIST_OBJECT2D::const_iterator itemOnLayer = aListHolesObject2d.begin();
itemOnLayer != aListHolesObject2d.end();
++itemOnLayer )
{
const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
wxASSERT( (object2d_A->GetObjectType() == OBJ2D_FILLED_CIRCLE) ||
(object2d_A->GetObjectType() == OBJ2D_ROUNDSEG) );
switch( object2d_A->GetObjectType() )
{
case OBJ2D_FILLED_CIRCLE:
add_object_to_triangle_layer( (const CFILLEDCIRCLE2D *)object2d_A,
layerTriangles,
aZtop, aZbot );
break;
case OBJ2D_ROUNDSEG:
add_object_to_triangle_layer( (const CROUNDSEGMENT2D *) object2d_A,
layerTriangles,
aZtop, aZbot );
break;
default:
wxFAIL_MSG("C3D_RENDER_OGL_LEGACY::generate_holes_display_list: Object type is not implemented");
break;
}
}
// Note: he can have a aListHolesObject2d whith holes but without countours
// eg: when there are only NPTH on the list and the contours were not
// added
if( aPoly.OutlineCount() > 0 )
{
layerTriangles->AddToMiddleContourns( aPoly,
aZbot,
aZtop,
m_settings.BiuTo3Dunits(),
aInvertFaces );
}
ret = new CLAYERS_OGL_DISP_LISTS( *layerTriangles,
m_ogl_circle_texture,
aZbot,
aZtop );
delete layerTriangles;
}
return ret;
}
void C3D_RENDER_OGL_LEGACY::reload( REPORTER *aStatusTextReporter )
{
m_reloadRequested = false;
ogl_free_all_display_lists();
COBJECT2D_STATS::Instance().ResetStats();
#ifdef PRINT_STATISTICS_3D_VIEWER
printf("InitSettings...\n");
#endif
unsigned stats_startReloadTime = GetRunningMicroSecs();
m_settings.InitSettings( aStatusTextReporter );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_endReloadTime = GetRunningMicroSecs();
#endif
SFVEC3F camera_pos = m_settings.GetBoardCenter3DU();
m_settings.CameraGet().SetBoardLookAtPos( camera_pos );
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_start_OpenGL_Load_Time = GetRunningMicroSecs();
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Load OpenGL: board" ) );
// Create Board
// /////////////////////////////////////////////////////////////////////////
CCONTAINER2D boardContainer;
Convert_shape_line_polygon_to_triangles( m_settings.GetBoardPoly(),
boardContainer,
m_settings.BiuTo3Dunits(),
(const BOARD_ITEM &)*m_settings.GetBoard() );
const LIST_OBJECT2D &listBoardObject2d = boardContainer.GetList();
if( listBoardObject2d.size() > 0 )
{
// We will set a unitary Z so it will in future used with transformations
// since the board poly will be used not only to draw itself but also the
// solder mask layers.
const float layer_z_top = 1.0f;
const float layer_z_bot = 0.0f;
CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( listBoardObject2d.size() );
// Convert the list of objects(triangles) to triangle layer structure
for( LIST_OBJECT2D::const_iterator itemOnLayer = listBoardObject2d.begin();
itemOnLayer != listBoardObject2d.end();
++itemOnLayer )
{
const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
wxASSERT( object2d_A->GetObjectType() == OBJ2D_TRIANGLE );
const CTRIANGLE2D *tri = (const CTRIANGLE2D *)object2d_A;
const SFVEC2F &v1 = tri->GetP1();
const SFVEC2F &v2 = tri->GetP2();
const SFVEC2F &v3 = tri->GetP3();
add_triangle_top_bot( layerTriangles,
v1,
v2,
v3,
layer_z_top,
layer_z_bot );
}
const SHAPE_POLY_SET &boardPoly = m_settings.GetBoardPoly();
wxASSERT( boardPoly.OutlineCount() > 0 );
if( boardPoly.OutlineCount() > 0 )
{
layerTriangles->AddToMiddleContourns( boardPoly,
layer_z_bot,
layer_z_top,
m_settings.BiuTo3Dunits(),
false );
m_ogl_disp_list_board = new CLAYERS_OGL_DISP_LISTS( *layerTriangles,
m_ogl_circle_texture,
layer_z_top,
layer_z_top );
}
delete layerTriangles;
}
// Create Through Holes and vias
// /////////////////////////////////////////////////////////////////////////
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Load OpenGL: holes and vias" ) );
m_ogl_disp_list_through_holes_outer = generate_holes_display_list(
m_settings.GetThroughHole_Outer().GetList(),
m_settings.GetThroughHole_Outer_poly(),
1.0f,
0.0f,
false );
SHAPE_POLY_SET bodyHoles = m_settings.GetThroughHole_Outer_poly();
bodyHoles.BooleanAdd( m_settings.GetThroughHole_Outer_poly_NPTH(),
SHAPE_POLY_SET::PM_FAST );
m_ogl_disp_list_through_holes_outer_with_npth = generate_holes_display_list(
m_settings.GetThroughHole_Outer().GetList(),
bodyHoles,
1.0f,
0.0f,
false );
m_ogl_disp_list_through_holes_inner = generate_holes_display_list(
m_settings.GetThroughHole_Inner().GetList(),
m_settings.GetThroughHole_Inner_poly(),
1.0f,
0.0f,
true );
m_ogl_disp_list_through_holes_vias_outer = generate_holes_display_list(
m_settings.GetThroughHole_Vias_Outer().GetList(),
m_settings.GetThroughHole_Vias_Outer_poly(),
1.0f,
0.0f,
false );
// Not in use
//m_ogl_disp_list_through_holes_vias_inner = generate_holes_display_list(
// m_settings.GetThroughHole_Vias_Inner().GetList(),
// m_settings.GetThroughHole_Vias_Inner_poly(),
// 1.0f, 0.0f,
// false );
const MAP_POLY & innerMapHoles = m_settings.GetPolyMapHoles_Inner();
const MAP_POLY & outerMapHoles = m_settings.GetPolyMapHoles_Outer();
wxASSERT( innerMapHoles.size() == outerMapHoles.size() );
const MAP_CONTAINER_2D &map_holes = m_settings.GetMapLayersHoles();
if( outerMapHoles.size() > 0 )
{
float layer_z_bot = 0.0f;
float layer_z_top = 0.0f;
for( MAP_POLY::const_iterator ii = outerMapHoles.begin();
ii != outerMapHoles.end();
++ii )
{
PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>(ii->first);
const SHAPE_POLY_SET *poly = static_cast<const SHAPE_POLY_SET *>(ii->second);
const CBVHCONTAINER2D *container = map_holes.at( layer_id );
get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
m_ogl_disp_lists_layers_holes_outer[layer_id] = generate_holes_display_list(
container->GetList(),
*poly,
layer_z_top,
layer_z_bot,
false );
}
for( MAP_POLY::const_iterator ii = innerMapHoles.begin();
ii != innerMapHoles.end();
++ii )
{
PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>(ii->first);
const SHAPE_POLY_SET *poly = static_cast<const SHAPE_POLY_SET *>(ii->second);
const CBVHCONTAINER2D *container = map_holes.at( layer_id );
get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
m_ogl_disp_lists_layers_holes_inner[layer_id] = generate_holes_display_list(
container->GetList(),
*poly,
layer_z_top,
layer_z_bot,
false );
}
}
// Generate vertical cylinders of vias and pads (copper)
generate_3D_Vias_and_Pads();
// Add layers maps
// /////////////////////////////////////////////////////////////////////////
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Load OpenGL: layers" ) );
for( MAP_CONTAINER_2D::const_iterator ii = m_settings.GetMapLayers().begin();
ii != m_settings.GetMapLayers().end();
++ii )
{
PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>(ii->first);
if( !m_settings.Is3DLayerEnabled( layer_id ) )
continue;
const CBVHCONTAINER2D *container2d = static_cast<const CBVHCONTAINER2D *>(ii->second);
const LIST_OBJECT2D &listObject2d = container2d->GetList();
if( listObject2d.size() == 0 )
continue;
float layer_z_bot = 0.0f;
float layer_z_top = 0.0f;
get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
// Calculate an estimation for the nr of triangles based on the nr of objects
unsigned int nrTrianglesEstimation = listObject2d.size() * 8;
CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( nrTrianglesEstimation );
m_triangles[layer_id] = layerTriangles;
// Load the 2D (X,Y axis) component of shapes
for( LIST_OBJECT2D::const_iterator itemOnLayer = listObject2d.begin();
itemOnLayer != listObject2d.end();
++itemOnLayer )
{
const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
switch( object2d_A->GetObjectType() )
{
case OBJ2D_FILLED_CIRCLE:
add_object_to_triangle_layer( (const CFILLEDCIRCLE2D *)object2d_A,
layerTriangles,
layer_z_top, layer_z_bot );
break;
case OBJ2D_POLYGON4PT:
add_object_to_triangle_layer( (const CPOLYGON4PTS2D *)object2d_A,
layerTriangles,
layer_z_top, layer_z_bot );
break;
case OBJ2D_RING:
add_object_to_triangle_layer( (const CRING2D *)object2d_A,
layerTriangles,
layer_z_top, layer_z_bot );
break;
case OBJ2D_TRIANGLE:
add_object_to_triangle_layer( (const CTRIANGLE2D *)object2d_A,
layerTriangles,
layer_z_top, layer_z_bot );
break;
case OBJ2D_ROUNDSEG:
add_object_to_triangle_layer( (const CROUNDSEGMENT2D *) object2d_A,
layerTriangles,
layer_z_top, layer_z_bot );
break;
default:
wxFAIL_MSG("C3D_RENDER_OGL_LEGACY: Object type is not implemented");
break;
}
}
const MAP_POLY &map_poly = m_settings.GetPolyMap();
// Load the vertical (Z axis) component of shapes
if( map_poly.find( layer_id ) != map_poly.end() )
{
const SHAPE_POLY_SET *polyList = map_poly.at( layer_id );
layerTriangles->AddToMiddleContourns( *polyList,
layer_z_bot,
layer_z_top,
m_settings.BiuTo3Dunits(),
false );
}
// Create display list
// /////////////////////////////////////////////////////////////////////
m_ogl_disp_lists_layers[layer_id] = new CLAYERS_OGL_DISP_LISTS( *layerTriangles,
m_ogl_circle_texture,
layer_z_bot,
layer_z_top );
}// for each layer on map
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_end_OpenGL_Load_Time = GetRunningMicroSecs();
#endif
// Load 3D models
// /////////////////////////////////////////////////////////////////////////
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_start_models_Load_Time = GetRunningMicroSecs();
#endif
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Loading 3D models" ) );
load_3D_models();
#ifdef PRINT_STATISTICS_3D_VIEWER
unsigned stats_end_models_Load_Time = GetRunningMicroSecs();
printf( "C3D_RENDER_OGL_LEGACY::reload times:\n" );
printf( " Reload board: %.3f ms\n",
(float)( stats_endReloadTime - stats_startReloadTime ) / 1000.0f );
printf( " Loading to openGL: %.3f ms\n",
(float)( stats_end_OpenGL_Load_Time - stats_start_OpenGL_Load_Time ) / 1000.0f );
printf( " Loading 3D models: %.3f ms\n",
(float)( stats_end_models_Load_Time - stats_start_models_Load_Time ) / 1000.0f );
COBJECT2D_STATS::Instance().PrintStats();
#endif
if( aStatusTextReporter )
{
// Calculation time in seconds
const double calculation_time = (double)( GetRunningMicroSecs() -
stats_startReloadTime) / 1e6;
aStatusTextReporter->Report( wxString::Format( _( "Reload time %.3f s" ),
calculation_time ) );
}
}
void C3D_RENDER_OGL_LEGACY::add_triangle_top_bot( CLAYER_TRIANGLES *aDst,
const SFVEC2F &v0,
const SFVEC2F &v1,
const SFVEC2F &v2,
float top,
float bot )
{
aDst->m_layer_bot_triangles->AddTriangle( SFVEC3F( v0.x, v0.y, bot ),
SFVEC3F( v1.x, v1.y, bot ),
SFVEC3F( v2.x, v2.y, bot ) );
aDst->m_layer_top_triangles->AddTriangle( SFVEC3F( v2.x, v2.y, top ),
SFVEC3F( v1.x, v1.y, top ),
SFVEC3F( v0.x, v0.y, top ) );
}
void C3D_RENDER_OGL_LEGACY::get_layer_z_pos ( PCB_LAYER_ID aLayerID,
float &aOutZtop,
float &aOutZbot ) const
{
aOutZbot = m_settings.GetLayerBottomZpos3DU( aLayerID );
aOutZtop = m_settings.GetLayerTopZpos3DU( aLayerID );
if( aOutZtop < aOutZbot )
{
float tmpFloat = aOutZbot;
aOutZbot = aOutZtop;
aOutZtop = tmpFloat;
}
}
void C3D_RENDER_OGL_LEGACY::generate_cylinder( const SFVEC2F &aCenter,
float aInnerRadius,
float aOuterRadius,
float aZtop,
float aZbot,
unsigned int aNr_sides_per_circle,
CLAYER_TRIANGLES *aDstLayer )
{
std::vector< SFVEC2F > innerContour;
std::vector< SFVEC2F > outerContour;
generate_ring_contour( aCenter,
aInnerRadius,
aOuterRadius,
aNr_sides_per_circle,
innerContour,
outerContour,
false );
for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
{
const SFVEC2F &vi0 = innerContour[i + 0];
const SFVEC2F &vi1 = innerContour[i + 1];
const SFVEC2F &vo0 = outerContour[i + 0];
const SFVEC2F &vo1 = outerContour[i + 1];
aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
SFVEC3F( vi0.x, vi0.y, aZtop ),
SFVEC3F( vo0.x, vo0.y, aZtop ),
SFVEC3F( vo1.x, vo1.y, aZtop ) );
aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
SFVEC3F( vo1.x, vo1.y, aZbot ),
SFVEC3F( vo0.x, vo0.y, aZbot ),
SFVEC3F( vi0.x, vi0.y, aZbot ) );
}
aDstLayer->AddToMiddleContourns( outerContour, aZbot, aZtop, true );
aDstLayer->AddToMiddleContourns( innerContour, aZbot, aZtop, false );
}
void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads()
{
if( m_settings.GetStats_Nr_Vias() )
{
const unsigned int reserve_nr_triangles_estimation =
m_settings.GetNrSegmentsCircle( m_settings.GetStats_Med_Via_Hole_Diameter3DU() ) *
8 *
m_settings.GetStats_Nr_Vias();
CLAYER_TRIANGLES *layerTriangleVIA = new CLAYER_TRIANGLES( reserve_nr_triangles_estimation );
// Insert plated vertical holes inside the board
// /////////////////////////////////////////////////////////////////////////
// Insert vias holes (vertical cylinders)
for( const TRACK* track = m_settings.GetBoard()->m_Track;
track;
track = track->Next() )
{
if( track->Type() == PCB_VIA_T )
{
const VIA *via = static_cast<const VIA*>(track);
const float holediameter = via->GetDrillValue() * m_settings.BiuTo3Dunits();
const float thickness = m_settings.GetCopperThickness3DU();
const float hole_inner_radius = ( holediameter / 2.0f );
const SFVEC2F via_center( via->GetStart().x * m_settings.BiuTo3Dunits(),
-via->GetStart().y * m_settings.BiuTo3Dunits() );
PCB_LAYER_ID top_layer, bottom_layer;
via->LayerPair( &top_layer, &bottom_layer );
float ztop, zbot, dummy;
get_layer_z_pos( top_layer, ztop, dummy );
get_layer_z_pos( bottom_layer, dummy, zbot );
wxASSERT( zbot < ztop );
generate_cylinder( via_center,
hole_inner_radius,
hole_inner_radius + thickness,
ztop,
zbot,
m_settings.GetNrSegmentsCircle( via->GetDrillValue() ),
layerTriangleVIA );
}
}
m_ogl_disp_list_via = new CLAYERS_OGL_DISP_LISTS( *layerTriangleVIA,
0,
0.0f,
0.0f );
delete layerTriangleVIA;
}
if( m_settings.GetStats_Nr_Holes() > 0 )
{
SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes (the pad)
SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes (the hole)
tht_outer_holes_poly.RemoveAllContours();
tht_inner_holes_poly.RemoveAllContours();
// Insert pads holes (vertical cylinders)
for( const MODULE* module = m_settings.GetBoard()->m_Modules;
module;
module = module->Next() )
{
for( const D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
{
if( pad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
{
const wxSize drillsize = pad->GetDrillSize();
const bool hasHole = drillsize.x && drillsize.y;
if( !hasHole )
continue;
// we use the hole diameter to calculate the seg count.
// for round holes, drillsize.x == drillsize.y
// for oblong holes, the diameter is the smaller of
// (drillsize.x, drillsize.y)
const int diam = std::min( drillsize.x, drillsize.y ) +
m_settings.GetCopperThicknessBIU() * 2;
const int segmentsPerCircle = m_settings.GetNrSegmentsCircle( diam );
pad->BuildPadDrillShapePolygon( tht_outer_holes_poly,
m_settings.GetCopperThicknessBIU(),
segmentsPerCircle );
pad->BuildPadDrillShapePolygon( tht_inner_holes_poly,
0,
segmentsPerCircle );
}
}
}
// Subtract the holes
tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
CCONTAINER2D holesContainer;
Convert_shape_line_polygon_to_triangles( tht_outer_holes_poly,
holesContainer,
m_settings.BiuTo3Dunits(),
(const BOARD_ITEM &)*m_settings.GetBoard() );
const LIST_OBJECT2D &listHolesObject2d = holesContainer.GetList();
if( listHolesObject2d.size() > 0 )
{
float layer_z_top, layer_z_bot, dummy;
get_layer_z_pos( F_Cu, layer_z_top, dummy );
get_layer_z_pos( B_Cu, dummy, layer_z_bot );
CLAYER_TRIANGLES *layerTriangles = new CLAYER_TRIANGLES( listHolesObject2d.size() );
// Convert the list of objects(triangles) to triangle layer structure
for( LIST_OBJECT2D::const_iterator itemOnLayer = listHolesObject2d.begin();
itemOnLayer != listHolesObject2d.end();
++itemOnLayer )
{
const COBJECT2D *object2d_A = static_cast<const COBJECT2D *>(*itemOnLayer);
wxASSERT( object2d_A->GetObjectType() == OBJ2D_TRIANGLE );
const CTRIANGLE2D *tri = (const CTRIANGLE2D *)object2d_A;
const SFVEC2F &v1 = tri->GetP1();
const SFVEC2F &v2 = tri->GetP2();
const SFVEC2F &v3 = tri->GetP3();
add_triangle_top_bot( layerTriangles,
v1,
v2,
v3,
layer_z_top,
layer_z_bot );
}
wxASSERT( tht_outer_holes_poly.OutlineCount() > 0 );
if( tht_outer_holes_poly.OutlineCount() > 0 )
{
layerTriangles->AddToMiddleContourns( tht_outer_holes_poly,
layer_z_bot,
layer_z_top,
m_settings.BiuTo3Dunits(),
false );
m_ogl_disp_list_pads_holes = new CLAYERS_OGL_DISP_LISTS(
*layerTriangles,
m_ogl_circle_texture, // not need
layer_z_top,
layer_z_top );
}
delete layerTriangles;
}
}
}
/*
* This function will get models from the cache and load it to openGL lists
* in the form of C_OGL_3DMODEL. So this map of models will work as a local
* cache for this render. (cache based on C_OGL_3DMODEL with associated
* openGL lists in GPU memory)
*/
void C3D_RENDER_OGL_LEGACY::load_3D_models()
{
if( (!m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL )) &&
(!m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT )) &&
(!m_settings.GetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL )) )
return;
// Go for all modules
for( const MODULE* module = m_settings.GetBoard()->m_Modules;
module;
module = module->Next() )
{
if( !module->Models().empty() )
{
// Get the list of model files for this model
auto sM = module->Models().begin();
auto eM = module->Models().end();
while( sM != eM )
{
if( !sM->m_Filename.empty() )
{
// Check if the model is not present in our cache map
if( m_3dmodel_map.find( sM->m_Filename ) == m_3dmodel_map.end() )
{
// It is not present, try get it from cache
const S3DMODEL *modelPtr =
m_settings.Get3DCacheManager()->GetModel( sM->m_Filename );
// only add it if the return is not NULL
if( modelPtr )
{
C_OGL_3DMODEL* ogl_model =
new C_OGL_3DMODEL( *modelPtr,
m_settings.MaterialModeGet() );
if( ogl_model )
m_3dmodel_map[ sM->m_Filename ] = ogl_model;
}
}
}
++sM;
}
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,221 @@
/*
* 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 c3d_render_ogl_legacy.h
* @brief
*/
#ifndef C3D_RENDER_OGL_LEGACY_H_
#define C3D_RENDER_OGL_LEGACY_H_
#include "../c3d_render_base.h"
#include "clayer_triangles.h"
#include "../3d_render_raytracing/shapes2D/cpolygon2d.h"
#include "../3d_render_raytracing/shapes2D/ctriangle2d.h"
#include "../3d_render_raytracing/shapes2D/cpolygon4pts2d.h"
#include "../3d_render_raytracing/shapes2D/cfilledcircle2d.h"
#include "../3d_render_raytracing/shapes2D/cring2d.h"
#include "../3d_render_raytracing/shapes2D/croundsegment2d.h"
#include "c_ogl_3dmodel.h"
#include "3d_cache/3d_info.h"
#include <map>
typedef std::map< PCB_LAYER_ID, CLAYERS_OGL_DISP_LISTS* > MAP_OGL_DISP_LISTS;
typedef std::map< PCB_LAYER_ID, CLAYER_TRIANGLES * > MAP_TRIANGLES;
typedef std::map< wxString, C_OGL_3DMODEL * > MAP_3DMODEL;
#define SIZE_OF_CIRCLE_TEXTURE 1024
/**
* @brief The C3D_RENDER_OGL_LEGACY class render the board using openGL legacy mode
*/
class C3D_RENDER_OGL_LEGACY : public C3D_RENDER_BASE
{
public:
explicit C3D_RENDER_OGL_LEGACY( CINFO3D_VISU &aSettings );
~C3D_RENDER_OGL_LEGACY();
// Imported from C3D_RENDER_BASE
void SetCurWindowSize( const wxSize &aSize ) override;
bool Redraw( bool aIsMoving, REPORTER *aStatusTextReporter ) override;
int GetWaitForEditingTimeOut() override;
private:
bool initializeOpenGL();
void reload( REPORTER *aStatusTextReporter );
void ogl_set_arrow_material();
void ogl_free_all_display_lists();
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers;
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer;
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_inner;
CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_board;
CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_outer;
CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_inner;
// User for body render
CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_outer_with_npth;
CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_vias_outer;
//CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_vias_inner; // Not in use
// This is for pads holes of the modules
//CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_vias_and_pad_holes_inner_contourn_and_caps;
CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps;
MAP_TRIANGLES m_triangles;
GLuint m_ogl_circle_texture;
GLuint m_ogl_disp_list_grid; ///< oGL list that stores current grid
GRID3D_TYPE m_last_grid_type; ///< Stores the last grid computed
CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_via;
CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_pads_holes;
MAP_3DMODEL m_3dmodel_map;
private:
void generate_through_outer_holes();
void generate_through_inner_holes();
CLAYERS_OGL_DISP_LISTS *generate_holes_display_list( const LIST_OBJECT2D &aListHolesObject2d,
const SHAPE_POLY_SET &aPoly,
float aZtop,
float aZbot,
bool aInvertFaces );
void add_triangle_top_bot( CLAYER_TRIANGLES *aDst,
const SFVEC2F &v0,
const SFVEC2F &v1,
const SFVEC2F &v2,
float top,
float bot );
void add_object_to_triangle_layer( const CRING2D *aRing,
CLAYER_TRIANGLES *aDstLayer,
float aZtop,
float aZbot );
void add_object_to_triangle_layer( const CPOLYGON4PTS2D *aPoly,
CLAYER_TRIANGLES *aDstLayer,
float aZtop,
float aZbot );
void add_object_to_triangle_layer( const CFILLEDCIRCLE2D *aFilledCircle,
CLAYER_TRIANGLES *aDstLayer,
float aZtop,
float aZbot );
void add_object_to_triangle_layer( const CTRIANGLE2D *aTri,
CLAYER_TRIANGLES *aDstLayer,
float aZtop,
float aZbot );
void add_object_to_triangle_layer( const CROUNDSEGMENT2D *aSeg,
CLAYER_TRIANGLES *aDstLayer,
float aZtop,
float aZbot );
void render_solder_mask_layer( PCB_LAYER_ID aLayerID,
float aZPosition,
bool aIsRenderingOnPreviewMode );
void get_layer_z_pos( PCB_LAYER_ID aLayerID,
float &aOutZtop,
float &aOutZbot ) const;
void generate_ring_contour( const SFVEC2F &aCenter,
float aInnerRadius,
float aOuterRadius,
unsigned int aNr_sides_per_circle,
std::vector< SFVEC2F > &aInnerContourResult,
std::vector< SFVEC2F > &aOuterContourResult,
bool aInvertOrder );
void generate_cylinder( const SFVEC2F &aCenter,
float aInnerRadius,
float aOuterRadius,
float aZtop,
float aZbot,
unsigned int aNr_sides_per_circle,
CLAYER_TRIANGLES *aDstLayer );
void generate_3D_Vias_and_Pads();
void load_3D_models();
/**
* @brief render_3D_models
* @param aRenderTopOrBot - true will render Top, false will render bottom
* @param aRenderTransparentOnly - true will render only the transparent
* objects, false will render opaque
*/
void render_3D_models( bool aRenderTopOrBot, bool aRenderTransparentOnly );
void render_3D_module( const MODULE* module, bool aRenderTransparentOnly );
void setLight_Front( bool enabled );
void setLight_Top( bool enabled );
void setLight_Bottom( bool enabled );
void render_3D_arrows();
void generate_new_3DGrid( GRID3D_TYPE aGridType );
// Materials
void setupMaterials();
struct
{
SMATERIAL m_Paste;
SMATERIAL m_SilkS;
SMATERIAL m_SolderMask;
SMATERIAL m_EpoxyBoard;
SMATERIAL m_Copper;
SMATERIAL m_Plastic;
SMATERIAL m_GrayMaterial;
}m_materials;
void set_layer_material( PCB_LAYER_ID aLayerID );
SFVEC3F get_layer_color( PCB_LAYER_ID aLayerID );
public:
const MAP_OGL_DISP_LISTS &GetLayerDispListMap() const { return m_ogl_disp_lists_layers; }
const CLAYERS_OGL_DISP_LISTS *GetLayerDispList( PCB_LAYER_ID aLayerId ) const { return m_ogl_disp_lists_layers.at( aLayerId ); }
const CLAYERS_OGL_DISP_LISTS *GetBoardDispList() const { return m_ogl_disp_list_board; }
};
#endif // C3D_RENDER_OGL_LEGACY_H_
@@ -0,0 +1,383 @@
/*
* 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 c_ogl_3dmodel.cpp
* @brief
*/
#include "c_ogl_3dmodel.h"
#include "ogl_legacy_utils.h"
#include "../common_ogl/ogl_utils.h"
#include "../3d_math.h"
#include <wx/debug.h>
C_OGL_3DMODEL::C_OGL_3DMODEL( const S3DMODEL &a3DModel,
MATERIAL_MODE aMaterialMode )
{
m_ogl_idx_list_meshes = 0;
m_ogl_idx_list_opaque = 0;
m_ogl_idx_list_transparent = 0;
m_nr_meshes = 0;
m_meshs_bbox = NULL;
// Validate a3DModel pointers
wxASSERT( a3DModel.m_Materials != NULL );
wxASSERT( a3DModel.m_Meshes != NULL );
wxASSERT( a3DModel.m_MaterialsSize > 0 );
wxASSERT( a3DModel.m_MeshesSize > 0 );
if( (a3DModel.m_Materials != NULL) && (a3DModel.m_Meshes != NULL) &&
(a3DModel.m_MaterialsSize > 0) && (a3DModel.m_MeshesSize > 0) )
{
m_nr_meshes = a3DModel.m_MeshesSize;
m_meshs_bbox = new CBBOX[a3DModel.m_MeshesSize];
// Generate m_MeshesSize auxiliar lists to render the meshes
m_ogl_idx_list_meshes = glGenLists( a3DModel.m_MeshesSize );
// Render each mesh of the model
// /////////////////////////////////////////////////////////////////////
for( unsigned int mesh_i = 0; mesh_i < a3DModel.m_MeshesSize; ++mesh_i )
{
if( glIsList( m_ogl_idx_list_meshes + mesh_i ) )
{
const SMESH &mesh = a3DModel.m_Meshes[mesh_i];
// Validate the mesh pointers
wxASSERT( mesh.m_Positions != NULL );
wxASSERT( mesh.m_FaceIdx != NULL );
wxASSERT( mesh.m_Normals != NULL );
if( (mesh.m_Positions != NULL) &&
(mesh.m_Normals != NULL) &&
(mesh.m_FaceIdx != NULL) &&
(mesh.m_FaceIdxSize > 0) && (mesh.m_VertexSize > 0) )
{
SFVEC4F *pColorRGBA = NULL;
// Create the bbox for this mesh
// /////////////////////////////////////////////////////////
m_meshs_bbox[mesh_i].Reset();
for( unsigned int vertex_i = 0;
vertex_i < mesh.m_VertexSize;
++vertex_i )
{
m_meshs_bbox[mesh_i].Union( mesh.m_Positions[vertex_i] );
}
// Make sure we start with client state disabled
// /////////////////////////////////////////////////////////
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
// Enable arrays client states
// /////////////////////////////////////////////////////////
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_NORMAL_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, mesh.m_Positions );
glNormalPointer( GL_FLOAT, 0, mesh.m_Normals );
if( mesh.m_Color != NULL )
{
glEnableClientState( GL_COLOR_ARRAY );
float transparency = 0.0f;
if( mesh.m_MaterialIdx < a3DModel.m_MaterialsSize )
transparency = a3DModel.m_Materials[mesh.m_MaterialIdx].m_Transparency;
if( (transparency > FLT_EPSILON) &&
(aMaterialMode == MATERIAL_MODE_NORMAL) )
{
// Create a new array of RGBA colors
pColorRGBA = new SFVEC4F[mesh.m_VertexSize];
// Copy RGB array and add the Alpha value
for( unsigned int i = 0; i < mesh.m_VertexSize; ++i )
pColorRGBA[i] = SFVEC4F( mesh.m_Color[i],
1.0f - transparency );
// Load an RGBA array
glColorPointer( 4, GL_FLOAT, 0, pColorRGBA );
}
else
{
switch( aMaterialMode )
{
case MATERIAL_MODE_NORMAL:
case MATERIAL_MODE_DIFFUSE_ONLY:
// load the original RGB color array
glColorPointer( 3, GL_FLOAT, 0, mesh.m_Color );
break;
case MATERIAL_MODE_CAD_MODE:
// Create a new array of RGBA colors
pColorRGBA = new SFVEC4F[mesh.m_VertexSize];
// Copy RGB array and add the Alpha value
for( unsigned int i = 0; i < mesh.m_VertexSize; ++i )
{
pColorRGBA[i] =
SFVEC4F( MaterialDiffuseToColorCAD( mesh.m_Color[i] ),
1.0f );
}
// Load an RGBA array
glColorPointer( 4, GL_FLOAT, 0, pColorRGBA );
break;
default:
break;
}
}
}
if( mesh.m_Texcoords != NULL )
{
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer( 2, GL_FLOAT, 0, mesh.m_Texcoords );
}
// Compile the display list to store triangles
// /////////////////////////////////////////////////////////
glNewList( m_ogl_idx_list_meshes + mesh_i, GL_COMPILE );
// Set material properties
// /////////////////////////////////////////////////////////
if( mesh.m_Color != NULL )
{
// This enables the use of the Color Pointer information
glEnable( GL_COLOR_MATERIAL );
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
}
else
{
glDisable( GL_COLOR_MATERIAL );
}
if( mesh.m_MaterialIdx < a3DModel.m_MaterialsSize )
{
switch( aMaterialMode )
{
case MATERIAL_MODE_NORMAL:
OGL_SetMaterial( a3DModel.m_Materials[mesh.m_MaterialIdx] );
break;
case MATERIAL_MODE_DIFFUSE_ONLY:
OGL_SetDiffuseOnlyMaterial(
a3DModel.m_Materials[mesh.m_MaterialIdx].m_Diffuse );
break;
case MATERIAL_MODE_CAD_MODE:
OGL_SetDiffuseOnlyMaterial(
MaterialDiffuseToColorCAD(
a3DModel.m_Materials[mesh.m_MaterialIdx].m_Diffuse ) );
break;
default:
break;
}
}
// Draw mesh
// /////////////////////////////////////////////////////////
glDrawElements( GL_TRIANGLES, mesh.m_FaceIdxSize,
GL_UNSIGNED_INT, mesh.m_FaceIdx );
glDisable( GL_COLOR_MATERIAL );
glEndList();
// Disable arrays client states
// /////////////////////////////////////////////////////////
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
glFinish();
delete [] pColorRGBA;
}
}
}// for each mesh
m_ogl_idx_list_opaque = glGenLists( 1 );
// Check if the generated list is valid
if( glIsList( m_ogl_idx_list_opaque ) )
{
bool have_opaque_meshes = false;
bool have_transparent_meshes = false;
// Compile the model display list
glNewList( m_ogl_idx_list_opaque, GL_COMPILE );
// Render each mesh display list (opaque first)
// /////////////////////////////////////////////////////////////////
for( unsigned int mesh_i = 0; mesh_i < a3DModel.m_MeshesSize; ++mesh_i )
{
const SMESH &mesh = a3DModel.m_Meshes[mesh_i];
if( mesh.m_MaterialIdx < a3DModel.m_MaterialsSize )
{
const SMATERIAL &material = a3DModel.m_Materials[mesh.m_MaterialIdx];
if( material.m_Transparency == 0.0f )
{
have_opaque_meshes = true; // Flag that we have at least one opaque mesh
glCallList( m_ogl_idx_list_meshes + mesh_i );
}
else
{
have_transparent_meshes = true; // Flag that we found a transparent mesh
}
}
}
glEndList();
if( !have_opaque_meshes )
{
// If we dont have opaque meshes, we can free the list
glDeleteLists( m_ogl_idx_list_opaque, 1 );
m_ogl_idx_list_opaque = 0;
}
if( have_transparent_meshes )
{
m_ogl_idx_list_transparent = glGenLists( 1 );
// Check if the generated list is valid
if( glIsList( m_ogl_idx_list_transparent ) )
{
// Compile the model display list
glNewList( m_ogl_idx_list_transparent, GL_COMPILE );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
// Render each mesh display list
// /////////////////////////////////////////////////////////
for( unsigned mesh_i = 0; mesh_i < a3DModel.m_MeshesSize; ++mesh_i )
{
const SMESH &mesh = a3DModel.m_Meshes[mesh_i];
if( mesh.m_MaterialIdx < a3DModel.m_MaterialsSize )
{
const SMATERIAL &material = a3DModel.m_Materials[mesh.m_MaterialIdx];
// Render the transparent mesh if it have a transparency value
if( material.m_Transparency != 0.0f )
glCallList( m_ogl_idx_list_meshes + mesh_i );
}
}
glDisable( GL_BLEND );
glEndList();
}
else
{
m_ogl_idx_list_transparent = 0;
}
}
}
else
{
m_ogl_idx_list_opaque = 0;
}
// Create the main bbox
// /////////////////////////////////////////////////////////////////////
m_model_bbox.Reset();
for( unsigned int mesh_i = 0; mesh_i < a3DModel.m_MeshesSize; ++mesh_i )
m_model_bbox.Union( m_meshs_bbox[mesh_i] );
glFinish();
}
}
void C_OGL_3DMODEL::Draw_opaque() const
{
if( glIsList( m_ogl_idx_list_opaque ) )
glCallList( m_ogl_idx_list_opaque );
}
void C_OGL_3DMODEL::Draw_transparent() const
{
if( glIsList( m_ogl_idx_list_transparent ) )
glCallList( m_ogl_idx_list_transparent );
}
C_OGL_3DMODEL::~C_OGL_3DMODEL()
{
if( glIsList( m_ogl_idx_list_opaque ) )
glDeleteLists( m_ogl_idx_list_opaque, 1 );
if( glIsList( m_ogl_idx_list_transparent ) )
glDeleteLists( m_ogl_idx_list_transparent, 1 );
if( glIsList( m_ogl_idx_list_meshes ) )
glDeleteLists( m_ogl_idx_list_meshes, m_nr_meshes );
m_ogl_idx_list_meshes = 0;
m_ogl_idx_list_opaque = 0;
m_ogl_idx_list_transparent = 0;
delete[] m_meshs_bbox;
m_meshs_bbox = NULL;
}
void C_OGL_3DMODEL::Draw_bbox() const
{
OGL_draw_bbox( m_model_bbox );
}
void C_OGL_3DMODEL::Draw_bboxes() const
{
for( unsigned int mesh_i = 0; mesh_i < m_nr_meshes; ++mesh_i )
OGL_draw_bbox( m_meshs_bbox[mesh_i] );
}
bool C_OGL_3DMODEL::Have_opaque() const
{
return glIsList( m_ogl_idx_list_opaque );
}
bool C_OGL_3DMODEL::Have_transparent() const
{
return glIsList( m_ogl_idx_list_transparent );
}
@@ -0,0 +1,97 @@
/*
* 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 c_ogl_3dmodel.h
* @brief implement a legacy 3dmodel render
*/
#ifndef _C_OGL_3DMODEL_H_
#define _C_OGL_3DMODEL_H_
#include <plugins/3dapi/c3dmodel.h>
#include "../../common_ogl/openGL_includes.h"
#include "../3d_render_raytracing/shapes3D/cbbox.h"
#include "../../3d_enums.h"
///
class C_OGL_3DMODEL
{
public:
/**
* @brief C_OGL_3DMODEL - Load a 3d model. 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
*/
C_OGL_3DMODEL( const S3DMODEL &a3DModel, MATERIAL_MODE aMaterialMode );
~C_OGL_3DMODEL();
/**
* @brief Draw_opaque - render the model into the current context
*/
void Draw_opaque() const;
/**
* @brief Draw_transparent - render the model into the current context
*/
void Draw_transparent() const;
/**
* @brief Have_opaque - return true if have opaque meshs to render
*/
bool Have_opaque() const;
/**
* @brief Have_transparent - return true if have transparent meshs to render
*/
bool Have_transparent() const;
/**
* @brief Draw_bbox - draw main bounding box of the model
*/
void Draw_bbox() const;
/**
* @brief Draw_bboxes - draw individual bounding boxes of each mesh
*/
void Draw_bboxes() const;
/**
* @brief GetBBox - Get main bbox
* @return the main model bbox
*/
const CBBOX &GetBBox() const { return m_model_bbox; }
private:
GLuint m_ogl_idx_list_opaque; ///< display list for rendering opaque meshes
GLuint m_ogl_idx_list_transparent; ///< display list for rendering transparent meshes
GLuint m_ogl_idx_list_meshes; ///< display lists for all meshes.
unsigned int m_nr_meshes; ///< number of meshes of this model
CBBOX m_model_bbox; ///< global bounding box for this model
CBBOX *m_meshs_bbox; ///< individual bbox for each mesh
};
#endif // _C_OGL_3DMODEL_H_

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