KiCad PCB EDA Suite
MARKER_BASE Class Referenceabstract

#include <marker_base.h>

Inheritance diagram for MARKER_BASE:
MARKER_PCB 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) const
 Returns 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 (RENDER_SETTINGS *aSettings, const wxPoint &aOffset)
 Function PrintMarker Prints the shape is the polygon defined in m_Corners (array of wxPoints). More...
 
const wxPointGetPos () const
 Function GetPos. More...
 
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
 Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used. More...
 
bool HitTestMarker (const wxPoint &aHitPosition, int aAccuracy) const
 Tests if the given wxPoint is within the bounds of this object. More...
 
EDA_RECT GetBoundingBoxMarker () const
 Function GetBoundingBoxMarker returns 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 51 of file marker_base.h.

Member Enumeration Documentation

◆ TYPEMARKER

Enumerator
MARKER_UNSPEC 
MARKER_ERC 
MARKER_PCB 
MARKER_SIMUL 

Definition at line 54 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 62 of file marker_base.cpp.

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

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

◆ ~MARKER_BASE()

MARKER_BASE::~MARKER_BASE ( )
virtual

Definition at line 86 of file marker_base.cpp.

87 {
88 }

Member Function Documentation

◆ GetBoundingBoxMarker()

EDA_RECT MARKER_BASE::GetBoundingBoxMarker ( ) const

Function GetBoundingBoxMarker returns 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 121 of file marker_base.cpp.

122 {
123  wxSize size_iu = m_shapeBoundingBox.GetSize();
124  wxPoint position_iu = m_shapeBoundingBox.GetPosition();
125  size_iu.x *= m_scalingFactor;
126  size_iu.y *= m_scalingFactor;
127  position_iu.x *= m_scalingFactor;
128  position_iu.y *= m_scalingFactor;
129  position_iu += m_Pos;
130 
131  return EDA_RECT( position_iu, size_iu );
132 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:61
EDA_RECT m_shapeBoundingBox
Definition: marker_base.h:70
const wxPoint GetPosition() const
Definition: eda_rect.h:115
int m_scalingFactor
Definition: marker_base.h:68
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxSize GetSize() const
Definition: eda_rect.h:103

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

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

◆ getColor()

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

Implemented in SCH_MARKER, and MARKER_PCB.

Referenced by PrintMarker().

◆ GetMarkerType()

enum TYPEMARKER MARKER_BASE::GetMarkerType ( ) const
inline

◆ GetPos()

const wxPoint& MARKER_BASE::GetPos ( ) const
inline

Function GetPos.

Returns
the position of this MARKER in internal units.

Definition at line 99 of file marker_base.h.

99 { return m_Pos; }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:61

References m_Pos.

◆ GetRCItem()

std::shared_ptr<RC_ITEM> MARKER_BASE::GetRCItem ( ) const
inline

◆ GetUUID()

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

Implemented in MARKER_PCB, and SCH_MARKER.

◆ HitTestMarker()

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

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

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

Definition at line 91 of file marker_base.cpp.

92 {
94  bbox.Inflate( aAccuracy );
95 
96  // Fast hit test using boundary box. A finer test will be made if requested
97  bool hit = bbox.Contains( aHitPosition );
98 
99  if( hit ) // Fine test
100  {
101  SHAPE_LINE_CHAIN polygon;
102  ShapeToPolygon( polygon );
103  VECTOR2I rel_pos( aHitPosition - m_Pos );
104  hit = polygon.PointInside( rel_pos, aAccuracy );
105  }
106 
107  return hit;
108 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:61
bool Contains(const wxPoint &aPoint) const
Function Contains.
EDA_RECT GetBoundingBoxMarker() const
Function GetBoundingBoxMarker returns the orthogonal, bounding box of this object for display purpose...
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const
Function PointInside()
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon) const
Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to th...
SHAPE_LINE_CHAIN.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.

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

Referenced by MARKER_PCB::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 81 of file marker_base.h.

81 { return m_scalingFactor; }
int m_scalingFactor
Definition: marker_base.h:68

References m_scalingFactor.

Referenced by MARKER_PCB::GetBoundingBox(), PrintMarker(), and ShapeToPolygon().

◆ PrintMarker()

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

Function PrintMarker Prints the shape is the polygon defined in m_Corners (array of wxPoints).

Definition at line 135 of file marker_base.cpp.

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

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

Referenced by SCH_MARKER::Print().

◆ SetExcluded()

void MARKER_BASE::SetExcluded ( bool  aExcluded)
inline

Definition at line 110 of file marker_base.h.

110 { m_excluded = aExcluded; }
bool m_excluded
Definition: marker_base.h:65

References m_excluded.

Referenced by DIALOG_DRC::OnDRCItemRClick(), and PCB_EDIT_FRAME::ResolveDRCExclusions().

◆ SetMarkerType()

void MARKER_BASE::SetMarkerType ( enum TYPEMARKER  aMarkerType)
inline

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

Definition at line 106 of file marker_base.h.

106 { m_markerType = aMarkerType; }
TYPEMARKER m_markerType
Definition: marker_base.h:64

References m_markerType.

◆ ShapeToPolygon()

void MARKER_BASE::ShapeToPolygon ( SHAPE_LINE_CHAIN aPolygon) const

Returns 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 111 of file marker_base.cpp.

112 {
113  for( const VECTOR2I& corner : MarkerShapeCorners )
114  aPolygon.Append( corner * MarkerScale() );
115 
116  // Be sure aPolygon is seen as a closed polyline:
117  aPolygon.SetClosed( true );
118 }
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetClosed(bool aClosed)
Function SetClosed()
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:81
static const VECTOR2I MarkerShapeCorners[]
Definition: marker_base.cpp:47

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

Referenced by KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), and HitTestMarker().

Member Data Documentation

◆ m_excluded

bool MARKER_BASE::m_excluded
protected

Definition at line 65 of file marker_base.h.

Referenced by IsExcluded(), and SetExcluded().

◆ m_markerType

TYPEMARKER MARKER_BASE::m_markerType
protected

Definition at line 64 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 68 of file marker_base.h.

Referenced by GetBoundingBoxMarker(), and MarkerScale().

◆ m_shapeBoundingBox

EDA_RECT MARKER_BASE::m_shapeBoundingBox
protected

Definition at line 70 of file marker_base.h.

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


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