KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGFX::GRID_SOURCE Struct Reference

Render-time projection of a grid: GRID_GEOMETRY (kind/origin/pitch/orientation/extent) plus rendering and interaction flags. More...

#include <graphics_abstraction_layer.h>

Inheritance diagram for KIGFX::GRID_SOURCE:
GRID_GEOMETRY

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

bool unbounded = false
 No extent; visible range derived from screen corners.
 
bool axesEnabled = false
 Skip grid lines coincident with the world axes (only meaningful for unbounded cartesian).
 
bool snapCursor = false
 Participate in the cursor snap (GAL::GetGridPoint).
 
bool highlighted = false
 Render with edit-mode emphasis (selected grid).
 
unsigned tick = 0
 Major-tick interval (0 = inherit default).
 
COLOR4D color
 
GRID_STYLE style = GRID_STYLE::LINES
 
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.
 

Detailed Description

Render-time projection of a grid: GRID_GEOMETRY (kind/origin/pitch/orientation/extent) plus rendering and interaction flags.

SetGridSources keeps the list in precedence order, so consumers may simply take the first source that applies.

Definition at line 73 of file graphics_abstraction_layer.h.

Member Enumeration Documentation

◆ KIND

enum class GRID_GEOMETRY::KIND
stronginherited
Enumerator
CARTESIAN 
POLAR 

Definition at line 32 of file grid_geometry.h.

Member Function Documentation

◆ Area()

double GRID_GEOMETRY::Area ( ) const
inherited
Returns
the area of the grid's coverage region. Used as a tiebreaker between overlapping grids of equal priority - smaller wins (more specific).

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().

◆ Contains()

bool GRID_GEOMETRY::Contains ( const VECTOR2D & aPoint,
double aTolerance = 0.0 ) const
inherited
Returns
true if aPoint is within aTolerance of the grid's coverage.

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()

VECTOR2D GRID_GEOMETRY::Snap ( const VECTOR2D & aPoint) const
inherited

Snap a point to the nearest on-grid position.

Returns
aPoint unchanged for degenerate geometry (non-positive pitch).

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.

◆ TakesPrecedenceOver()

bool GRID_GEOMETRY::TakesPrecedenceOver ( const GRID_GEOMETRY & aOther) const
inlineinherited
Returns
true if this grid owns a point that both grids cover: higher priority first, then the smaller (more specific) area.

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().

Member Data Documentation

◆ axesEnabled

bool KIGFX::GRID_SOURCE::axesEnabled = false

Skip grid lines coincident with the world axes (only meaningful for unbounded cartesian).

Definition at line 77 of file graphics_abstraction_layer.h.

Referenced by KIGFX::CAIRO_GAL_BASE::DrawGrid(), KIGFX::OPENGL_GAL::DrawGrid(), KIGFX::CAIRO_GAL_BASE::drawGridSource(), and KIGFX::OPENGL_GAL::drawGridSources().

◆ color

◆ extent

VECTOR2D GRID_GEOMETRY::extent
inherited

◆ highlighted

bool KIGFX::GRID_SOURCE::highlighted = false

Render with edit-mode emphasis (selected grid).

Definition at line 80 of file graphics_abstraction_layer.h.

Referenced by KIGFX::CAIRO_GAL_BASE::drawGridSource(), KIGFX::OPENGL_GAL::drawGridSources(), and PCB_DRAW_PANEL_GAL::prepareGridSources().

◆ kind

◆ orientation

◆ origin

◆ pitch

◆ priority

unsigned GRID_GEOMETRY::priority = 0
inherited

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().

◆ snapCursor

bool KIGFX::GRID_SOURCE::snapCursor = false

Participate in the cursor snap (GAL::GetGridPoint).

Definition at line 79 of file graphics_abstraction_layer.h.

Referenced by PCB_DRAW_PANEL_GAL::prepareGridSources().

◆ style

◆ tick

unsigned KIGFX::GRID_SOURCE::tick = 0

◆ unbounded

bool KIGFX::GRID_SOURCE::unbounded = false

The documentation for this struct was generated from the following file: