56 return new TRACK( *
this );
62 return new ARC( *
this );
80 return new VIA( *
this );
92 default: formatStr =
_(
"Via %s on %s" );
break;
137 *aSource = constraint.
GetName();
147 *aSource =
_(
"removed annular ring" );
164 *aSource = constraint.
GetName();
207 if( min_dist >=
KiROUND( dist ) )
212 if( min_dist >=
KiROUND( dist ) )
223 int radius = (
m_Width + 1 ) / 2;
224 int ymax, xmax, ymin, xmin;
237 auto bbox = arc->BBox();
239 xmin = bbox.GetLeft();
240 xmax = bbox.GetRight();
241 ymin = bbox.GetTop();
242 ymax = bbox.GetBottom();
260 EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
286 m_End.x = aCentre.x - (
m_End.x - aCentre.x );
291 m_End.y = aCentre.y - (
m_End.y - aCentre.y );
299 void ARC::Flip(
const wxPoint& aCentre,
bool aFlipLeftRight )
304 m_End.x = aCentre.x - (
m_End.x - aCentre.x );
305 m_Mid.x = aCentre.x - (
m_Mid.x - aCentre.x );
310 m_End.y = aCentre.y - (
m_End.y - aCentre.y );
311 m_Mid.y = aCentre.y - (
m_Mid.y - aCentre.y );
319 void VIA::Flip(
const wxPoint& aCentre,
bool aFlipLeftRight )
324 m_End.x = aCentre.x - (
m_End.x - aCentre.x );
329 m_End.y = aCentre.y - (
m_End.y - aCentre.y );
338 top_layer =
FlipLayer( top_layer, copperLayerCount );
339 bottom_layer =
FlipLayer( bottom_layer, copperLayerCount );
351 if( stype ==
Type() )
367 wxASSERT( top_layer <= bottom_layer );
369 if( top_layer <= layer_number && layer_number <= bottom_layer )
445 if( b_layer < t_layer )
446 std::swap( b_layer, t_layer );
450 *top_layer = t_layer;
453 *bottom_layer = b_layer;
484 for(
auto layer : aLayers.
Seq() )
496 std::vector<KICAD_T> types
508 if( !
IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ) )
517 return board->
GetConnectivity()->IsConnectedOnLayer(
this, static_cast<int>( aLayer ),
533 constexpr
double HIDE = std::numeric_limits<double>::max();
544 if( renderSettings->GetHighContrast() )
546 if(
m_layer != renderSettings->GetPrimaryHighContrastLayer() )
593 constexpr
double HIDE = (double)std::numeric_limits<double>::max();
620 if( renderSettings->GetHighContrast() )
623 if( !
FlashLayer( renderSettings->GetPrimaryHighContrastLayer() ) )
649 aList.emplace_back(
_(
"Type" ),
_(
"Track" ) );
664 std::tie( count, trackLen, lenPadToDie ) = board->
GetTrackLength( *
this );
668 if( lenPadToDie != 0 )
671 aList.emplace_back(
_(
"Pad To Die Length" ), msg );
674 aList.emplace_back(
_(
"Full Length" ), msg );
685 int minWidth, maxWidth;
704 default: msg =
_(
"Via" );
break;
707 aList.emplace_back(
_(
"Type" ), msg );
715 aList.emplace_back(
_(
"Diameter" ), msg );
719 aList.emplace_back(
_(
"Drill" ), msg );
744 #if 0 // Enable for debugging 749 aList.emplace_back(
_(
"NetCode" ), msg );
753 msg.Printf( wxT(
"0x%08X" ),
m_flags );
754 aList.emplace_back( wxT(
"Flags" ), msg );
759 msg.Printf( wxT(
"%d %d" ),
m_End.x,
m_End.y );
764 aList.emplace_back(
_(
"Status" ),
IsLocked() ?
_(
"Locked" ) : wxT(
"" ) );
788 int max_dist = aAccuracy + (
m_Width / 2 );
798 wxPoint relpos = aPosition - center;
802 if( std::abs( dist - radius ) > max_dist )
806 double arc_hittest =
ArcTangente( relpos.y, relpos.x );
809 arc_hittest -= arc_angle_start;
816 return arc_hittest >= 3600 + arc_angle;
818 return arc_hittest <= arc_angle;
824 int max_dist = aAccuracy + (
m_Width / 2 );
827 wxPoint rel_pos = aPosition -
m_Start;
828 double dist = (double) rel_pos.x * rel_pos.x + (
double) rel_pos.y * rel_pos.y;
829 return dist <= (double) max_dist * max_dist;
898 std::swap( *((
TRACK*)
this), *((
TRACK*) aImage) );
905 std::swap( *
this, *static_cast<ARC*>( aImage ) );
912 std::swap( *((
VIA*)
this), *((
VIA*) aImage) );
919 return wxPoint( center.x, center.y );
932 wxPoint p1 =
m_Mid - center;
933 wxPoint p2 =
m_End - center;
954 m_End.x - center.x );
985 if( FlashLayer( aLayer ) )
988 return std::make_shared<SHAPE_CIRCLE>(
m_Start, GetDrillValue() / 2 );
1001 wxString TRACK::ShowState(
int stateBits )
1006 ret << wxT(
" | IS_LINKED" );
1009 ret << wxT(
" | LOCKED" );
1012 ret << wxT(
" | IN_EDIT" );
1015 ret << wxT(
" | IS_DRAGGED" );
1018 ret << wxT(
" | DO_NOT_DRAW" );
1021 ret << wxT(
" | IS_DELETED" );
1024 ret << wxT(
" | END_ONPAD" );
1027 ret << wxT(
" | BEGIN_ONPAD" );
1047 if( layerEnum.
Choices().GetCount() == 0 )
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
bool IsViaPadLayer(LAYER_NUM aLayer)
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
void GetWidthConstraints(int *aMin, int *aMax, wxString *aSource) const
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
to draw blind/buried vias
static PROPERTY_MANAGER & Instance()
wxPoint m_Start
Line start point.
void GetMsgPanelInfoBase_Common(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) const
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
bool m_isFree
"Free" vias don't get their nets auto-updated
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
PNG memory record (file in memory).
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Implementation of conversion functions that require both schematic and board internal units.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
MINOPTMAX< int > & Value()
int GetBiggestClearanceValue()
static struct TRACK_VIA_DESC _TRACK_VIA_DESC
const wxPoint & GetStart() const
to draw via holes (pad holes do not use this layer)
ENUM_MAP & Undefined(T aValue)
int m_drill
for vias: via drill (- 1 for default value)
virtual NETCLASS * GetNetClass() const
Return the NETCLASS for this item.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
bool operator()(const TRACK *aFirst, const TRACK *aSecond) const
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
virtual wxPoint GetPosition() const override
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
static ENUM_MAP< T > & Instance()
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
virtual EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings Returns a bit-mask of all t...
class ARC, an arc track segment on a copper layer
bool IntersectsCircle(const wxPoint &aCenter, const int aRadius) const
Test for a common area between a circle and this rectangle.
void SetOrigin(const wxPoint &pos)
#define END_ONPAD
Pcbnew: flag set for track segment ending on a pad.
wxString GetNetname() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
class PAD, a pad in a footprint
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings Returns a bit-mask of all t...
const BITMAP_OPAQUE add_tracks_xpm[1]
void RotatePoint(int *pX, int *pY, double angle)
void NORMALIZE_ANGLE_POS(T &Angle)
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
The base class for create windows for drawing purpose.
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Contains methods for drawing PCB-specific items.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
bool Contains(const wxPoint &aPoint) const
const INSPECTOR_FUNC & INSPECTOR
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
class TRACK, a track segment (segment on a copper layer)
int m_Width
Thickness of track, or via diameter.
void SetWidth(int aWidth)
Classes used in Pcbnew, CvPcb and GerbView.
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
PCB specific render settings.
virtual wxString layerMaskDescribe() const
Return a string (to be shown to the user) describing a layer mask.
PCB_LAYER_ID
A quick note on layer IDs:
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Display value expressed in distance units (mm/inch)
BITMAP_DEF GetMenuImage() const override
Return a pointer to an image to be used in menus.
int GetMinAnnulus(PCB_LAYER_ID aLayer, wxString *aSource) const
LSET is a set of PCB_LAYER_IDs.
const wxPoint & GetMid() const
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
bool FlashLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
bool m_keepTopBottomLayer
Keep the top and bottom annular rings.
#define IN_EDIT
Item currently edited.
wxPoint m_End
Line end point.
to draw usual through hole vias
A collection of nets and the parameters used to route or test these nets.
virtual BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
#define DO_NOT_DRAW
Used to disable draw function.
static LSET AllLayersMask()
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_layer contains the top layer, the other layer is in m_bottomLayer.
class ZONE, a copper pour area
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
#define IS_DRAGGED
Item being dragged.
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
int GetPrintMode() const
Get the current print mode.
void SetDrillDefault()
Function SetDrillDefault sets the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
#define LOCKED
Pcbnew: locked from movement and deletion.
int LAYER_NUM
This can be replaced with int and removed.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
wxString GetNetnameMsg() const
Some functions to handle hotkeys in KiCad.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
#define BEGIN_ONPAD
Pcbnew: flag set for track segment starting on a pad.
#define STARTPOINT
When a line is selected, these flags indicate which.
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
wxString layerMaskDescribe() const override
Return a string (to be shown to the user) describing a layer mask.
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
virtual bool IsLocked() const
virtual void SetLayerSet(LSET aLayers) override
BITMAP_DEF GetMenuImage() const override
Return a pointer to an image to be used in menus.
Meta control for all vias opacity/visibility.
STATUS_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Information pertinent to a Pcbnew printed circuit board.
void SetTopLayer(PCB_LAYER_ID aLayer)
wxString UnescapeString(const wxString &aSource)
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
double GetArcAngleEnd() const
void AddProperty(PROPERTY_BASE *aProperty)
Register a property.
int GetCopperLayerCount() const
class ZONE, managed by a footprint
Handle the component boundary box.
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
bool IsHoleLayer(LAYER_NUM aLayer)
VIATYPE GetViaType() const
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
A base class for most all the KiCad significant classes used in schematics and boards.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
PCB_LAYER_ID TopLayer() const
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
const wxPoint & GetEnd() const
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
void SetBottomLayer(PCB_LAYER_ID aLayer)
virtual double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
void ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew)
Replace an existing property for a specific type.
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
#define ENDPOINT
ends. (Used to support dragging.)
Provide class metadata.Helper macro to map type hashes to names.
double GetArcAngleStart() const
class VIA, a via (like a track segment on a copper layer)
TRACK(BOARD_ITEM *aParent, KICAD_T idtype=PCB_TRACE_T)
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
double ArcTangente(int dy, int dx)
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
const VECTOR2I GetArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
ENUM_MAP & Map(T aValue, const wxString &aName)
void SanitizeLayers()
Function SanitizeLayers Check so that the layers are correct dependin on the type of via,...
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
std::tuple< int, double, double > GetTrackLength(const TRACK &aTrack) const
Returns data on the length and number of track segments connected to a given track.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
void SetViaType(VIATYPE aViaType)
static constexpr int Millimeter2iu(double mm)
PCB_LAYER_ID BottomLayer() const
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
const BITMAP_OPAQUE via_xpm[1]
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
wxPoint m_Mid
Arc mid point, halfway between start and end.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
PCB_LAYER_ID m_bottomLayer
The bottom layer of the via (the top layer is in m_layer)
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
bool m_removeUnconnectedLayer
Remove unconnected copper on a via.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
KICAD_T Type() const
Returns the type of object.
Container for design settings for a BOARD object.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
int GetLocalClearance(wxString *aSource) const override
Function GetLocalClearance returns any local clearance overrides set in the "classic" (ie: pre-rule) ...