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 (wxDC *aDC, 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
 
void SetData (EDA_UNITS aUnits, int aErrorCode, const wxPoint &aMarkerPos, EDA_ITEM *aItem, const wxPoint &aPos, EDA_ITEM *bItem=nullptr, const wxPoint &bPos=wxPoint())
 Function SetData fills in all the reportable data associated with a MARKER. More...
 
void SetData (int aErrorCode, const wxPoint &aMarkerPos, const wxString &aText, const wxPoint &aPos, const wxString &bText=wxEmptyString, const wxPoint &bPos=wxPoint())
 Function SetData fills in all the reportable data associated with a MARKER. More...
 
void SetData (EDA_UNITS aUnits, int aErrorCode, const wxPoint &aMarkerPos, EDA_ITEM *aItem, EDA_ITEM *bItem=nullptr)
 Function SetData fills in all the reportable data associated with a MARKER. More...
 
void SetData (int aErrorCode, const wxPoint &aMarkerPos, const wxString &aText, const wxString &bText=wxEmptyString)
 Function SetData fills in all the reportable data associated with a MARKER. More...
 
void SetData (int aErrorCode, const wxPoint &aMarkerPos, const wxString &aText, const KIID &aID, const wxString &bText=wxEmptyString, const KIID &bID=niluuid)
 
void SetAuxiliaryData (const wxString &aAuxiliaryText, const wxPoint &aAuxiliaryPos)
 Function SetAuxiliaryData initialize data for the second (auxiliary) item. More...
 
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 41 of file marker_base.h.

Member Enumeration Documentation

◆ TYPEMARKER

Enumerator
MARKER_UNSPEC 
MARKER_ERC 
MARKER_PCB 
MARKER_SIMUL 

Definition at line 44 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( int 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:55
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
TYPEMARKER m_markerType
Definition: marker_base.h:54
RC_ITEM * m_rcItem
Definition: marker_base.h:56
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:60
int m_scalingFactor
Definition: marker_base.h:58
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 171 of file marker_base.cpp.

172 {
173  wxSize size_iu = m_shapeBoundingBox.GetSize();
174  wxPoint position_iu = m_shapeBoundingBox.GetPosition();
175  size_iu.x *= m_scalingFactor;
176  size_iu.y *= m_scalingFactor;
177  position_iu.x *= m_scalingFactor;
178  position_iu.y *= m_scalingFactor;
179  position_iu += m_Pos;
180 
181  return EDA_RECT( position_iu, size_iu );
182 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51
EDA_RECT m_shapeBoundingBox
Definition: marker_base.h:60
const wxPoint GetPosition() const
Definition: eda_rect.h:115
int m_scalingFactor
Definition: marker_base.h:58
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 MARKER_PCB, and SCH_MARKER.

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

90 { return m_Pos; }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51

References m_Pos.

◆ GetRCItem() [1/2]

RC_ITEM* MARKER_BASE::GetRCItem ( )
inline

◆ GetRCItem() [2/2]

const RC_ITEM* MARKER_BASE::GetRCItem ( ) const
inline

Definition at line 182 of file marker_base.h.

182 { return m_rcItem; }
RC_ITEM * m_rcItem
Definition: marker_base.h:56

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

142 {
144  bbox.Inflate( aAccuracy );
145 
146  // Fast hit test using boundary box. A finer test will be made if requested
147  bool hit = bbox.Contains( aHitPosition );
148 
149  if( hit ) // Fine test
150  {
151  SHAPE_LINE_CHAIN polygon;
152  ShapeToPolygon( polygon );
153  VECTOR2I rel_pos( aHitPosition - m_Pos );
154  hit = polygon.PointInside( rel_pos, aAccuracy );
155  }
156 
157  return hit;
158 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51
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 SCH_MARKER::HitTest(), and MARKER_PCB::HitTest().

◆ IsExcluded()

◆ MarkerScale()

int MARKER_BASE::MarkerScale ( ) const
inline

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

Definition at line 72 of file marker_base.h.

72 { return m_scalingFactor; }
int m_scalingFactor
Definition: marker_base.h:58

References m_scalingFactor.

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

◆ PrintMarker()

void MARKER_BASE::PrintMarker ( wxDC *  aDC,
const wxPoint aOffset 
)

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

Definition at line 185 of file marker_base.cpp.

186 {
187  // Build the marker shape polygon in internal units:
188  std::vector<wxPoint> shape;
189  shape.reserve( CORNERS_COUNT );
190 
191  for( const VECTOR2I& corner : MarkerShapeCorners )
192  shape.emplace_back( corner * MarkerScale() + m_Pos + aOffset );
193 
194  GRClosedPoly( nullptr, aDC, CORNERS_COUNT, &shape[0], true, 0, getColor(), getColor() );
195 }
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51
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:72
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(), GRClosedPoly(), m_Pos, MarkerScale(), and MarkerShapeCorners.

Referenced by SCH_MARKER::Print(), and MARKER_PCB::Print().

◆ SetAuxiliaryData()

void MARKER_BASE::SetAuxiliaryData ( const wxString &  aAuxiliaryText,
const wxPoint aAuxiliaryPos 
)
inline

Function SetAuxiliaryData initialize data for the second (auxiliary) item.

Parameters
aAuxiliaryText= the second text (main text) concerning the second schematic or board item
aAuxiliaryPos= position the second item

Definition at line 167 of file marker_base.h.

168  {
169  m_rcItem->SetAuxiliaryData( aAuxiliaryText, aAuxiliaryPos );
170  }
RC_ITEM * m_rcItem
Definition: marker_base.h:56
void SetAuxiliaryData(const wxString &aAuxiliaryText, const wxPoint &aAuxiliaryPos)
Function SetAuxiliaryData initialize data for the second (auxiliary) item.
Definition: rc_item.h:247

References m_rcItem, and RC_ITEM::SetAuxiliaryData().

◆ SetData() [1/5]

void MARKER_BASE::SetData ( EDA_UNITS  aUnits,
int  aErrorCode,
const wxPoint aMarkerPos,
EDA_ITEM aItem,
const wxPoint aPos,
EDA_ITEM bItem = nullptr,
const wxPoint bPos = wxPoint() 
)

Function SetData fills in all the reportable data associated with a MARKER.

Parameters
aErrorCodeThe categorizing identifier for an error
aMarkerPosThe position of the MARKER on the BOARD
aItemThe first of two objects
aPosThe position of the first of two objects
bItemThe second of the two conflicting objects
bPosThe position of the second of two objects

Definition at line 91 of file marker_base.cpp.

94 {
95  m_Pos = aMarkerPos;
96  m_rcItem->SetData( aUnits, aErrorCode, aItem, aPos, bItem, bPos );
97  m_rcItem->SetParent( this );
98 }
void SetData(EDA_UNITS aUnits, int aErrorCode, EDA_ITEM *aMainItem, EDA_ITEM *bAuxItem=nullptr)
Function SetData initialize all data in item.
Definition: rc_item.h:128
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51
void SetParent(MARKER_BASE *aMarker)
Definition: rc_item.h:255
RC_ITEM * m_rcItem
Definition: marker_base.h:56

References m_Pos, m_rcItem, RC_ITEM::SetData(), and RC_ITEM::SetParent().

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), Diagnose(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::ercCheckNoConnects(), MARKER_PCB::MARKER_PCB(), SimilarLabelsDiagnose(), TestConflictingBusAliases(), TestDuplicateSheetNames(), DIALOG_ERC::TestErc(), and TestMultiunitFootprints().

◆ SetData() [2/5]

void MARKER_BASE::SetData ( int  aErrorCode,
const wxPoint aMarkerPos,
const wxString &  aText,
const wxPoint aPos,
const wxString &  bText = wxEmptyString,
const wxPoint bPos = wxPoint() 
)

Function SetData fills in all the reportable data associated with a MARKER.

Parameters
aErrorCodeThe categorizing identifier for an error
aMarkerPosThe position of the MARKER on the BOARD
aTextText describing the first of two objects
aPosThe position of the first of two objects
bTextText describing the second of the two conflicting objects
bPosThe position of the second of two objects

Definition at line 101 of file marker_base.cpp.

104 {
105  m_Pos = aMarkerPos;
106  m_rcItem->SetData( aErrorCode, aText, aPos, bText, bPos );
107  m_rcItem->SetParent( this );
108 }
void SetData(EDA_UNITS aUnits, int aErrorCode, EDA_ITEM *aMainItem, EDA_ITEM *bAuxItem=nullptr)
Function SetData initialize all data in item.
Definition: rc_item.h:128
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51
void SetParent(MARKER_BASE *aMarker)
Definition: rc_item.h:255
RC_ITEM * m_rcItem
Definition: marker_base.h:56

References m_Pos, m_rcItem, RC_ITEM::SetData(), and RC_ITEM::SetParent().

◆ SetData() [3/5]

void MARKER_BASE::SetData ( EDA_UNITS  aUnits,
int  aErrorCode,
const wxPoint aMarkerPos,
EDA_ITEM aItem,
EDA_ITEM bItem = nullptr 
)

Function SetData fills in all the reportable data associated with a MARKER.

Parameters
aErrorCodeThe categorizing identifier for an error
aMarkerPosThe position of the MARKER on the BOARD
aItemThe first of two objects
aPosThe position of the first of two objects
bItemThe second of the two conflicting objects
bPosThe position of the second of two objects

Definition at line 111 of file marker_base.cpp.

114 {
115  m_Pos = aMarkerPos;
116  m_rcItem->SetData( aUnits, aErrorCode, aItem, bItem );
117  m_rcItem->SetParent( this );
118 }
void SetData(EDA_UNITS aUnits, int aErrorCode, EDA_ITEM *aMainItem, EDA_ITEM *bAuxItem=nullptr)
Function SetData initialize all data in item.
Definition: rc_item.h:128
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51
void SetParent(MARKER_BASE *aMarker)
Definition: rc_item.h:255
RC_ITEM * m_rcItem
Definition: marker_base.h:56

References m_Pos, m_rcItem, RC_ITEM::SetData(), and RC_ITEM::SetParent().

◆ SetData() [4/5]

void MARKER_BASE::SetData ( int  aErrorCode,
const wxPoint aMarkerPos,
const wxString &  aText,
const wxString &  bText = wxEmptyString 
)

Function SetData fills in all the reportable data associated with a MARKER.

Parameters
aErrorCodeThe categorizing identifier for an error
aMarkerPosThe position of the MARKER on the BOARD
aTextText describing the first of two objects
aPosThe position of the first of two objects
bTextText describing the second of the two conflicting objects
bPosThe position of the second of two objects

Definition at line 121 of file marker_base.cpp.

124 {
125  m_Pos = aMarkerPos;
126  m_rcItem->SetData( aErrorCode, aText, bText );
127  m_rcItem->SetParent( this );
128 }
void SetData(EDA_UNITS aUnits, int aErrorCode, EDA_ITEM *aMainItem, EDA_ITEM *bAuxItem=nullptr)
Function SetData initialize all data in item.
Definition: rc_item.h:128
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51
void SetParent(MARKER_BASE *aMarker)
Definition: rc_item.h:255
RC_ITEM * m_rcItem
Definition: marker_base.h:56

References m_Pos, m_rcItem, RC_ITEM::SetData(), and RC_ITEM::SetParent().

◆ SetData() [5/5]

void MARKER_BASE::SetData ( int  aErrorCode,
const wxPoint aMarkerPos,
const wxString &  aText,
const KIID aID,
const wxString &  bText = wxEmptyString,
const KIID bID = niluuid 
)

Definition at line 131 of file marker_base.cpp.

134 {
135  m_Pos = aMarkerPos;
136  m_rcItem->SetData( aErrorCode, aText, aID, bText, bID );
137  m_rcItem->SetParent( this );
138 }
void SetData(EDA_UNITS aUnits, int aErrorCode, EDA_ITEM *aMainItem, EDA_ITEM *bAuxItem=nullptr)
Function SetData initialize all data in item.
Definition: rc_item.h:128
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51
void SetParent(MARKER_BASE *aMarker)
Definition: rc_item.h:255
RC_ITEM * m_rcItem
Definition: marker_base.h:56

References m_Pos, m_rcItem, RC_ITEM::SetData(), and RC_ITEM::SetParent().

◆ SetExcluded()

void MARKER_BASE::SetExcluded ( bool  aExcluded)
inline

Definition at line 173 of file marker_base.h.

173 { m_excluded = aExcluded; }
bool m_excluded
Definition: marker_base.h:55

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

97 { m_markerType = aMarkerType; }
TYPEMARKER m_markerType
Definition: marker_base.h:54

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

162 {
163  for( const VECTOR2I& corner : MarkerShapeCorners )
164  aPolygon.Append( corner * MarkerScale() );
165 
166  // Be sure aPolygon is seen as a closed polyline:
167  aPolygon.SetClosed( true );
168 }
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:72
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 55 of file marker_base.h.

Referenced by IsExcluded(), and SetExcluded().

◆ m_markerType

TYPEMARKER MARKER_BASE::m_markerType
protected

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

Referenced by GetBoundingBoxMarker(), and MarkerScale().

◆ m_shapeBoundingBox

EDA_RECT MARKER_BASE::m_shapeBoundingBox
protected

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