38#include <magic_enum.hpp>
97 VIATYPE viaType = VIATYPE::NOT_DEFINED;
119 bool hasLocked =
false;
120 bool hasUnlocked =
false;
125 int selection_first_layer = -1;
126 int selection_last_layer = -1;
129 int track_selection_layer = -1;
131 auto getAnnularRingSelection = [](
const PCB_VIA*
via ) ->
int
133 switch(
via->Padstack().UnconnectedLayerMode() )
143 for(
auto& preset : magic_enum::enum_values<IPC4761_PRESET>() )
150 wxString
name =
_(
"Unknown choice" );
153 name = name_it->second;
158 auto getProtectionSurface = [](
const std::optional<bool>& front,
163 if( !front.has_value() )
165 else if( front.value() )
170 if( !back.has_value() )
175 else if( back.value() )
193 auto getProtectionDrill = [](
const std::optional<bool>& drill ) ->
IPC4761_DRILL
195 if( !drill.has_value() )
206 config.tent = getProtectionSurface(
via->Padstack().FrontOuterLayers().has_solder_mask,
207 via->Padstack().BackOuterLayers().has_solder_mask );
209 config.cover = getProtectionSurface(
via->Padstack().FrontOuterLayers().has_covering,
210 via->Padstack().BackOuterLayers().has_covering );
212 config.plug = getProtectionSurface(
via->Padstack().FrontOuterLayers().has_plugging,
213 via->Padstack().BackOuterLayers().has_plugging );
215 config.cap = getProtectionDrill(
via->Padstack().Drill().is_capped );
217 config.fill = getProtectionDrill(
via->Padstack().Drill().is_filled );
221 if( configuration ==
config )
241 switch( item->Type() )
255 track_selection_layer = t->
GetLayer();
282 if( track_selection_layer != t->
GetLayer() )
316 selection_first_layer = v->
TopLayer();
355 viaType = VIATYPE::NOT_DEFINED;
360 if( selection_first_layer != v->
TopLayer() )
396 if(
static_cast<int>( getViaConfiguration( v ) )
477 int viaSelection = wxNOT_FOUND;
480 for(
unsigned ii = 1; ii < aParent->
GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
488 if( viaSelection == wxNOT_FOUND
492 viaSelection = ii - 1;
506 case VIATYPE::NOT_DEFINED:
m_ViaTypeChoice->SetSelection( wxNOT_FOUND );
break;
526 int widthSelection = wxNOT_FOUND;
529 for(
unsigned ii = 1; ii < aParent->
GetDesignSettings().m_TrackWidthList.size(); ii++ )
536 widthSelection = ii - 1;
542 wxCommandEvent event;
550 if( hasLocked && hasUnlocked )
628 if( shortingNets.size() == 1 )
630 msg.Printf(
_(
"Applying these changes will short net %s with %s." ),
636 msg.Printf(
_(
"Applying these changes will short net %s with other nets." ),
640 KIDIALOG dlg(
this, msg,
_(
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
652 if( changingPads.size() == 1 )
654 PAD*
pad = *changingPads.begin();
655 msg.Printf(
_(
"Changing the net will also update %s pad %s to %s." ),
656 pad->GetParentFootprint()->GetReference(),
660 else if( changingPads.size() == 2 )
662 PAD* pad1 = *changingPads.begin();
663 PAD* pad2 = *( ++changingPads.begin() );
664 msg.Printf(
_(
"Changing the net will also update %s pad %s and %s pad %s to %s." ),
673 msg.Printf(
_(
"Changing the net will also update %lu connected pads to %s." ),
674 static_cast<unsigned long>( changingPads.size() ),
678 KIDIALOG dlg(
this, msg,
_(
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
689 std::vector<PCB_TRACK*> selected_tracks;
690 std::set<PCB_TRACK*> connected_tracks;
695 selected_tracks.push_back( track );
698 for(
PCB_TRACK* selected_track : selected_tracks )
703 connected_tracks.insert( track );
723 DisplayError( GetParent(),
_(
"Via hole size must be smaller than via diameter" ) );
732 DisplayError( GetParent(),
_(
"Via start layer and end layer cannot be the same" ) );
755 bool changeLock =
m_lockedCbox->Get3StateValue() != wxCHK_UNDETERMINED;
756 bool setLock =
m_lockedCbox->Get3StateValue() == wxCHK_CHECKED;
758 for(
PCB_TRACK* track : selected_tracks )
762 switch( track->Type() )
795 track->SetLocalSolderMaskMargin( {} );
801 track->SetLocked( setLock );
817 if(
m_viaNotFree->Get3StateValue() != wxCHK_UNDETERMINED )
825 case 0:
via->SetViaType( VIATYPE::THROUGH );
break;
826 case 1:
via->SetViaType( VIATYPE::MICROVIA );
break;
827 case 2:
via->SetViaType( VIATYPE::BLIND_BURIED );
break;
837 via->SetTopLayer( startLayer );
843 via->SetBottomLayer( endLayer );
846 via->SanitizeLayers();
851 via->Padstack().SetUnconnectedLayerMode(
855 via->Padstack().SetUnconnectedLayerMode(
859 via->Padstack().SetUnconnectedLayerMode(
863 via->Padstack().SetUnconnectedLayerMode(
902 via->SetLocked( setLock );
904 auto setSurfaceProtection =
905 [&]( std::optional<bool>& aFront, std::optional<bool>& aBack,
IPC4761_SURFACE aProtection )
907 switch( aProtection )
933 auto setDrillProtection =
934 [&]( std::optional<bool>& aDrill,
IPC4761_DRILL aProtection )
936 switch( aProtection )
950 setSurfaceProtection(
via->Padstack().FrontOuterLayers().has_solder_mask,
951 via->Padstack().BackOuterLayers().has_solder_mask,
954 setSurfaceProtection(
via->Padstack().FrontOuterLayers().has_plugging,
955 via->Padstack().BackOuterLayers().has_plugging,
958 setSurfaceProtection(
via->Padstack().FrontOuterLayers().has_covering,
959 via->Padstack().BackOuterLayers().has_covering,
962 setDrillProtection(
via->Padstack().Drill().is_filled,
config.fill );
964 setDrillProtection(
via->Padstack().Drill().is_capped,
config.cap );
976 std::set<int> shortingNets;
978 std::set<PAD*> changingPads;
988 if( a->
GetEffectiveShape( layer )->Collide( b->GetEffectiveShape( layer ).get() ) )
995 for(
PCB_TRACK* track : connected_tracks )
999 if( other->GetNetCode() == track->GetNetCode() || other->GetNetCode() == newNetCode )
1003 shortingNets.insert( other->GetNetCode() );
1008 for(
PAD*
pad : footprint->Pads() )
1010 if(
pad->GetNetCode() == newNetCode )
1015 if(
pad->GetNetCode() == track->GetNetCode() )
1016 changingPads.insert(
pad );
1018 shortingNets.insert(
pad->GetNetCode() );
1034 for(
PCB_TRACK* track : selected_tracks )
1035 track->SetNetCode( newNetCode );
1037 for(
PAD*
pad : changingPads )
1040 pad->SetNetCode( newNetCode );
1045 commit.
Push(
_(
"Edit Track/Via Properties" ) );
1090 wxCHECK_MSG(
m_viaStack, ,
"Expected valid via stack in onPadstackModeChanged" );
1106 wxCHECK_MSG(
m_viaStack, ,
"Expected valid via stack in onEditLayerChanged" );
1155 wxCHECK_MSG(
m_viaStack, ,
"Expected valid via stack in afterPadstackModeChanged" );
1175 std::vector choices = {
1177 _(
"Inner Layers" ),
1232 if( startLayer < 0 || endLayer < 0 )
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
virtual void Revert() override
Revert the commit by restoring the modified items state.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
TEARDROP_PARAMETERS & GetTeardropParams()
std::vector< int > m_TrackWidthList
std::vector< VIA_DIMENSION > m_ViasDimensionsList
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
bool IsLocked() const override
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
int GetCopperLayerCount() const
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
int LayerDepth(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer) const
bool LegacyTeardrops() const
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_TRACK_VIA_PROPERTIES_BASE.
wxStaticText * m_annularRingsLabel
wxChoice * m_protectionFeatures
wxBoxSizer * m_legacyTeardropsWarning
wxStaticText * m_stMaxWidthLabel
wxStaticText * m_TrackEndYLabel
wxStaticText * m_ViaYLabel
PCB_LAYER_BOX_SELECTOR * m_ViaStartLayer
wxCheckBox * m_lockedCbox
wxCheckBox * m_curvedEdges
wxStaticText * m_trackMaskMarginUnit
wxStaticText * m_TrackStartYUnit
wxStaticText * m_TrackEndXLabel
wxTextCtrl * m_TrackStartXCtrl
wxStaticText * m_predefinedTrackWidthsUnits
wxStaticText * m_TrackWidthLabel
wxStaticText * m_stMaxLenUnits
PCB_LAYER_BOX_SELECTOR * m_ViaEndLayer
wxChoice * m_predefinedTrackWidthsCtrl
wxStaticText * m_trackMaskMarginLabel
wxStaticBoxSizer * m_sbTrackSizer
wxChoice * m_annularRingsCtrl
wxStaticBoxSizer * m_sbViaSizer
wxStaticText * m_ViaDrillUnit
wxStaticText * m_TrackStartXLabel
wxStaticText * m_stWidthPercentLabel
wxCheckBox * m_trackHasSolderMask
PCB_LAYER_BOX_SELECTOR * m_TrackLayerCtrl
wxStaticText * m_TrackStartYLabel
wxStaticText * m_stMaxLen
wxStaticText * m_ViaDiameterUnit
wxTextCtrl * m_TrackEndXCtrl
wxCheckBox * m_cbTeardrops
wxTextCtrl * m_tcLenPercent
wxStaticText * m_minTrackWidthHint
wxStaticText * m_ViaDrillLabel
wxStaticText * m_ViaYUnit
wxStaticText * m_stLenPercentLabel
wxChoice * m_cbPadstackMode
wxCheckBox * m_viaNotFree
wxStaticText * m_TrackWidthUnit
wxTextCtrl * m_tcWidthPercent
wxChoice * m_ViaTypeChoice
wxStaticText * m_stHDRatio
wxTextCtrl * m_ViaDiameterCtrl
wxChoice * m_predefinedViaSizesCtrl
wxStaticText * m_ViaXLabel
wxTextCtrl * m_trackMaskMarginCtrl
wxTextCtrl * m_ViaDrillCtrl
wxStaticText * m_TrackEndYUnit
wxStaticText * m_stMaxWidthUnits
wxStaticText * m_netSelectorLabel
wxStaticBitmap * m_bitmapTeardrop
wxTextCtrl * m_TrackEndYCtrl
wxStaticText * m_techLayersLabel
wxTextCtrl * m_tcTdMaxLen
wxTextCtrl * m_TrackStartYCtrl
wxStaticText * m_ViaDiameterLabel
wxStaticText * m_stHDRatioUnits
wxStaticBitmap * m_legacyTeardropsIcon
wxTextCtrl * m_TrackWidthCtrl
wxStaticText * m_predefinedViaSizesUnits
wxCheckBox * m_cbTeardropsUseNextTrack
wxTextCtrl * m_tcMaxWidth
NET_SELECTOR * m_netSelector
void onWidthEdit(wxCommandEvent &aEvent) override
const PCB_SELECTION & m_items
bool TransferDataFromWindow() override
void onUnitsChanged(wxCommandEvent &aEvent)
UNIT_BINDER m_viaDiameter
void onNetSelector(wxCommandEvent &aEvent)
UNIT_BINDER m_trackMaskMargin
void afterPadstackModeChanged()
void onWidthSelect(wxCommandEvent &aEvent) override
UNIT_BINDER m_teardropWidthPercent
bool confirmShortingNets(int aNet, const std::set< int > &shortingNets)
UNIT_BINDER m_teardropLenPercent
UNIT_BINDER m_teardropMaxWidth
const std::map< IPC4761_PRESET, IPC4761_CONFIGURATION > m_IPC4761Presets
const std::map< IPC4761_PRESET, wxString > m_IPC4761Names
void onTeardropsUpdateUi(wxUpdateUIEvent &event) override
void onPadstackModeChanged(wxCommandEvent &aEvent) override
void onViaEdit(wxCommandEvent &aEvent) override
std::map< int, PCB_LAYER_ID > m_editLayerCtrlMap
PCB_LAYER_ID m_editLayer
The currently-shown copper layer of the edited via(s)
UNIT_BINDER m_trackStartY
void onViaSelect(wxCommandEvent &aEvent) override
void onEditLayerChanged(wxCommandEvent &aEvent) override
PCB_BASE_EDIT_FRAME * m_frame
void onViaNotFreeClicked(wxCommandEvent &aEvent) override
DIALOG_TRACK_VIA_PROPERTIES(PCB_BASE_EDIT_FRAME *aParent, const PCB_SELECTION &aItems)
std::unique_ptr< PADSTACK > m_viaStack
Temporary padstack of the edited via(s)
UNIT_BINDER m_teardropMaxLen
UNIT_BINDER m_trackStartX
UNIT_BINDER m_teardropHDPercent
bool confirmPadChange(const std::set< PAD * > &connectedPads)
~DIALOG_TRACK_VIA_PROPERTIES()
void onTrackEdit(wxCommandEvent &aEvent) override
A base class for most all the KiCad significant classes used in schematics and boards.
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
bool SetOKCancelLabels(const ButtonLabel &ok, const ButtonLabel &cancel) override
int GetLayerSelection() const
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
LSET is a set of PCB_LAYER_IDs.
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
static LSET AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
const wxString & GetNetname() const
void SetNetInfo(const NETINFO_LIST *aNetInfoList)
void SetIndeterminateString(const wxString &aString)
void SetSelectedNetcode(int aNetcode)
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
@ NORMAL
Shape is the same on all layers.
@ CUSTOM
Shapes can be defined on arbitrary layers.
@ FRONT_INNER_BACK
Up to three shapes can be defined (F_Cu, inner copper layers, B_Cu)
@ REMOVE_EXCEPT_START_AND_END
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
static constexpr PCB_LAYER_ID INNER_LAYERS
! The layer identifier to use for "inner layers" on top/inner/bottom padstacks
const wxString & GetNumber() const
Common, abstract interface for edit frames.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
void SetUndefinedLayerName(const wxString &aName)
void SetNotAllowedLayerSet(const LSET &aMask)
bool HasSolderMask() const
std::optional< int > GetLocalSolderMaskMargin() const
virtual int GetWidth() const
bool GetIsFree() const
Check if the via is a free via (as opposed to one created on a track by the router).
PCB_LAYER_ID BottomLayer() const
VECTOR2I GetPosition() const override
const PADSTACK & Padstack() const
int GetWidth() const override
PCB_LAYER_ID TopLayer() const
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
VIATYPE GetViaType() const
bool Empty() const
Checks if there is anything selected.
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
bool m_Enabled
Flag to enable teardrops.
bool m_CurvedEdges
True if the teardrop should be curved.
EDA_UNITS GetUserUnits() const
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aValue in internal units into a united string.
virtual long long int GetValue()
Return the current value in Internal Units.
virtual void SetUnits(EDA_UNITS aUnits)
Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DE...
virtual double GetDoubleValue()
Return the current value in Internal Units.
bool IsIndeterminate() const
Return true if the control holds the indeterminate value (for instance, if it represents a multiple s...
virtual void SetDoubleValue(double aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
virtual void ChangeValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT trigger...
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void SetCoordType(ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
Set the current origin transform mode.
bool IsNull() const
Return true if the control holds no value (ie: empty string, not 0).
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
This file is part of the common library.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
KICOMMON_API wxString GetLabel(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
#define GEOMETRY_MIN_SIZE
bool collide(T aObject, U aAnotherObject, int aLayer, int aMinDistance)
Used by SHAPE_INDEX to implement Query().
bool operator==(const IPC4761_CONFIGURATION &other) const
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ 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)
#define INDETERMINATE_ACTION
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...