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, 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)
 
RC_ITEMGetRCItem ()
 Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used. More...
 
const RC_ITEMGetRCItem () const
 
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
 
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,
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:63
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
TYPEMARKER m_markerType
Definition: marker_base.h:62
RC_ITEM * m_rcItem
Definition: marker_base.h:64
const unsigned CORNERS_COUNT
Definition: marker_base.cpp:59
void SetEnd(int x, int y)
Definition: eda_rect.h:192
EDA_RECT m_shapeBoundingBox
Definition: marker_base.h:68
int m_scalingFactor
Definition: marker_base.h:66
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  delete m_rcItem;
89 }
RC_ITEM * m_rcItem
Definition: marker_base.h:64

References m_rcItem.

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

123 {
124  wxSize size_iu = m_shapeBoundingBox.GetSize();
125  wxPoint position_iu = m_shapeBoundingBox.GetPosition();
126  size_iu.x *= m_scalingFactor;
127  size_iu.y *= m_scalingFactor;
128  position_iu.x *= m_scalingFactor;
129  position_iu.y *= m_scalingFactor;
130  position_iu += m_Pos;
131 
132  return EDA_RECT( position_iu, size_iu );
133 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:59
EDA_RECT m_shapeBoundingBox
Definition: marker_base.h:68
const wxPoint GetPosition() const
Definition: eda_rect.h:115
int m_scalingFactor
Definition: marker_base.h:66
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 98 of file marker_base.h.

98 { return m_Pos; }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:59

References m_Pos.

◆ GetRCItem() [1/2]

◆ GetRCItem() [2/2]

const RC_ITEM* MARKER_BASE::GetRCItem ( ) const
inline

Definition at line 118 of file marker_base.h.

118 { return m_rcItem; }
RC_ITEM * m_rcItem
Definition: marker_base.h:64

References m_rcItem.

◆ GetUUID()

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

Implemented in MARKER_PCB, and SCH_MARKER.

Referenced by RC_TREE_MODEL::ToUUID().

◆ 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 92 of file marker_base.cpp.

93 {
95  bbox.Inflate( aAccuracy );
96 
97  // Fast hit test using boundary box. A finer test will be made if requested
98  bool hit = bbox.Contains( aHitPosition );
99 
100  if( hit ) // Fine test
101  {
102  SHAPE_LINE_CHAIN polygon;
103  ShapeToPolygon( polygon );
104  VECTOR2I rel_pos( aHitPosition - m_Pos );
105  hit = polygon.PointInside( rel_pos, aAccuracy );
106  }
107 
108  return hit;
109 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:59
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...
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
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const
Function PointInside()
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::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 80 of file marker_base.h.

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

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

137 {
138  wxDC* DC = aSettings->GetPrintDC();
139 
140  // Build the marker shape polygon in internal units:
141  std::vector<wxPoint> shape;
142  shape.reserve( CORNERS_COUNT );
143 
144  for( const VECTOR2I& corner : MarkerShapeCorners )
145  shape.emplace_back( corner * MarkerScale() + m_Pos + aOffset );
146 
147  GRClosedPoly( nullptr, DC, CORNERS_COUNT, &shape[0], true, 0, getColor(), getColor() );
148 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:59
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:80
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:552

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 109 of file marker_base.h.

109 { m_excluded = aExcluded; }
bool m_excluded
Definition: marker_base.h:63

References m_excluded.

Referenced by DIALOG_DRC::OnDRCItemRClick(), DIALOG_ERC::OnERCItemRClick(), 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 105 of file marker_base.h.

105 { m_markerType = aMarkerType; }
TYPEMARKER m_markerType
Definition: marker_base.h:62

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

113 {
114  for( const VECTOR2I& corner : MarkerShapeCorners )
115  aPolygon.Append( corner * MarkerScale() );
116 
117  // Be sure aPolygon is seen as a closed polyline:
118  aPolygon.SetClosed( true );
119 }
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:80
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 63 of file marker_base.h.

Referenced by IsExcluded(), and SetExcluded().

◆ m_markerType

TYPEMARKER MARKER_BASE::m_markerType
protected

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

Referenced by GetBoundingBoxMarker(), and MarkerScale().

◆ m_shapeBoundingBox

EDA_RECT MARKER_BASE::m_shapeBoundingBox
protected

Definition at line 68 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: