51#include <google/protobuf/any.pb.h>
55#include <api/board/board_types.pb.h>
77 *
this = *
static_cast<const PCB_TRACK*
>( aOther );
99 *
this = *
static_cast<const PCB_ARC*
>( aOther );
156 *
this = *
static_cast<const PCB_VIA*
>( aOther );
172 case VIATYPE::BLIND_BURIED: formatStr =
_(
"Blind/Buried Via %s on %s" );
break;
173 case VIATYPE::MICROVIA: formatStr =
_(
"Micro Via %s on %s" );
break;
174 default: formatStr =
_(
"Via %s on %s" );
break;
194 return *
this == other;
216 double similarity = 1.0;
247 return *
this == other;
258 return *
this == other;
281 double similarity = 1.0;
315 return *
this == other;
326 return *
this == other;
348 double similarity = 1.0;
375 wxASSERT_MSG(
false,
"Warning: PCB_VIA::SetWidth called without a layer argument" );
383 wxASSERT_MSG(
false,
"Warning: PCB_VIA::GetWidth called without a layer argument" );
402 kiapi::board::types::Track track;
405 track.mutable_start()->set_x_nm(
GetStart().x );
406 track.mutable_start()->set_y_nm(
GetStart().y );
407 track.mutable_end()->set_x_nm(
GetEnd().x );
408 track.mutable_end()->set_y_nm(
GetEnd().y );
409 track.mutable_width()->set_value_nm(
GetWidth() );
410 track.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>(
GetLayer() ) );
411 track.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
412 : kiapi::common::types::LockedState::LS_UNLOCKED );
413 track.mutable_net()->mutable_code()->set_value(
GetNetCode() );
414 track.mutable_net()->set_name(
GetNetname() );
417 aContainer.PackFrom( track );
423 kiapi::board::types::Track track;
425 if( !aContainer.UnpackTo( &track ) )
431 SetWidth( track.width().value_nm() );
432 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( track.layer() ) );
434 SetLocked( track.locked() == kiapi::common::types::LockedState::LS_LOCKED );
443 kiapi::board::types::Arc arc;
446 arc.mutable_start()->set_x_nm(
GetStart().x );
447 arc.mutable_start()->set_y_nm(
GetStart().y );
448 arc.mutable_mid()->set_x_nm(
GetMid().x );
449 arc.mutable_mid()->set_y_nm(
GetMid().y );
450 arc.mutable_end()->set_x_nm(
GetEnd().x );
451 arc.mutable_end()->set_y_nm(
GetEnd().y );
452 arc.mutable_width()->set_value_nm(
GetWidth() );
453 arc.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>(
GetLayer() ) );
454 arc.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
455 : kiapi::common::types::LockedState::LS_UNLOCKED );
456 arc.mutable_net()->mutable_code()->set_value(
GetNetCode() );
460 aContainer.PackFrom( arc );
466 kiapi::board::types::Arc arc;
468 if( !aContainer.UnpackTo( &arc ) )
476 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( arc.layer() ) );
478 SetLocked( arc.locked() == kiapi::common::types::LockedState::LS_LOCKED );
487 kiapi::board::types::Via
via;
495 google::protobuf::Any padStackWrapper;
497 padStackWrapper.UnpackTo(
via.mutable_pad_stack() );
500 via.mutable_pad_stack()->clear_layers();
503 via.set_type( ToProtoEnum<VIATYPE, kiapi::board::types::ViaType>(
GetViaType() ) );
504 via.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
505 : kiapi::common::types::LockedState::LS_UNLOCKED );
506 via.mutable_net()->mutable_code()->set_value(
GetNetCode() );
509 aContainer.PackFrom(
via );
515 kiapi::board::types::Via
via;
517 if( !aContainer.UnpackTo( &
via ) )
524 google::protobuf::Any padStackWrapper;
525 padStackWrapper.PackFrom(
via.pad_stack() );
535 SetLocked(
via.locked() == kiapi::common::types::LockedState::LS_LOCKED );
561 *aSource = constraint.
GetName();
563 return constraint.
Value();
579 *aSource = constraint.
GetName();
581 return constraint.
Value();
597 *aSource = constraint.
GetName();
599 return constraint.
Value();
608 *aSource =
_(
"removed annular ring" );
625 *aSource = constraint.
GetName();
668 if( min_dist >= dist )
673 if( min_dist >= dist )
685 int ymax, xmax, ymin, xmin;
698 BOX2I bbox = arc->BBox();
722 VECTOR2L( (int64_t) xmax - xmin + 1, (int64_t) ymax - ymin + 1 ) );
747 VECTOR2L( (int64_t) xmax - xmin + 1, (int64_t) ymax - ymin + 1 ) );
766 VECTOR2L( (int64_t) xmax - xmin + 1, (int64_t) ymax - ymin + 1 ) );
808 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
825 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
848 return start_end.
Cross( start_mid ) < 0;
854 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
878 const std::vector<KICAD_T>& aScanTypes )
880 for(
KICAD_T scanType : aScanTypes )
882 if( scanType ==
Type() )
884 if( INSPECT_RESULT::QUIT == inspector(
this, testData ) )
885 return INSPECT_RESULT::QUIT;
889 return INSPECT_RESULT::CONTINUE;
915 TENTING_MODE::TENTED : TENTING_MODE::NOT_TENTED;
918 return TENTING_MODE::FROM_RULES;
938 TENTING_MODE::TENTED : TENTING_MODE::NOT_TENTED;
941 return TENTING_MODE::FROM_RULES;
961 COVERING_MODE::COVERED : COVERING_MODE::NOT_COVERED;
964 return COVERING_MODE::FROM_RULES;
984 COVERING_MODE::COVERED : COVERING_MODE::NOT_COVERED;
987 return COVERING_MODE::FROM_RULES;
1007 PLUGGING_MODE::PLUGGED : PLUGGING_MODE::NOT_PLUGGED;
1010 return PLUGGING_MODE::FROM_RULES;
1030 PLUGGING_MODE::PLUGGED : PLUGGING_MODE::NOT_PLUGGED;
1033 return PLUGGING_MODE::FROM_RULES;
1053 CAPPING_MODE::CAPPED : CAPPING_MODE::NOT_CAPPED;
1056 return CAPPING_MODE::FROM_RULES;
1076 FILLING_MODE::FILLED : FILLING_MODE::NOT_FILLED;
1079 return FILLING_MODE::FROM_RULES;
1087 "Invalid layer passed to IsTented" );
1099 return front ? board->GetDesignSettings().m_TentViasFront
1100 : board->GetDesignSettings().m_TentViasBack;
1110 return board->GetDesignSettings().m_SolderMaskExpansion;
1131 margin = std::max( margin, -
m_width / 2 );
1171 else if( aLayer ==
B_Mask )
1183 int layer_id = aCopperLayerCount*2;
1187 if(
Padstack().Drill().start > layer_id )
1231 if( layermask.test(
F_Cu ) )
1233 else if( layermask.test(
B_Cu ) )
1260 layermask.
set(
id );
1291 bool top_found =
false;
1292 bool bottom_found =
false;
1302 if( !top_found && layer !=
B_Cu )
1313 bottom_found =
true;
1351 std::swap( b_layer, t_layer );
1355 *top_layer = t_layer;
1358 *bottom_layer = b_layer;
1446 return board->
GetConnectivity()->IsConnectedOnLayer(
this, layer, nonZoneTypes );
1486 bool connected =
false;
1513 std::vector<int> layers{
1519 layers.reserve( 6 );
1524 layers.push_back(
F_Mask );
1526 layers.push_back(
B_Mask );
1562 if(
VECTOR2I(
end - start ).SquaredEuclideanNorm() < nameSize * nameSize )
1569 if(
VECTOR2I(
end - start ).SquaredEuclideanNorm() == 0 )
1600 bbox.
Inflate( 2 * board->GetDesignSettings().GetBiggestClearanceValue() );
1620 bool isBlindBuried =
1622 || (
m_viaType == VIATYPE::MICROVIA && ( layerTop !=
F_Cu || layerBottom !=
B_Cu ) );
1627 cuMask = board->GetEnabledLayers();
1644 ret_layers.push_back(
F_Mask );
1647 ret_layers.push_back(
B_Mask );
1665 visible = board->GetVisibleLayers() & board->GetEnabledLayers();
1675 highContrastLayer =
F_Cu;
1677 highContrastLayer =
B_Cu;
1740 default:
return _(
"Track" );
1773 std::tie( count, trackLen, lenPadToDie ) = board->
GetTrackLength( *
this );
1777 if( lenPadToDie != 0 )
1780 aList.emplace_back(
_(
"Pad To Die Length" ), msg );
1783 aList.emplace_back(
_(
"Full Length" ), msg );
1789 aList.emplace_back(
_(
"Copper Area" ),
1795 aList.emplace_back( wxString::Format(
_(
"Min Clearance: %s" ),
1797 wxString::Format(
_(
"(from %s)" ), source ) );
1802 if( !msg.IsEmpty() )
1804 aList.emplace_back( wxString::Format(
_(
"Width Constraints: %s" ), msg ),
1805 wxString::Format(
_(
"(from %s)" ), source ) );
1816 case VIATYPE::MICROVIA: msg =
_(
"Micro Via" );
break;
1817 case VIATYPE::BLIND_BURIED: msg =
_(
"Blind/Buried Via" );
break;
1818 case VIATYPE::THROUGH: msg =
_(
"Through Via" );
break;
1819 default: msg =
_(
"Via" );
break;
1822 aList.emplace_back(
_(
"Type" ), msg );
1828 aList.emplace_back(
_(
"Diameter" ),
1835 aList.emplace_back( wxString::Format(
_(
"Min Clearance: %s" ),
1837 wxString::Format(
_(
"(from %s)" ), source ) );
1841 aList.emplace_back( wxString::Format(
_(
"Min Annular Width: %s" ),
1843 wxString::Format(
_(
"(from %s)" ), source ) );
1848 std::vector<MSG_PANEL_ITEM>& aList )
const
1852 aList.emplace_back(
_(
"Resolved Netclass" ),
1857 aList.emplace_back(
_(
"NetCode" ), fmt::format(
"{}",
GetNetCode() ) );
1859 aList.emplace_back( wxT(
"Flags" ), fmt::format(
"#08X",
m_flags ) );
1861 aList.emplace_back( wxT(
"Start pos" ), fmt::format(
"{} {}",
m_Start.
x,
m_Start.
y ) );
1862 aList.emplace_back( wxT(
"End pos" ), fmt::format(
"{} {}",
m_End.
x,
m_End.
y ) );
1866 aList.emplace_back(
_(
"Status" ),
_(
"Locked" ) );
1890 double max_dist = aAccuracy + (
GetWidth() / 2.0 );
1911 arc_hittest -= arc_angle_start;
1917 return arc_hittest >=
ANGLE_360 + arc_angle;
1919 return arc_hittest <= arc_angle;
1933 int max_dist = aAccuracy + (
GetWidth( aLayer ) / 2 );
1937 double dist = rel_pos.
x * rel_pos.x + rel_pos.y * rel_pos.y;
1939 if( dist <=
static_cast<double>( max_dist ) * max_dist )
1949 BOX2I arect = aRect;
1961 BOX2I arect = aRect;
1979 BOX2I arect = aRect;
2005 return wxString::Format(
Type() ==
PCB_ARC_T ?
_(
"Track (arc) %s on %s, length %s" )
2006 :
_(
"Track %s on %s, length %s" ),
2015 return BITMAPS::add_tracks;
2029 std::swap( *
this, *
static_cast<PCB_ARC*
>( aImage ) );
2090 && (
GetMid() -
GetEnd() ).EuclideanNorm() < aThreshold;
2119 return std::make_shared<SHAPE_SEGMENT>(
m_Start,
m_End, width );
2125 if( aFlash == FLASHING::ALWAYS_FLASHED
2126 || ( aFlash == FLASHING::DEFAULT && FlashLayer( aLayer ) ) )
2132 Padstack().ForEachUniqueLayer(
2135 width = std::max( width,
GetWidth( layer ) );
2142 PCB_LAYER_ID cuLayer = m_padStack.EffectiveLayerFor( aLayer );
2146 return std::make_shared<SHAPE_CIRCLE>(
m_Start, width );
2150 return std::make_shared<SHAPE_CIRCLE>(
m_Start, GetDrillValue() / 2 );
2165 return std::make_shared<SHAPE_SEGMENT>(
GetStart(),
GetEnd(), width );
2167 return std::make_shared<SHAPE_ARC>( arc );
2172 int aClearance,
int aError,
ERROR_LOC aErrorLoc,
2173 bool ignoreLineWidth )
const
2175 wxASSERT_MSG( !ignoreLineWidth, wxT(
"IgnoreLineWidth has no meaning for tracks." ) );
2190 int width =
m_width + ( 2 * aClearance );
2196 aError, aErrorLoc );
2202 int width =
m_width + ( 2 * aClearance );
2221 .Undefined( VIATYPE::NOT_DEFINED )
2222 .Map( VIATYPE::THROUGH,
_HKI(
"Through" ) )
2223 .Map( VIATYPE::BLIND_BURIED,
_HKI(
"Blind/buried" ) )
2224 .Map( VIATYPE::MICROVIA,
_HKI(
"Micro" ) );
2227 .Undefined( TENTING_MODE::FROM_RULES )
2228 .Map( TENTING_MODE::FROM_RULES,
_HKI(
"From design rules" ) )
2229 .Map( TENTING_MODE::TENTED,
_HKI(
"Tented" ) )
2230 .Map( TENTING_MODE::NOT_TENTED,
_HKI(
"Not tented" ) );
2233 .Undefined( COVERING_MODE::FROM_RULES )
2234 .Map( COVERING_MODE::FROM_RULES,
_HKI(
"From design rules" ) )
2235 .Map( COVERING_MODE::COVERED,
_HKI(
"Covered" ) )
2236 .Map( COVERING_MODE::NOT_COVERED,
_HKI(
"Not covered" ) );
2239 .Undefined( PLUGGING_MODE::FROM_RULES )
2240 .Map( PLUGGING_MODE::FROM_RULES,
_HKI(
"From design rules" ) )
2241 .Map( PLUGGING_MODE::PLUGGED,
_HKI(
"Plugged" ) )
2242 .Map( PLUGGING_MODE::NOT_PLUGGED,
_HKI(
"Not plugged" ) );
2245 .Undefined( CAPPING_MODE::FROM_RULES )
2246 .Map( CAPPING_MODE::FROM_RULES,
_HKI(
"From design rules" ) )
2247 .Map( CAPPING_MODE::CAPPED,
_HKI(
"Capped" ) )
2248 .Map( CAPPING_MODE::NOT_CAPPED,
_HKI(
"Not capped" ) );
2251 .Undefined( FILLING_MODE::FROM_RULES )
2252 .Map( FILLING_MODE::FROM_RULES,
_HKI(
"From design rules" ) )
2253 .Map( FILLING_MODE::FILLED,
_HKI(
"Filled" ) )
2254 .Map( FILLING_MODE::NOT_FILLED,
_HKI(
"Not filled" ) );
2259 if( layerEnum.
Choices().GetCount() == 0 )
2290 const wxString groupTechLayers =
_HKI(
"Technical Layers" );
2292 auto isExternalLayerTrack =
2295 if(
auto track =
dynamic_cast<PCB_TRACK*
>( aItem ) )
2296 return track->GetLayer() ==
F_Cu || track->GetLayer() ==
B_Cu;
2303 .SetAvailableFunc( isExternalLayerTrack );
2306 PROPERTY_DISPLAY::PT_SIZE ), groupTechLayers )
2307 .SetAvailableFunc( isExternalLayerTrack );
2318 const wxString groupVia =
_HKI(
"Via Properties" );
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
constexpr EDA_IU_SCALE pcbIUScale
constexpr int ARC_LOW_DEF
BITMAPS
A list of all bitmap identifiers.
ZONE_LAYER_OVERRIDE
Conditionally flashed vias and pads that interact with zones of different priority can be very squirr...
constexpr BOX2I BOX2ISafe(const BOX2D &aInput)
BASE_SET & reset(size_t pos)
BASE_SET & set(size_t pos)
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString GetNetnameMsg() const
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
wxString GetNetname() const
const wxString & GetDisplayNetname() const
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
int m_SolderMaskExpansion
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Convert the item shape to a polyset.
virtual void SetLocked(bool aLocked)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
virtual bool IsLocked() const
virtual int BoardCopperLayerCount() const
Return the total number of copper layers for the board that this item resides on.
virtual wxString layerMaskDescribe() const
Return a string (to be shown to the user) describing a layer mask.
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Information pertinent to a Pcbnew printed circuit board.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayer) const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
std::tuple< int, double, double > GetTrackLength(const PCB_TRACK &aTrack) const
Return data on the length and number of track segments connected to a given track.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
bool IntersectsCircle(const Vec &aCenter, const int aRadius) const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
constexpr coord_type GetBottom() const
MINOPTMAX< int > & Value()
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Assign the members of aItem to another object.
KICAD_T Type() const
Returns the type of object.
ENUM_MAP & Map(T aValue, const wxString &aName)
static ENUM_MAP< T > & Instance()
ENUM_MAP & Undefined(T aValue)
Class that other classes need to inherit from, in order to be inspectable.
Contains methods for drawing PCB-specific items.
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
static double lodScaleForThreshold(const KIGFX::VIEW *aView, int aWhatIu, int aThresholdIu)
Get the scale at which aWhatIu would be drawn at the same size as aThresholdIu on screen.
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
std::string AsStdString() const
static bool Contains(int aStart_layer, int aEnd_layer, int aTest_layer)
LSET is a set of PCB_LAYER_IDs.
void RunOnLayers(const std::function< void(PCB_LAYER_ID)> &aFunction) const
Execute a function on each layer of the LSET.
static const LSET & BackTechMask()
Return a mask holding all technical layers (no CU layer) on back side.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const LSET & AllLayersMask()
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
static const LSET & FrontTechMask()
Return a mask holding all technical layers (no CU layer) on front side.
A collection of nets and the parameters used to route or test these nets.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
MASK_LAYER_PROPS & FrontOuterLayers()
void ForEachUniqueLayer(const std::function< void(PCB_LAYER_ID)> &aMethod) const
Runs the given callable for each active unique copper layer in this padstack, meaning F_Cu for MODE::...
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
const LSET & LayerSet() const
void SetShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer)
UNCONNECTED_LAYER_MODE UnconnectedLayerMode() const
const VECTOR2I & Size(PCB_LAYER_ID aLayer) const
@ REMOVE_EXCEPT_START_AND_END
MASK_LAYER_PROPS & BackOuterLayers()
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void SetSize(const VECTOR2I &aSize, PCB_LAYER_ID aLayer)
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
virtual VECTOR2I GetPosition() const override
bool IsDegenerated(int aThreshold=5) const
virtual void swapData(BOARD_ITEM *aImage) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
EDA_ANGLE GetArcAngleStart() const
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
EDA_ANGLE GetArcAngleEnd() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void SetMid(const VECTOR2I &aMid)
EDA_ANGLE GetAngle() const
const VECTOR2I & GetMid() const
PCB_ARC(BOARD_ITEM *aParent)
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
VECTOR2I m_Mid
Arc mid point, halfway between start and end.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
bool operator==(const PCB_ARC &aOther) const
void CopyFrom(const BOARD_ITEM *aOther) override
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
virtual void SetLayerSet(const LSET &aLayers) override
int GetSolderMaskExpansion() const
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void SetHasSolderMask(bool aVal)
virtual double GetLength() const
Get the length of the track using the hypotenuse calculation.
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
virtual void swapData(BOARD_ITEM *aImage) override
void SetEnd(const VECTOR2I &aEnd)
bool HasSolderMask() const
void SetStart(const VECTOR2I &aStart)
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
virtual void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
bool ApproxCollinear(const PCB_TRACK &aTrack)
VECTOR2I m_End
Line end point.
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
std::optional< int > m_solderMaskMargin
void CopyFrom(const BOARD_ITEM *aOther) override
std::optional< int > GetLocalSolderMaskMargin() const
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.
virtual EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the track shape to a closed polygon.
const VECTOR2I & GetStart() const
virtual bool operator==(const BOARD_ITEM &aOther) const override
VECTOR2I m_Start
Line start point.
wxString GetFriendlyName() const override
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
virtual double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
const VECTOR2I & GetEnd() const
PCB_TRACK(BOARD_ITEM *aParent, KICAD_T idtype=PCB_TRACE_T)
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
virtual MINOPTMAX< int > GetWidthConstraint(wxString *aSource=nullptr) const
int m_width
Thickness of track (or arc) – no longer the width of a via.
EDA_ITEM_FLAGS IsPointOnEnds(const VECTOR2I &point, int min_dist=0) const
Return STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if point if near (dist = m...
virtual void SetWidth(int aWidth)
virtual int GetWidth() const
void GetMsgPanelInfoBase_Common(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) const
PCB_LAYER_ID BottomLayer() const
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
PLUGGING_MODE GetFrontPluggingMode() const
VECTOR2I GetPosition() const override
bool IsTented(PCB_LAYER_ID aLayer) const override
Checks if the given object is tented (its copper shape is covered by solder mask) on a given side of ...
void CopyFrom(const BOARD_ITEM *aOther) override
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
void SetCappingMode(CAPPING_MODE aMode)
void SetFrontCoveringMode(COVERING_MODE aMode)
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
COVERING_MODE GetBackCoveringMode() const
bool FlashLayer(int aLayer) const
Check to see whether the via should have a pad on the specific layer.
void SetDrillDefault()
Set the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > m_zoneLayerOverrides
void ClearZoneLayerOverrides()
CAPPING_MODE GetCappingMode() const
const PADSTACK & Padstack() const
void SetFrontTentingMode(TENTING_MODE aMode)
bool m_isFree
"Free" vias don't get their nets auto-updated
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
TENTING_MODE GetFrontTentingMode() const
void SetBottomLayer(PCB_LAYER_ID aLayer)
int GetSolderMaskExpansion() const
void SetDrill(int aDrill)
Set the drill value for vias.
PLUGGING_MODE GetBackPluggingMode() const
void SetBackPluggingMode(PLUGGING_MODE aMode)
MINOPTMAX< int > GetDrillConstraint(wxString *aSource=nullptr) const
void SetBackTentingMode(TENTING_MODE aMode)
void SetFrontPluggingMode(PLUGGING_MODE aMode)
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
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.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool operator==(const PCB_VIA &aOther) const
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
std::mutex m_zoneLayerOverridesMutex
void SetTopLayer(PCB_LAYER_ID aLayer)
FILLING_MODE GetFillingMode() const
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
int GetFrontWidth() const
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
For a via m_layer contains the top layer, the other layer is in m_bottomLayer/.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
virtual void SetLayerSet(const LSET &aLayers) override
Note SetLayerSet() initialize the first and last copper layers connected by the via.
void GetOutermostConnectedLayers(PCB_LAYER_ID *aTopmost, PCB_LAYER_ID *aBottommost) const
Return the top-most and bottom-most connected layers.
void SanitizeLayers()
Check so that the layers are correct depending on the type of via, and so that the top actually is on...
int GetWidth() const override
PCB_VIA & operator=(const PCB_VIA &aOther)
void swapData(BOARD_ITEM *aImage) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void SetFillingMode(FILLING_MODE aMode)
PCB_VIA(BOARD_ITEM *aParent)
wxString layerMaskDescribe() const override
Return a string (to be shown to the user) describing a layer mask.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
void SetViaType(VIATYPE aViaType)
int GetMinAnnulus(PCB_LAYER_ID aLayer, wxString *aSource) const
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
TENTING_MODE GetBackTentingMode() const
PCB_LAYER_ID TopLayer() const
VIATYPE m_viaType
through, blind/buried or micro
COVERING_MODE GetFrontCoveringMode() const
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
void SetFrontWidth(int aWidth)
VIATYPE GetViaType() const
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
MINOPTMAX< int > GetWidthConstraint(wxString *aSource=nullptr) const override
void SetWidth(int aWidth) override
void SetBackCoveringMode(COVERING_MODE aMode)
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Return the 2 layers used by the via (the via actually uses all layers between these 2 layers)
bool HasValidLayerPair(int aCopperLayerCount)
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
VECTOR2I::extended_type ecoord
bool ApproxCollinear(const SEG &aSeg, int aDistanceThreshold=1) const
const VECTOR2I & GetArcMid() const
const VECTOR2I & GetP1() const
bool IsEffectiveLine() const
const VECTOR2I & GetP0() const
Represent a set of closed polygons.
double Area()
Return the area of this poly set.
wxString MessageTextFromMinOptMax(const MINOPTMAX< int > &aValue) const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
void TransformArcToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arc to multiple straight segments.
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
@ ANNULAR_WIDTH_CONSTRAINT
@ VIA_DIAMETER_CONSTRAINT
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
#define PCB_EDIT_FRAME_NAME
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
#define ENDPOINT
ends. (Used to support dragging.)
std::uint32_t EDA_ITEM_FLAGS
#define STARTPOINT
When a line is selected, these flags indicate which.
a few functions useful in geometry calculations.
bool ClipLine(const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
bool IsSolderMaskLayer(int aLayer)
bool IsCopperLayerLowerThan(PCB_LAYER_ID aLayerA, PCB_LAYER_ID aLayerB)
Return true if copper aLayerA is placed lower than aLayerB, false otherwise.
constexpr PCB_LAYER_ID PCBNEW_LAYER_ID_START
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
@ LAYER_VIA_COPPER_START
Virtual layers for via copper on a given copper layer.
@ LAYER_CLEARANCE_START
Virtual layers for pad/via/track clearance outlines for a given copper layer.
@ LAYER_VIA_HOLES
Draw via holes (pad holes do not use this layer).
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
bool IsHoleLayer(int aLayer)
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
void PackLayerSet(google::protobuf::RepeatedField< int > &aOutput, const LSET &aLayerSet)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
static struct TRACK_VIA_DESC _TRACK_VIA_DESC
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
wxString UnescapeString(const wxString &aSource)
constexpr int mmToIU(double mm) const
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
std::optional< bool > is_capped
True if the drill hole should be capped.
std::optional< bool > is_filled
True if the drill hole should be filled completely.
std::optional< bool > has_covering
True if the pad on this side should have covering.
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
std::optional< bool > has_plugging
True if the drill hole should be plugged on this side.
bool operator()(const PCB_TRACK *aFirst, const PCB_TRACK *aSecond) const
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< int32_t > VECTOR2I
VECTOR2< int64_t > VECTOR2L