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_DRC , MARKER_DRAWING_SHEET ,
  MARKER_RATSNEST , MARKER_PARITY , 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 SetMarkerScale (int aScale)
 
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 VECTOR2I &aOffset)
 Print the shape is the polygon defined in m_Corners (array of VECTOR2Is). More...
 
const VECTOR2IGetPos () 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)
 
virtual SEVERITY GetSeverity () const
 
std::shared_ptr< RC_ITEMGetRCItem () const
 
bool HitTestMarker (const VECTOR2I &aHitPosition, int aAccuracy) const
 Test if the given VECTOR2I is within the bounds of this object. More...
 
BOX2I GetBoundingBoxMarker () const
 Return the orthogonal, bounding box of this object for display purposes. More...
 

Public Attributes

VECTOR2I 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
 
BOX2I m_shapeBoundingBox
 

Detailed Description

Definition at line 48 of file marker_base.h.

Member Enumeration Documentation

◆ TYPEMARKER

Enumerator
MARKER_UNSPEC 
MARKER_ERC 
MARKER_DRC 
MARKER_DRAWING_SHEET 
MARKER_RATSNEST 
MARKER_PARITY 
MARKER_SIMUL 

Definition at line 51 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 VECTOR2I start( point_shape->x, point_shape->y );
69 VECTOR2I 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}
void SetOrigin(const Vec &pos)
Definition: box2.h:202
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
int m_scalingFactor
Definition: marker_base.h:135
TYPEMARKER m_markerType
Definition: marker_base.h:131
bool m_excluded
Definition: marker_base.h:132
std::shared_ptr< RC_ITEM > m_rcItem
Definition: marker_base.h:133
BOX2I m_shapeBoundingBox
Definition: marker_base.h:137
static const VECTOR2I MarkerShapeCorners[]
Definition: marker_base.cpp:46
const unsigned CORNERS_COUNT
Definition: marker_base.cpp:58

References CORNERS_COUNT, m_shapeBoundingBox, MarkerShapeCorners, BOX2< Vec >::SetEnd(), BOX2< Vec >::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()

BOX2I 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{
126
127 VECTOR2I pos = m_Pos;
129
130 return BOX2I( pos, bbox.GetSize() * m_scalingFactor );
131}
BOX2< VECTOR2I > BOX2I
Definition: box2.h:847
const Vec & GetPosition() const
Definition: box2.h:184
const Vec & GetSize() const
Definition: box2.h:179
VECTOR2I m_Pos
position of the marker
Definition: marker_base.h:128

References BOX2< Vec >::GetPosition(), BOX2< Vec >::GetSize(), m_Pos, m_scalingFactor, and m_shapeBoundingBox.

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

◆ getColor()

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

Implemented in SCH_MARKER, and PCB_MARKER.

Referenced by PrintMarker().

◆ GetMarkerType()

◆ GetPos()

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

Definition at line 87 of file marker_base.h.

87{ return m_Pos; }

References m_Pos.

Referenced by PCB_SELECTION_TOOL::hitTestDistance().

◆ GetRCItem()

◆ GetSeverity()

virtual SEVERITY MARKER_BASE::GetSeverity ( ) const
inlinevirtual

Reimplemented in SCH_MARKER, and PCB_MARKER.

Definition at line 100 of file marker_base.h.

100{ return RPT_SEVERITY_UNDEFINED; }
@ RPT_SEVERITY_UNDEFINED

References RPT_SEVERITY_UNDEFINED.

Referenced by RC_TREE_MODEL::DeleteItems().

◆ GetUUID()

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

Implemented in SCH_MARKER, and PCB_MARKER.

◆ HitTestMarker()

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

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

Parameters
aHitPositionis the VECTOR2I 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}
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
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...
BOX2I 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.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...

References BOX2< Vec >::Contains(), GetBoundingBoxMarker(), BOX2< Vec >::Inflate(), m_Pos, SHAPE_LINE_CHAIN_BASE::PointInside(), and ShapeToPolygon().

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

◆ IsExcluded()

◆ MarkerScale()

int MARKER_BASE::MarkerScale ( ) const
inline

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

Definition at line 68 of file marker_base.h.

68{ return m_scalingFactor; }

References m_scalingFactor.

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

◆ PrintMarker()

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

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

Definition at line 134 of file marker_base.cpp.

135{
136 wxDC* DC = aSettings->GetPrintDC();
137
138 // Build the marker shape polygon in internal units:
139 std::vector<VECTOR2I> shape;
140 shape.reserve( CORNERS_COUNT );
141
142 for( const VECTOR2I& corner : MarkerShapeCorners )
143 shape.emplace_back( corner * MarkerScale() + m_Pos + aOffset );
144
145 GRClosedPoly( DC, CORNERS_COUNT, &shape[0], true, getColor() );
146}
wxDC * GetPrintDC() const
virtual KIGFX::COLOR4D getColor() const =0
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:68
void GRClosedPoly(wxDC *DC, int n, const VECTOR2I *Points, bool Fill, const COLOR4D &Color)
Draw a closed polyline and fill it if Fill, in object space.
Definition: gr_basic.cpp:351

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

Referenced by SCH_MARKER::Print().

◆ SetExcluded()

◆ SetMarkerScale()

void MARKER_BASE::SetMarkerScale ( int  aScale)
inline

Definition at line 69 of file marker_base.h.

69{ m_scalingFactor = aScale; }

References m_scalingFactor.

Referenced by PCB_MARKER::SetZoom().

◆ SetMarkerType()

void MARKER_BASE::SetMarkerType ( enum TYPEMARKER  aMarkerType)
inline

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

Definition at line 94 of file marker_base.h.

94{ m_markerType = aMarkerType; }

References m_markerType.

Referenced by PCB_MARKER::PCB_MARKER().

◆ 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 SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.

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

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

Member Data Documentation

◆ m_excluded

bool MARKER_BASE::m_excluded
protected

Definition at line 132 of file marker_base.h.

Referenced by IsExcluded(), and SetExcluded().

◆ m_markerType

TYPEMARKER MARKER_BASE::m_markerType
protected

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

Referenced by GetBoundingBoxMarker(), MarkerScale(), and SetMarkerScale().

◆ m_shapeBoundingBox

BOX2I MARKER_BASE::m_shapeBoundingBox
protected

Definition at line 137 of file marker_base.h.

Referenced by GetBoundingBoxMarker(), and MARKER_BASE().


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