71 frame()->SetDisplayOptions( opts );
74 frame()->GetInfoBar()->Dismiss();
96 auto explodeCondition =
102 auto recombineCondition =
122 auto& ctxMenu =
m_menu->GetMenu();
126 ctxMenu.AddSeparator( 1 );
136 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( *
m_menu.get() );
146 const PAD* masterPad =
frame()->GetDesignSettings().m_Pad_Master.get();
160 commit.
Push(
_(
"Paste Pad Properties" ) );
181 const PAD& selPad =
static_cast<const PAD&
>( *item );
182 frame()->GetDesignSettings().m_Pad_Master->ImportSettingsFrom( selPad );
191 bool aSameFootprints,
bool aPadShapeFilter,
bool aPadOrientFilter,
192 bool aPadLayerFilter,
bool aPadTypeFilter )
200 if( !aSameFootprints && ( footprint != refFootprint ) )
203 if( footprint->GetFPID() != refFootprint->
GetFPID() )
206 for(
PAD*
pad : footprint->Pads() )
212 EDA_ANGLE padAngle =
pad->GetOrientation() - footprint->GetOrientation();
214 if( aPadOrientFilter && ( padAngle != srcPadAngle ) )
217 if( aPadLayerFilter && (
pad->GetLayerSet() != aSrcPad.
GetLayerSet() ) )
220 if( aPadTypeFilter && (
pad->GetAttribute() != aSrcPad.
GetAttribute() ) )
233 pad->ImportSettingsFrom( aSrcPad );
255 if( dialogRet == wxID_CANCEL )
258 const bool edit_Same_Modules = (dialogRet == 1);
265 commit.
Push(
_(
"Push Pad Settings" ) );
292 return s_lastUsedParams;
301 if( !
board()->GetFirstFootprint() ||
board()->GetFirstFootprint()->Pads().
empty() )
317 int seqPadNum = params->m_start_number;
319 std::deque<int> storedPadNumbers;
320 std::map<wxString, std::pair<int, wxString>> oldNumbers;
324 frame()->PushTool( aEvent );
327 std::list<PAD*> selectedPads;
329 bool isFirstPoint =
true;
334 mag_settings.
tracks = MAGNETIC_OPTIONS::NO_EFFECT;
335 mag_settings.
pads = MAGNETIC_OPTIONS::CAPTURE_ALWAYS;
339 grid.SetSnap(
true );
340 grid.SetUseGrid(
false );
353 auto checkVisibility =
361 if( ( isHighContrast && activeLayers.count( layer ) ) ||
view->
IsLayerVisible( layer ) )
373 if( checkVisibility(
pad ) )
374 pads.push_back(
pad );
387 const auto constructPadNumber =
390 return wxString::Format( wxT(
"%s%d" ), params->m_prefix.value_or(
"" ), aValue );
394 const auto setPopupTextForValue =
397 const wxString msg =
_(
"Click on pad %s\n"
398 "Press <esc> to cancel all; double-click to finish" );
399 statusPopup.
SetText( wxString::Format( msg, constructPadNumber( aValue ) ) );
402 setPopupTextForValue( seqPadNum );
415 if( evt->IsCancelInteractive() )
420 frame()->PopTool( aEvent );
423 else if( evt->IsActivate() )
425 commit.
Push(
_(
"Renumber Pads" ) );
427 frame()->PopTool( aEvent );
432 selectedPads.clear();
437 oldMousePos = mousePos;
438 isFirstPoint =
false;
444 int distance = ( mousePos - oldMousePos ).EuclideanNorm();
447 const VECTOR2I line_step( ( mousePos - oldMousePos ) / segments );
451 for(
int j = 0; j < segments; ++j )
453 VECTOR2I testpoint( mousePos.
x - j * line_step.
x, mousePos.
y - j * line_step.
y );
456 for(
int i = 0; i < collector.
GetCount(); ++i )
458 PAD*
pad =
static_cast<PAD*
>( collector[i] );
460 if( !
pad->IsAperturePad() && checkVisibility(
pad ) )
461 selectedPads.push_back(
pad );
465 selectedPads.unique();
467 for(
PAD*
pad : selectedPads )
470 if( !
pad->IsSelected() )
477 if( storedPadNumbers.size() > 0 )
479 newval = storedPadNumbers.front();
480 storedPadNumbers.pop_front();
485 seqPadNum += params->m_step;
488 const wxString newNumber = constructPadNumber( newval );
489 oldNumbers[newNumber] = { newval,
pad->GetNumber() };
490 pad->SetNumber( newNumber );
496 if( storedPadNumbers.size() > 0 )
497 newval = storedPadNumbers.front();
501 setPopupTextForValue( newval );
505 else if(
pad->IsSelected() && evt->IsClick(
BUT_LEFT ) )
507 auto it = oldNumbers.find(
pad->GetNumber() );
508 wxASSERT( it != oldNumbers.end() );
510 if( it != oldNumbers.end() )
512 storedPadNumbers.push_back( it->second.first );
513 pad->SetNumber( it->second.second );
515 oldNumbers.erase( it );
517 const int newval = storedPadNumbers.front();
518 setPopupTextForValue( newval );
521 pad->ClearSelected();
526 else if( evt->IsDblClick(
BUT_LEFT ) )
528 commit.
Push(
_(
"Renumber Pads" ) );
529 frame()->PopTool( aEvent );
543 oldMousePos = mousePos;
547 for(
PAD* p :
board()->GetFirstFootprint()->Pads() )
568 static bool neednewPadNumber;
573 if( !
board()->GetFirstFootprint() )
579 m_padTool( aPadTool ),
583 neednewPadNumber =
true;
586 virtual ~PAD_PLACER() =
default;
588 std::unique_ptr<BOARD_ITEM> CreateItem()
override
591 PAD*
pad =
new PAD( m_board->GetFirstFootprint() );
592 PAD* master = m_frame->GetDesignSettings().m_Pad_Master.get();
594 pad->ImportSettingsFrom( *master );
599 if( ( m_board->GetFirstFootprint()->GetAttributes() &
FP_SMD )
602 if(
pad->GetProperty() != PAD_PROP::HEATSINK )
604 pad->SetAttribute( PAD_ATTRIB::SMD );
606 pad->SetSizeX( 1.5 *
pad->GetSizeY() );
610 else if( ( m_board->GetFirstFootprint()->GetAttributes() &
FP_THROUGH_HOLE )
613 pad->SetAttribute( PAD_ATTRIB::PTH );
619 pad->SetDrillShape( PAD_DRILL_SHAPE::CIRCLE );
620 int hole_size =
pad->GetSizeX() / 2;
621 pad->SetDrillSize(
VECTOR2I( hole_size, hole_size ) );
626 if(
pad->CanHaveNumber() )
628 wxString padNumber = m_padTool->GetLastPadNumber();
632 if( neednewPadNumber )
633 padNumber = m_board->GetFirstFootprint()->GetNextPadNumber( padNumber );
635 pad->SetNumber( padNumber );
636 m_padTool->SetLastPadNumber( padNumber );
640 neednewPadNumber =
false;
643 return std::unique_ptr<BOARD_ITEM>(
pad );
651 neednewPadNumber =
true;
656 aCommit.
Add( aItem );
665 m_gridHelper.SetSnap( !( m_modifiers &
MD_SHIFT ) );
666 m_gridHelper.SetUseGrid( !( m_modifiers &
MD_CTRL ) );
668 if( !m_gridHelper.GetSnap() )
673 VECTOR2I position = m_padTool->getViewControls()->GetMousePosition();
675 std::vector<BOARD_ITEM*> ignored_items( 1,
pad );
677 if( settings->
pads == MAGNETIC_OPTIONS::NO_EFFECT )
679 PADS& pads = m_board->GetFirstFootprint()->Pads();
680 ignored_items.insert( ignored_items.end(), pads.begin(), pads.end() );
685 DRAWINGS& graphics = m_board->GetFirstFootprint()->GraphicalItems();
686 ignored_items.insert( ignored_items.end(), graphics.begin(), graphics.end() );
699 PAD_PLACER placer(
this,
frame() );
731 commit.
Push(
_(
"Edit Pad" ) );
744 commit.
Push(
_(
"Edit Pad" ) );
747 frame()->SetActiveLayer( layer );
762 PAD* flaggedPad =
nullptr;
767 for(
PAD*
pad : fp->Pads() )
769 if(
pad->IsEntered() )
772 flaggedPadId =
pad->m_Uuid;
805 return dynamic_cast<PAD*
>( aItem ) !=
nullptr;
813 frame()->SetDisplayOptions( opts );
818 msg.Printf(
_(
"Pad Edit Mode. Press %s again to exit." ),
823 msg.Printf(
_(
"Pad Edit Mode. Press %s to exit." ),
843 frame()->SetDisplayOptions( opts );
851 return dynamic_cast<PAD*
>( aItem ) !=
nullptr;
858 frame()->GetInfoBar()->Dismiss();
891 aCommit.
Add( shape );
911 return aPad->
Recombine( aIsDryRun, maxError );
@ NORMAL
Use all material properties from model file.
constexpr EDA_IU_SCALE pcbIUScale
HIGH_CONTRAST_MODE
Determine how inactive layers should be displayed.
static TOOL_ACTION cancelInteractive
static TOOL_ACTION selectionClear
Clear the current selection.
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 for any item which can be embedded within the BOARD container class, and therefore insta...
FOOTPRINT * GetParentFootprint() const
Information pertinent to a Pcbnew printed circuit board.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
const FOOTPRINTS & Footprints() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void Empty()
Clear the list.
int GetCount() const
Return the number of objects in the list.
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
static DELETED_BOARD_ITEM * GetInstance()
Dialog for enumerating pads.
bool GetPadShapeFilter() const
bool GetPadLayerFilter() const
bool GetPadTypeFilter() const
bool GetPadOrientFilter() const
void ForceRefresh()
Force a redraw.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
void SetStatusPopup(wxWindow *aPopup)
A base class for most all the KiCad significant classes used in schematics and boards.
virtual void SetPosition(const VECTOR2I &aPos)
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual void SetParent(EDA_ITEM *aParent)
void SetWidth(int aWidth)
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
static const TOOL_EVENT UndoRedoPostEvent
A general implementation of a COLLECTORS_GUIDE.
void SetIgnoreFPTextOnFront(bool ignore)
void SetIgnoreFPTextOnBack(bool ignore)
void SetIgnoreFPReferences(bool ignore)
void SetIgnoreFPValues(bool ignore)
Used when the right click button is pressed, or when the select tool is in effect.
void Collect(BOARD_ITEM *aItem, const std::vector< KICAD_T > &aScanList, const VECTOR2I &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
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.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const std::set< int > GetHighContrastLayers() const
Returns the set of currently high-contrast layers.
bool GetHighContrast() const
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
An abstract base class for deriving all objects that can be added to a VIEW.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
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.
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
static const LSET & AllLayersMask()
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
bool IsAperturePad() const
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives(PCB_LAYER_ID aLayer) const
Accessor to the basic shape list for custom-shaped pads.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
PAD_ATTRIB GetAttribute() const
static LSET PTHMask()
layer set for a through hole pad
void SetShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the new shape of this pad.
std::vector< PCB_SHAPE * > Recombine(bool aIsDryRun, int aMaxError)
Recombines the pad with other graphical shapes in the footprint.
void DeletePrimitivesList(PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Clear the basic shapes list.
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
static LSET SMDMask()
layer set for a SMD pad on Front layer
std::optional< int > GetLocalThermalSpokeWidthOverride() const
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
PAD_SHAPE GetAnchorPadShape(PCB_LAYER_ID aLayer) const
static TOOL_ACTION recombinePad
static TOOL_ACTION enumeratePads
Tool for quick pad enumeration.
static TOOL_ACTION pushPadSettings
Copy the current pad's settings to other pads in the footprint or on the board.
static TOOL_ACTION mirrorH
Mirroring of selected items.
static TOOL_ACTION copyPadSettings
Copy the selected pad's settings to the board design settings.
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION explodePad
static TOOL_ACTION applyPadSettings
Copy the default pad settings to the selected pad.
static TOOL_ACTION mirrorV
static TOOL_ACTION flip
Flipping of selected objects.
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
Common, abstract interface for edit frames.
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
bool IsProxyItem() const override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
static SELECTION_CONDITION HasType(KICAD_T aType)
Create a functor that tests if among the selected items there is at least one of a given type.
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
int Size() const
Returns the number of selected parts.
A modified version of the wxInfoBar class that allows us to:
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
static bool empty(const wxTextEntryBase *aCtrl)
#define ENTERED
indicates a group has been entered
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
@ REPAINT
Item needs to be redrawn.
@ ALL
All except INITIAL_ADD.
@ CONN
Like smd, does not appear on the solder paste layer (default) Note: also has a special attribute in G...
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
constexpr int mmToIU(double mm) const
Parameters for sequential pad numbering.
@ PCB_PAD_T
class PAD, a pad in a footprint
VECTOR2< int32_t > VECTOR2I
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MM