KiCad PCB EDA Suite
MARKER_BASE Class Referenceabstract

#include <marker_base.h>

Inheritance diagram for MARKER_BASE:
PCB_MARKER SCH_MARKER

Public Types

enum  TYPEMARKER { MARKER_UNSPEC, MARKER_ERC, MARKER_PCB, MARKER_SIMUL }
 

Public Member Functions

 MARKER_BASE (int aScalingFactor, std::shared_ptr< RC_ITEM > aItem, TYPEMARKER aType=MARKER_UNSPEC)
 
virtual ~MARKER_BASE ()
 
int MarkerScale () const
 The scaling factor to convert polygonal shape coordinates to internal units. More...
 
void ShapeToPolygon (SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
 Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the marker position (are not absolute). More...
 
void PrintMarker (const RENDER_SETTINGS *aSettings, const wxPoint &aOffset)
 Print the shape is the polygon defined in m_Corners (array of wxPoints). More...
 
const wxPoint & GetPos () const
 
virtual const KIID GetUUID () const =0
 
void SetMarkerType (enum TYPEMARKER aMarkerType)
 Accessors to set/get marker type (DRC, ERC, or other) More...
 
enum TYPEMARKER GetMarkerType () const
 
bool IsExcluded () const
 
void SetExcluded (bool aExcluded)
 
std::shared_ptr< RC_ITEMGetRCItem () const
 
bool HitTestMarker (const wxPoint &aHitPosition, int aAccuracy) const
 Test if the given wxPoint is within the bounds of this object. More...
 
EDA_RECT GetBoundingBoxMarker () const
 Return the orthogonal, bounding box of this object for display purposes. More...
 

Public Attributes

wxPoint m_Pos
 position of the marker More...
 

Protected Member Functions

virtual KIGFX::COLOR4D getColor () const =0
 

Protected Attributes

TYPEMARKER m_markerType
 
bool m_excluded
 
std::shared_ptr< RC_ITEMm_rcItem
 
int m_scalingFactor
 
EDA_RECT m_shapeBoundingBox
 

Detailed Description

Definition at line 49 of file marker_base.h.

Member Enumeration Documentation

◆ TYPEMARKER

Enumerator
MARKER_UNSPEC 
MARKER_ERC 
MARKER_PCB 
MARKER_SIMUL 

Definition at line 52 of file marker_base.h.

Constructor & Destructor Documentation

◆ MARKER_BASE()

MARKER_BASE::MARKER_BASE ( int  aScalingFactor,
std::shared_ptr< RC_ITEM aItem,
TYPEMARKER  aType = MARKER_UNSPEC 
)

Definition at line 61 of file marker_base.cpp.

61  :
62  m_markerType( aType ),
63  m_excluded( false ),
64  m_rcItem( aItem ),
65  m_scalingFactor( aScalingFactor )
66 {
67  const VECTOR2I* point_shape = MarkerShapeCorners;
68  wxPoint start( point_shape->x, point_shape->y );
69  wxPoint end = start;
70 
71  for( unsigned ii = 1; ii < CORNERS_COUNT; ii++ )
72  {
73  ++point_shape;
74  start.x = std::min( start.x, point_shape->x);
75  start.y = std::min( start.y, point_shape->y);
76  end.x = std::max( end.x, point_shape->x);
77  end.y = std::max( end.y, point_shape->y);
78  }
79 
82 }
bool m_excluded
Definition: marker_base.h:127
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:121
TYPEMARKER m_markerType
Definition: marker_base.h:126
const unsigned CORNERS_COUNT
Definition: marker_base.cpp:58
std::shared_ptr< RC_ITEM > m_rcItem
Definition: marker_base.h:128
void SetEnd(int x, int y)
Definition: eda_rect.h:182
EDA_RECT m_shapeBoundingBox
Definition: marker_base.h:132
int m_scalingFactor
Definition: marker_base.h:130
static const VECTOR2I MarkerShapeCorners[]
Definition: marker_base.cpp:46

References CORNERS_COUNT, m_shapeBoundingBox, MarkerShapeCorners, EDA_RECT::SetEnd(), EDA_RECT::SetOrigin(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ ~MARKER_BASE()

MARKER_BASE::~MARKER_BASE ( )
virtual

Definition at line 85 of file marker_base.cpp.

86 {
87 }

Member Function Documentation

◆ GetBoundingBoxMarker()

EDA_RECT MARKER_BASE::GetBoundingBoxMarker ( ) const

Return the orthogonal, bounding box of this object for display purposes.

This box should be an enclosing perimeter for visible components of this object, and the units should be in the pcb or schematic coordinate system. It is OK to overestimate the size by a few counts.

Definition at line 123 of file marker_base.cpp.

124 {
125  wxSize size_iu = m_shapeBoundingBox.GetSize();
126  wxPoint position_iu = m_shapeBoundingBox.GetPosition();
127  size_iu.x *= m_scalingFactor;
128  size_iu.y *= m_scalingFactor;
129  position_iu.x *= m_scalingFactor;
130  position_iu.y *= m_scalingFactor;
131  position_iu += m_Pos;
132 
133  return EDA_RECT( position_iu, size_iu );
134 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:123
EDA_RECT m_shapeBoundingBox
Definition: marker_base.h:132
const wxPoint GetPosition() const
Definition: eda_rect.h:102
int m_scalingFactor
Definition: marker_base.h:130
Handle the component boundary box.
Definition: eda_rect.h:42
const wxSize GetSize() const
Definition: eda_rect.h:91

References EDA_RECT::GetPosition(), EDA_RECT::GetSize(), m_Pos, m_scalingFactor, and m_shapeBoundingBox.

Referenced by SCH_MARKER::GetBoundingBox(), and HitTestMarker().

◆ getColor()

virtual KIGFX::COLOR4D MARKER_BASE::getColor ( ) const
protectedpure virtual

Implemented in PCB_MARKER, and SCH_MARKER.

Referenced by PrintMarker().

◆ GetMarkerType()

enum TYPEMARKER MARKER_BASE::GetMarkerType ( ) const
inline

Definition at line 92 of file marker_base.h.

92 { return m_markerType; }
TYPEMARKER m_markerType
Definition: marker_base.h:126

References m_markerType.

Referenced by SCH_SCREENS::DeleteMarkers(), SHEETLIST_ERC_ITEMS_PROVIDER::visitMarkers(), and DIALOG_ERC::writeReport().

◆ GetPos()

const wxPoint& MARKER_BASE::GetPos ( ) const
inline
Returns
the position of this marker in internal units.

Definition at line 84 of file marker_base.h.

84 { return m_Pos; }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:123

References m_Pos.

Referenced by PCB_SELECTION_TOOL::hitTestDistance().

◆ GetRCItem()

◆ GetUUID()

virtual const KIID MARKER_BASE::GetUUID ( ) const
pure virtual

Implemented in PCB_MARKER, and SCH_MARKER.

◆ HitTestMarker()

bool MARKER_BASE::HitTestMarker ( const wxPoint &  aHitPosition,
int  aAccuracy 
) const

Test if the given wxPoint is within the bounds of this object.

Parameters
aHitPositionis the wxPoint to test (in internal units).
Returns
true if a hit, else false.

Definition at line 90 of file marker_base.cpp.

91 {
93  bbox.Inflate( aAccuracy );
94 
95  // Fast hit test using boundary box. A finer test will be made if requested
96  bool hit = bbox.Contains( aHitPosition );
97 
98  if( hit ) // Fine test
99  {
100  SHAPE_LINE_CHAIN polygon;
101  ShapeToPolygon( polygon );
102  VECTOR2I rel_pos( aHitPosition - m_Pos );
103  hit = polygon.PointInside( rel_pos, aAccuracy );
104  }
105 
106  return hit;
107 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:123
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
EDA_RECT GetBoundingBoxMarker() const
Return the orthogonal, bounding box of this object for display purposes.
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const
Check if point aP lies inside a polygon (any type) defined by the line chain.
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
Represent a polyline (an zero-thickness chain of connected line segments).
Handle the component boundary box.
Definition: eda_rect.h:42
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References EDA_RECT::Contains(), GetBoundingBoxMarker(), EDA_RECT::Inflate(), m_Pos, SHAPE_LINE_CHAIN_BASE::PointInside(), and ShapeToPolygon().

Referenced by PCB_MARKER::HitTest(), and SCH_MARKER::HitTest().

◆ IsExcluded()

◆ MarkerScale()

int MARKER_BASE::MarkerScale ( ) const
inline

The scaling factor to convert polygonal shape coordinates to internal units.

Definition at line 66 of file marker_base.h.

66 { return m_scalingFactor; }
int m_scalingFactor
Definition: marker_base.h:130

References m_scalingFactor.

Referenced by KIGFX::PCB_PAINTER::draw(), PCB_MARKER::GetBoundingBox(), PrintMarker(), and ShapeToPolygon().

◆ PrintMarker()

void MARKER_BASE::PrintMarker ( const RENDER_SETTINGS aSettings,
const wxPoint &  aOffset 
)

Print the shape is the polygon defined in m_Corners (array of wxPoints).

Definition at line 137 of file marker_base.cpp.

138 {
139  wxDC* DC = aSettings->GetPrintDC();
140 
141  // Build the marker shape polygon in internal units:
142  std::vector<wxPoint> shape;
143  shape.reserve( CORNERS_COUNT );
144 
145  for( const VECTOR2I& corner : MarkerShapeCorners )
146  shape.emplace_back( corner * MarkerScale() + m_Pos + aOffset );
147 
148  GRClosedPoly( nullptr, DC, CORNERS_COUNT, &shape[0], true, 0, getColor(), getColor() );
149 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:123
virtual KIGFX::COLOR4D getColor() const =0
const unsigned CORNERS_COUNT
Definition: marker_base.cpp:58
wxDC * GetPrintDC() const
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:66
static const VECTOR2I MarkerShapeCorners[]
Definition: marker_base.cpp:46
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, COLOR4D Color, COLOR4D BgColor)
Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around ...
Definition: gr_basic.cpp:553

References CORNERS_COUNT, getColor(), KIGFX::RENDER_SETTINGS::GetPrintDC(), GRClosedPoly(), m_Pos, MarkerScale(), and MarkerShapeCorners.

Referenced by SCH_MARKER::Print().

◆ SetExcluded()

◆ SetMarkerType()

void MARKER_BASE::SetMarkerType ( enum TYPEMARKER  aMarkerType)
inline

Accessors to set/get marker type (DRC, ERC, or other)

Definition at line 91 of file marker_base.h.

91 { m_markerType = aMarkerType; }
TYPEMARKER m_markerType
Definition: marker_base.h:126

References m_markerType.

◆ ShapeToPolygon()

void MARKER_BASE::ShapeToPolygon ( SHAPE_LINE_CHAIN aPolygon,
int  aScale = -1 
) const

Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the marker position (are not absolute).

Parameters
aPolygonis the SHAPE_LINE_CHAIN to fill with the shape.

Definition at line 110 of file marker_base.cpp.

111 {
112  if( aScale < 0 )
113  aScale = MarkerScale();
114 
115  for( const VECTOR2I& corner : MarkerShapeCorners )
116  aPolygon.Append( corner * aScale );
117 
118  // Be sure aPolygon is seen as a closed polyline:
119  aPolygon.SetClosed( true );
120 }
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:66
static const VECTOR2I MarkerShapeCorners[]
Definition: marker_base.cpp:46

References SHAPE_LINE_CHAIN::Append(), MarkerScale(), MarkerShapeCorners, and SHAPE_LINE_CHAIN::SetClosed().

Referenced by KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), FOOTPRINT::GetCoverageArea(), PCB_SELECTION_TOOL::hitTestDistance(), and HitTestMarker().

Member Data Documentation

◆ m_excluded

bool MARKER_BASE::m_excluded
protected

Definition at line 127 of file marker_base.h.

Referenced by IsExcluded(), and SetExcluded().

◆ m_markerType

TYPEMARKER MARKER_BASE::m_markerType
protected

Definition at line 126 of file marker_base.h.

Referenced by GetMarkerType(), and SetMarkerType().

◆ m_Pos

◆ m_rcItem

◆ m_scalingFactor

int MARKER_BASE::m_scalingFactor
protected

Definition at line 130 of file marker_base.h.

Referenced by GetBoundingBoxMarker(), and MarkerScale().

◆ m_shapeBoundingBox

EDA_RECT MARKER_BASE::m_shapeBoundingBox
protected

Definition at line 132 of file marker_base.h.

Referenced by PCB_MARKER::GetBoundingBox(), GetBoundingBoxMarker(), and MARKER_BASE().


The documentation for this class was generated from the following files: