|
KiCad PCB EDA Suite
|
Geometry of a regular grid (cartesian or polar) and the math operations for snapping and coverage testing. More...
#include <grid_geometry.h>
Public Types | |
| enum class | KIND { CARTESIAN , POLAR } |
Public Member Functions | |
| VECTOR2D | Snap (const VECTOR2D &aPoint) const |
| Snap a point to the nearest on-grid position. | |
| bool | Contains (const VECTOR2D &aPoint, double aTolerance=0.0) const |
| double | Area () const |
| bool | TakesPrecedenceOver (const GRID_GEOMETRY &aOther) const |
Public Attributes | |
| KIND | kind = KIND::CARTESIAN |
| VECTOR2D | origin |
| VECTOR2D | pitch |
| Cartesian: (dx, dy); polar: (dr, dPhi rad). | |
| double | orientation = 0.0 |
| Rotation about origin, radians CCW. | |
| VECTOR2D | extent |
| Cartesian: (dx, dy) = size/2 from origin. | |
| unsigned | priority = 0 |
| Higher wins where grids overlap. | |
Geometry of a regular grid (cartesian or polar) and the math operations for snapping and coverage testing.
Definition at line 30 of file grid_geometry.h.
|
strong |
| Enumerator | |
|---|---|
| CARTESIAN | |
| POLAR | |
Definition at line 32 of file grid_geometry.h.
| double GRID_GEOMETRY::Area | ( | ) | const |
Definition at line 124 of file grid_geometry.cpp.
References std::abs(), CARTESIAN, extent, kind, and POLAR.
Referenced by PCB_GRID_ITEM::GetCoverageArea(), and TakesPrecedenceOver().
| bool GRID_GEOMETRY::Contains | ( | const VECTOR2D & | aPoint, |
| double | aTolerance = 0.0 ) const |
Definition at line 93 of file grid_geometry.cpp.
References std::abs(), CARTESIAN, extent, GetRotated(), kind, M_PI, orientation, origin, POLAR, RADIANS_T, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by PCB_GRID_ITEM::HitTest(), and PCB_GRID_ITEM::HitTestArea().
Snap a point to the nearest on-grid position.
Definition at line 29 of file grid_geometry.cpp.
References CARTESIAN, extent, GetRotated(), kind, M_PI, orientation, origin, pitch, POLAR, RADIANS_T, VECTOR2< T >::x, and VECTOR2< T >::y.
|
inline |
The Compare for std::stable_sort - the winner sorts FIRST, ties keep document order. The background grid is the only one at priority 0, so it always sorts last.
Definition at line 72 of file grid_geometry.h.
References Area(), and priority.
Referenced by FindActiveGridAt().
| VECTOR2D GRID_GEOMETRY::extent |
Cartesian: (dx, dy) = size/2 from origin.
Polar: (rMax, phiMax rad).
Definition at line 42 of file grid_geometry.h.
Referenced by Area(), PCB_GRID_ITEM::AsGridGeometry(), Contains(), KIGFX::CAIRO_GAL_BASE::drawGridCoverageShape(), KIGFX::OPENGL_GAL::drawGridCoverageShape(), KIGFX::CAIRO_GAL_BASE::drawGridSource(), KIGFX::OPENGL_GAL::drawGridSources(), and Snap().
| KIND GRID_GEOMETRY::kind = KIND::CARTESIAN |
Definition at line 38 of file grid_geometry.h.
Referenced by Area(), PCB_GRID_ITEM::AsGridGeometry(), Contains(), KIGFX::CAIRO_GAL_BASE::DrawGrid(), KIGFX::OPENGL_GAL::DrawGrid(), KIGFX::CAIRO_GAL_BASE::drawGridCoverageShape(), KIGFX::OPENGL_GAL::drawGridCoverageShape(), KIGFX::CAIRO_GAL_BASE::drawGridSource(), KIGFX::OPENGL_GAL::drawGridSources(), and Snap().
| double GRID_GEOMETRY::orientation = 0.0 |
Rotation about origin, radians CCW.
Definition at line 41 of file grid_geometry.h.
Referenced by PCB_GRID_ITEM::AsGridGeometry(), Contains(), KIGFX::CAIRO_GAL_BASE::drawGridCoverageShape(), KIGFX::OPENGL_GAL::drawGridCoverageShape(), KIGFX::CAIRO_GAL_BASE::drawGridSource(), KIGFX::OPENGL_GAL::drawGridSources(), KIGFX::GAL::gridScreenBBox(), and Snap().
| VECTOR2D GRID_GEOMETRY::origin |
Definition at line 39 of file grid_geometry.h.
Referenced by PCB_GRID_ITEM::AsGridGeometry(), Contains(), KIGFX::CAIRO_GAL_BASE::DrawGrid(), KIGFX::OPENGL_GAL::DrawGrid(), KIGFX::CAIRO_GAL_BASE::drawGridCoverageShape(), KIGFX::OPENGL_GAL::drawGridCoverageShape(), KIGFX::CAIRO_GAL_BASE::drawGridSource(), KIGFX::OPENGL_GAL::drawGridSources(), KIGFX::GAL::gridScreenBBox(), and Snap().
| VECTOR2D GRID_GEOMETRY::pitch |
Cartesian: (dx, dy); polar: (dr, dPhi rad).
Definition at line 40 of file grid_geometry.h.
Referenced by PCB_GRID_ITEM::AsGridGeometry(), KIGFX::CAIRO_GAL_BASE::DrawGrid(), KIGFX::OPENGL_GAL::DrawGrid(), KIGFX::CAIRO_GAL_BASE::drawGridSource(), KIGFX::OPENGL_GAL::drawGridSources(), PCB_DRAW_PANEL_GAL::prepareGridSources(), and Snap().
| unsigned GRID_GEOMETRY::priority = 0 |
Higher wins where grids overlap.
0 is reserved for the background grid; see TakesPrecedenceOver.
Definition at line 44 of file grid_geometry.h.
Referenced by PCB_GRID_ITEM::AsGridGeometry(), KIGFX::CAIRO_GAL_BASE::DrawGrid(), KIGFX::OPENGL_GAL::DrawGrid(), and TakesPrecedenceOver().