Commit Graph

155 Commits

Author SHA1 Message Date
John Beard 7acc0b89f9 Pcbnew: fix 45-degree snapping of ruler and dimension tools
This introduces a new util function in geometry_utils which snaps a vector
to axes or 45 degree lines. This can be used whenever you want to
snap a vector to these angles, but still want it to stay on a grid.

This snapping is used for the dimension tool and the ruler tool.

This is substantially simpler for two-point tools that the method
used by the line tool, which uses DIRECTION_45.

Fixes: lp:1780826
https://bugs.launchpad.net/kicad/+bug/1780826
2018-07-24 15:01:02 +01:00
Seth Hillbrand 840ad7f680 Add SH_ARC collisions 2018-07-17 10:08:13 -07:00
Maciej Suminski 73a8d2a9d5 OPENGL GAL: Fixed the iteration condition when drawing triangulated polyset
The loop used an incorrect variable size as the loop limit,
occasionally causing out of bounds accesses.

Fixes: lp:1778288
* https://bugs.launchpad.net/kicad/+bug/1778288
2018-06-23 02:05:21 +02:00
Maciej Suminski 1751e4631c Code formatting 2018-06-23 01:59:49 +02:00
Seth Hillbrand 4959f91dac pcbnew: Ensure Connectivity RTree gets updated
When removing items, we perform a two-pass removal, checking first
for the cached rectangle collision.  Then, if we do not find the item
being removed, we perform a second, more expensive pass over the full
tree.  This second pass is required as we cannot be certain that an
item's bbox has not been modified between insertion and deletion.  In
which case, keeping stale pointers in the tree will lead to segfaults.

Fixes: lp:1777246
* https://bugs.launchpad.net/kicad/+bug/1777246
2018-06-16 21:45:55 -07:00
Seth Hillbrand d67821d771 Add a clearance check for closed shape line chains
Also improves speed of multiple point checks by first eliminating points
outside of the BBox.
2018-05-11 15:42:41 -07:00
Seth Hillbrand b2c4519c2c Setting custom pad shape to be outline for PNS
Changes SHAPE_CONVEX to SHAPE_SIMPLE to better reflect the limitations.
Changes SHAPE_LINE_CHAIN::PointInside calculation to allow points
strictly inside a line chain

Fixes: lp:1768862
* https://bugs.launchpad.net/kicad/+bug/1768862
2018-05-04 08:23:20 -07:00
Seth Hillbrand dbfa9093ab Adding seg-polyset collision support 2018-04-23 16:43:13 -07:00
Seth Hillbrand b618da1fac Fixing bounding box calc for arcs 2018-04-23 16:43:13 -07:00
Jeff Young d54a252eaa Check zone fills for being out-of-date during DRC. 2018-04-09 11:05:14 +01:00
Maciej Suminski 168112cf84 SEG: added Center() method 2018-03-29 12:11:35 +02:00
Jeff Young fbf10e941b Switch zone fillets to absolute-error algorithm.
And some general cleanup to related constants, etc.
2018-03-23 12:46:17 +00:00
jean-pierre charras 51fe063524 Circle to polygon conversion: a few enhancements:
* Remove duplicate code
* fix incorrect formulas is some places
* add comments
2018-03-09 13:28:47 +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
Jon Evans 01ab8b0584 Use polygonal hit testing for module selection 2018-02-20 10:43:43 -05:00
Maciej Suminski 6c1a05a7d5 Coverity fixes
Uninitialized variables: CID #163188 and #174187
Unused variable: CID #168698
2018-02-20 09:14:51 +01:00
jean-pierre charras cf5d93857f PnS router: add support for circles in board outline 2018-02-18 21:00:28 +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
Maciej Suminski 570f4dd991 Coverity fixes
CIDs:
174166
174170
174171
2018-02-15 10:27:01 +01:00
jean-pierre charras 4012aa70da Fix a few minor Coverity warnings 2018-02-15 10:16:17 +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
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
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
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
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
Tomasz Włostowski 8df299a6bc pcbnew: Optimized zone filling algorithm: code cleanup 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
jean-pierre charras 9723b0d844 Fix a few minor coverity warnings (not initialized members) 2017-11-11 07:25:00 +01:00
Marvin Schmidt 69974b73db Remove some extra semicolons 2017-11-09 19:52:18 +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
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
Tomasz Włostowski d2c9a5d81a geometry: Area() method in SHAPE_LINE_CHAIN 2017-10-19 23:14:36 +02:00
jean-pierre charras b8c621a991 fix a few Coverity warnings. 2017-08-06 14:23:03 +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 3b16d3cffe further DLIST/Iterators cleanup, some code formatting 2017-06-23 11:12:37 +02:00
Tomasz Włostowski 9ad886344b New connectivity algorithm. 2017-06-23 11:12:36 +02:00
jean-pierre charras 1466d0cee6 Fix a few doxygen warnings 2017-06-18 09:18:41 +02: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 88105f891f Fixes Pcbnew bug: Drag Zone Outlines no longer working in legacy view 2017-04-16 18:32:47 +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
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 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
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
Simon Richter ad088db6d2 Add more "override" markers. 2016-09-25 13:59:41 -04:00
Simon Richter 59c81976dc Explicitly mark overriding functions. 2016-09-24 14:53:15 -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
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
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
jean-pierre charras 4a838fb8c3 Pcbnew: Add rounded rect pad shape. 2016-04-06 20:15:49 +02:00
Tomasz Wlostowski 0fa71d8d8f more accurate pushout force calculation for circle-segment collisions 2016-03-01 14:26:08 +01: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
Mario Luzeiro 61f4f1ca9d Add hole count function and other minor improvements to SHAPE_POLY_SET. 2015-08-24 09:55:22 -04:00
Tomasz Wlostowski a96299d456 router: improvements to shove algorithm 2015-08-19 18:07:16 +02:00
jean-pierre charras c63f6aa3c5 Polygon boolean operations on SHAPE_POLY_SET: Add a parameter (aFastMode) to speed up calculations. By default, the transforms use an option to create stricly simple polygons.
In 3D viewer, this option can take a *very long* calculation time (minutes instead of seconds, or hangs) and they are now using aFastMode = true to do polygon calculations, especially for zones inside zones belong to the same net but having different priority (which creates weak polygons).
aFastMode = false is the default for other calculations (zone filling) as before.
2015-08-16 14:07:58 +02:00
Maciej Suminski 65ebfe12c1 Fixed oval pads highlighting in mark collisions mode (PNS). 2015-08-10 17:50:10 +02:00
Tomasz Wlostowski 07f5516e59 geometry: Parse() method for SHAPE_LINE_CHAIN, working on Read() in SHAPE_FILE_IO 2015-08-03 20:29:44 +02:00
jean-pierre charras 4b4d9d9770 Plot solder mask layer: fix incorrect margin of zones drawn on this layer (zone areas were slighly larger than the actual areas)
Fix a few  minor and very minor other issues: coverity warnings and compil warning.
2015-08-01 12:20:23 +02:00
Tomasz Wlostowski 1d7e49a45c SHAPE_POLY_SET::Inflate(): correct arc approximation for negative offsets (deflation). Control circle->segments count explicitly in all Inflate() calls 2015-07-27 21:46:47 +02:00
Tomasz Wlostowski 63b35f40a7 Removed all dependencies on boost::polygon except for bitmap2component. Replaced almost all instances of CPOLYGONS_LIST with SHAPE_POLY_SET. 2015-07-27 21:45:57 +02:00
Maciej Suminski d2ebf688f9 Reverted commits that remove boost::polygon dependency (need more testing). 2015-07-14 22:23:13 +02:00
Tomasz Wlostowski 9f18e5a98f SHAPE_POLY_SET::Inflate(): correct arc approximation for negative offsets (deflation). Control circle->segments count explicitly in all Inflate() calls 2015-07-14 15:05:41 +02:00
Tomasz Wlostowski 41c753b05d Removed all dependencies on boost::polygon except for bitmap2component. Replaced almost all instances of CPOLYGONS_LIST with SHAPE_POLY_SET. 2015-07-14 13:36:24 +02:00
Tomasz Włostowski 24170f5588 Fixes to SHAPE_POLY_SET slitting/fracturing algo, some speed optimization. 2015-07-06 15:15:48 +02:00
Tomasz Wlostowski 506e8c4d89 added missing file 2015-07-02 16:11:02 +02:00
Mathias Grimmberger 7724c581fd router: support for non-90 degree pad orientations 2015-07-02 16:09:43 +02:00
Tomasz Wlostowski feaa403266 common/geometry: introducing set-of-polygons class (SHAPE_POLY_SET) and File I/O for shapes class (SHAPE_FILE_IO) 2015-06-12 17:12:02 +02:00
Tomasz Wlostowski 7e4bc6262c common/geometry: added AllowDuplication option for adding vertices to a SHAPE_LINE_CHAIN 2015-06-12 17:11:56 +02:00
Tomasz Wlostowski 9cf885c383 common/geometry: rouding error fixes 2015-06-12 17:11:50 +02:00
Maciej Suminski e6a10faab7 FIxed a few clang warnings. 2015-03-09 11:06:54 +01:00
Alexander Golubev f2ce42ddb5 fix several -Woverloaded-virtual warnings in common/* dir
- CACHED_CONTAINER::GetVertices: removed useless and unused function
   which does nothing but tainted the API
 - SHAPE_LINE_CHAIN::Collide( const BOX2I& aBox, int aClearance ):
   removed an outdated function with assert(false)
 - SHAPE::BBox(): fix a small typo in the doc string
2015-03-06 15:26:47 +01:00
Maciej Suminski 4fb9bce354 Code formatting. 2015-02-18 17:53:46 +01:00
Tomasz Włostowski c87b136522 geometry: new methods and fixes in SEG class 2015-02-18 00:40:11 +01:00
Maciej Suminski 9245b90392 Code formatting. 2014-11-14 20:19:00 +01:00
Tomasz Wlostowski 33f3aca611 geometry: IsSolid() and Move() methods, segment overlap detection, some improvements in SHAPE_LINE_CHAIN class. 2014-11-14 19:18:31 +01:00
jean-pierre charras 24f516f6ae Fix many doxygen warnings (due to missing info, old comments, typo ...) when building the doxygen doc. 2014-11-02 17:25:04 +01:00
Maciej Sumiński 46020e20de Merged the new Interactive Push and Shove router.
Do not pay attention to add/remove files - it seems there may be a bug in git-bzr-ng plugin. I have checked them, they stayed exactly the same as before.
2014-05-18 17:16:59 +02:00
Tomasz Włostowski dd5558f653 geometry: GetShape()->Shape() in indexed shape containers 2014-05-14 13:53:02 +02:00
Tomasz Włostowski 5a51d11b78 geometry: get rid of useless vertex references in SEG class 2014-05-14 13:52:29 +02:00
Maciej Suminski 0ae6b4412e Added a missing file. 2014-05-14 11:47:17 +02:00
Maciej Suminski cce6e27096 Various fixes to geometry & math library. 2014-05-14 11:45:01 +02:00
Maciej Suminski 009d28d48c Merged lp:~cern-kicad/kicad/drawing_tool branch. 2014-05-13 10:19:37 +02:00
Maciej Suminski 402c7d21cb Fixed ifdefs in rtree.h. 2014-05-13 10:01:06 +02:00
Maciej Suminski c3b448b633 Upstream merge. 2014-05-01 15:55:50 +02:00
Marco Serantoni d2083b0671 [MacOSX] Fix for name collision with OSX headers, Maciej, Tomasz or others feel free to rework if you want/like 2014-04-27 16:28:37 +02:00
Maciej Suminski 342fd6e19e EC_CONVERGING handles colinear lines properly. 2014-03-18 13:57:10 +01:00
Maciej Suminski 66fcb84f92 Minor fix to SEG class. 2014-03-12 10:05:09 +01:00
Maciej Suminski f82e07849b Improved way of drawing 45-degree lines. 2014-02-17 11:33:03 +01:00
Maciej Suminski d7fc8db02c Removed warning. 2013-12-05 13:46:13 +01:00
Maciej Suminski 89b80b2bcd Merged rtree.h, to avoid code duplication.
Fixes the case, when waste is never greater then the worst case and seeds assignment does not occur.
2013-11-13 17:03:22 +01:00
Orson 28b9317640 Fix redraw issue in modedit a modview, with GAL 2013-11-01 13:56:20 +01:00
Maciej Suminski bc305859b2 Mainly case changes. 2013-10-14 20:40:36 +02:00
Maciej Suminski 0ac3e1fbf2 Namespace KiGfx->KIGFX.
template<> -> template <>
Some more reformatting according to uncrustify results.
2013-10-14 16:13:35 +02:00
Maciej Suminski 22045b61ea Converted tabs to spaces. Removed trailing whitespaces. 2013-10-14 13:43:57 +02:00
Maciej Suminski 6b74b5771a Even more code comments and reformatting. 2013-09-27 18:51:21 +02:00
Maciej Suminski 3f320e4d68 Some more comments and code formatting. 2013-09-27 16:23:43 +02:00
Maciej Suminski 7837dfa3ac Fixed build for Mac OS 2013-09-23 17:02:25 +02:00