48 m_wasHighContrast( false ),
90 auto explodeCondition =
96 auto recombineCondition =
120 ctxMenu.AddSeparator( 1 );
129 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus(
m_menu );
149 static_cast<PAD&>( *item ).ImportSettingsFrom( *masterPad );
153 commit.
Push(
_(
"Paste Pad Properties" ) );
174 const PAD& selPad = static_cast<const PAD&>( *item );
184 bool aSameFootprints,
185 bool aPadShapeFilter,
186 bool aPadOrientFilter,
187 bool aPadLayerFilter,
188 bool aPadTypeFilter )
196 if( !aSameFootprints && ( footprint != refFootprint ) )
199 if( footprint->GetFPID() != refFootprint->
GetFPID() )
202 for(
auto pad : footprint->Pads() )
204 if( aPadShapeFilter && (
pad->GetShape() != aSrcPad.
GetShape() ) )
207 double currpad_orient =
pad->GetOrientation() - footprint->GetOrientation();
209 if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
212 if( aPadLayerFilter && (
pad->GetLayerSet() != aSrcPad.
GetLayerSet() ) )
215 if( aPadTypeFilter && (
pad->GetAttribute() != aSrcPad.
GetAttribute() ) )
228 pad->ImportSettingsFrom( aSrcPad );
241 srcPad = static_cast<PAD*>(
selection[0] );
253 int dialogRet = dlg.ShowModal();
255 if( dialogRet == wxID_CANCEL )
258 const bool edit_Same_Modules = (dialogRet == 1);
268 commit.
Push(
_(
"Push Pad Settings" ) );
279 if( !
board()->GetFirstFootprint() ||
board()->GetFirstFootprint()->Pads().
empty() )
294 if( settingsDlg.ShowModal() != wxID_OK )
298 wxString padPrefix = settingsDlg.
GetPrefix();
299 std::deque<int> storedPadNumbers;
300 std::map<wxString, std::pair<int, wxString>> oldNumbers;
308 std::list<PAD*> selectedPads;
310 bool isFirstPoint =
true;
319 grid.SetSnap(
true );
320 grid.SetUseGrid(
false );
335 wxString msg =
_(
"Click on pad %s%d\nPress <esc> to cancel or double-click to commit" );
338 statusPopup.
Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
347 if( evt->IsCancelInteractive() )
355 else if( evt->IsActivate() )
357 commit.
Push(
_(
"Renumber pads" ) );
364 selectedPads.clear();
369 oldCursorPos = cursorPos;
370 isFirstPoint =
false;
379 const wxPoint line_step( ( cursorPos - oldCursorPos ) / segments );
383 for(
int j = 0; j < segments; ++j )
385 wxPoint testpoint( cursorPos.
x - j * line_step.x, cursorPos.
y - j * line_step.y );
388 for(
int i = 0; i < collector.
GetCount(); ++i )
389 selectedPads.push_back( static_cast<PAD*>( collector[i] ) );
392 selectedPads.unique();
394 for(
PAD*
pad : selectedPads )
397 if( !
pad->IsSelected() )
404 if( storedPadNumbers.size() > 0 )
406 newval = storedPadNumbers.front();
407 storedPadNumbers.pop_front();
410 newval = seqPadNum++;
413 oldNumbers[newNumber] = { newval,
pad->GetNumber() };
414 pad->SetNumber( newNumber );
420 if( storedPadNumbers.size() > 0 )
421 newval = storedPadNumbers.front();
429 else if(
pad->IsSelected() && evt->IsClick(
BUT_LEFT ) )
431 auto it = oldNumbers.find(
pad->GetNumber() );
432 wxASSERT( it != oldNumbers.end() );
434 if( it != oldNumbers.end() )
436 storedPadNumbers.push_back( it->second.first );
437 pad->SetNumber( it->second.second );
439 oldNumbers.erase( it );
441 int newval = storedPadNumbers.front();
446 pad->ClearSelected();
451 else if( ( evt->IsKeyPressed() && evt->KeyCode() == WXK_RETURN ) ||
454 commit.
Push(
_(
"Renumber pads" ) );
470 statusPopup.
Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
473 for(
PAD* p :
board()->GetFirstFootprint()->Pads() )
487 if( !
board()->GetFirstFootprint() )
494 m_padTool = aPadTool;
497 virtual ~PAD_PLACER()
501 std::unique_ptr<BOARD_ITEM> CreateItem()
override 503 PAD*
pad =
new PAD( m_board->GetFirstFootprint() );
504 PAD* master = m_frame->GetDesignSettings().m_Pad_Master.get();
506 pad->ImportSettingsFrom( *master );
510 if( ( m_board->GetFirstFootprint()->GetAttributes() &
FP_SMD )
515 pad->SetSizeX( 1.5 *
pad->GetSizeY() );
518 else if( ( m_board->GetFirstFootprint()->GetAttributes() &
FP_THROUGH_HOLE )
523 pad->SetSize( wxSize(
pad->GetSizeX(),
pad->GetSizeX() ) );
527 if(
pad->CanHaveNumber() )
529 wxString padNumber = m_padTool->GetLastPadNumber();
530 padNumber = m_board->GetFirstFootprint()->GetNextPadNumber( padNumber );
531 pad->SetNumber( padNumber );
532 m_padTool->SetLastPadNumber( padNumber );
535 return std::unique_ptr<BOARD_ITEM>(
pad );
540 PAD*
pad = dynamic_cast<PAD*>( aItem );
544 m_frame->GetDesignSettings().m_Pad_Master->ImportSettingsFrom( *
pad );
545 pad->SetLocalCoord();
546 aCommit.
Add( aItem );
556 PAD_PLACER placer(
this );
594 msg.Printf(
_(
"Pad Edit Mode. Press %s again to exit." ),
599 msg.Printf(
_(
"Pad Edit Mode. Press %s to exit." ),
639 for(
const std::shared_ptr<PCB_SHAPE>& primitive : aPad->
GetPrimitives() )
643 shape->
SetShape( primitive->GetShape() );
644 shape->
SetFilled( primitive->IsFilled() );
645 shape->
SetWidth( primitive->GetWidth() );
652 shape->
SetStart( primitive->GetStart() );
653 shape->
SetEnd( primitive->GetEnd() );
657 shape->
SetStart( primitive->GetStart() );
658 shape->
SetEnd( primitive->GetEnd() );
659 shape->
SetCenter( primitive->GetCenter() );
663 shape->
SetStart( primitive->GetStart() );
664 shape->
SetEnd( primitive->GetEnd() );
690 commit.
Push(
_(
"Edit pad shapes") );
711 for(
BOARD_ITEM* item :
board()->GetFirstFootprint()->GraphicalItems() )
713 PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( item );
784 pcbShape->
SetShape( fpShape->GetShape() );
785 pcbShape->
SetFilled( fpShape->IsFilled() );
786 pcbShape->
SetWidth( fpShape->GetWidth() );
794 pcbShape->
SetStart( fpShape->GetStart() );
795 pcbShape->
SetEnd( fpShape->GetEnd() );
799 pcbShape->
SetStart( fpShape->GetStart() );
800 pcbShape->
SetEnd( fpShape->GetEnd() );
801 pcbShape->
SetCenter( fpShape->GetCenter() );
805 pcbShape->
SetStart( fpShape->GetStart() );
806 pcbShape->
SetEnd( fpShape->GetEnd() );
827 commit.
Push(
_(
"Recombine pads" ) );
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
void Empty()
Clear the list.
static TOOL_ACTION selectionClear
Clear the current selection.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
void SetOffset(const wxPoint &aOffset)
const int GetSizeY() const
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
static TOOL_ACTION explodePad
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
static PCB_SHAPE * findNext(PCB_SHAPE *aShape, const wxPoint &aPoint, const std::vector< PCB_SHAPE * > &aList, unsigned aLimit)
Searches for a PCB_SHAPE matching a given end point or start point in a list.
void SetFilled(bool aFlag)
void SetEnd(const wxPoint &aEnd)
void DeletePrimitivesList()
Clear the basic shapes list.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
static constexpr double IU_PER_MM
Mock up a conversion function.
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
void SetIgnoreModulesVals(bool ignore)
void SetPolyShape(const SHAPE_POLY_SET &aShape)
virtual void Revert() override
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static TOOL_ACTION enumeratePads
Tool for quick pad enumeration.
static bool m_Pad_Layer_Filter
Like smd, does not appear on the solder paste layer (default)
Smd pad, appears on the solder paste layer (default)
static TOOL_ACTION cancelInteractive
static TOOL_ACTION properties
Activation of the edit tool.
void SetIgnoreModulesRefs(bool ignore)
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
void SetSizeX(const int aX)
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 TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
static TOOL_ACTION mirror
Mirroring of selected items.
class PAD, a pad in a footprint
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.
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
bool IsAperturePad() const
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::unique_ptr< PAD > m_Pad_Master
search types array terminator (End Of Types)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
void SetBezierC1(const wxPoint &aPt)
This file contains miscellaneous commonly used macros and functions.
void SetStart(const wxPoint &aStart)
static TOOL_ACTION pushPadSettings
Copy the current pad's settings to other pads in the footprint or on the board.
int GetCount() const
Return the number of objects in the list.
virtual void Move(const wxPoint &aMoveVector) override
Move this object.
Container for display options like enable/disable some optional drawings.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
static TOOL_ACTION rotateCw
Rotation of selected objects.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
double GetOrientation() const
Return the rotation angle of the pad in a variety of units (the basic call returns tenths of degrees)...
void SetIgnoreMTextsOnBack(bool ignore)
static TOOL_ACTION copyPadSettings
Copy the selected pad's settings to the board design settings.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
Represent a set of closed polygons.
void SetIgnoreMTextsOnFront(bool ignore)
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
FOOTPRINTS & Footprints()
Inactive layers are shown normally (no high-contrast mode)
wxString GetPrefix() const
static TOOL_ACTION applyPadSettings
Copy the default pad settings to the selected pad.
static TOOL_ACTION recombinePad
static LSET PTHMask()
layer set for a through hole pad
#define UNIMPLEMENTED_FOR(type)
static bool m_Pad_Orient_Filter
PAD_SHAPE GetShape() const
#define STRUCT_DELETED
flag indication structures to be erased
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
void SetWidth(int aWidth)
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
std::function< bool(const SELECTION &)> SELECTION_CONDITION
< Functor type that checks a specific condition for selected items.
EDA_ITEM_FLAGS GetEditFlags() const
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
void SetCenter(const wxPoint &aCenter)
void SetIgnoreMTextsMarkedNoShow(bool ignore)
wxString SHAPE_T_asString() const
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset union between a and b, store the result in it self For aFastMode meaning,...
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
static TOOL_ACTION rotateCcw
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
FOOTPRINT * GetParent() const
static TOOL_ACTION flip
Flipping of selected objects.
A modified version of the wxInfoBar class that allows us to:
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aMaxError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
wxPoint GetPosition() const override
Information pertinent to a Pcbnew printed circuit board.
PCB_LAYER_ID
A quick note on layer IDs:
PAD_ATTRIB GetAttribute() const
Used when the right click button is pressed, or when the select tool is in effect.
static bool m_Pad_Type_Filter
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
void SetShape(SHAPE_T aShape)
const int GetSizeX() const
int Size() const
Returns the number of selected parts.
void AddPrimitive(PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
static bool empty(const wxTextEntryBase *aCtrl)
A base class for most all the KiCad significant classes used in schematics and boards.
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
void SetBezierC2(const wxPoint &aPt)
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
WX_INFOBAR * GetInfoBar()
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
void SetLocalCoord()
Set relative coordinates from draw coordinates.
int GetStartNumber() const
Return common prefix for all enumerated pads.
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
A general implementation of a COLLECTORS_GUIDE.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
static LSET SMDMask()
layer set for a SMD pad on Front layer
static TOOL_ACTION highContrastMode
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
PAD_SHAPE GetAnchorPadShape() const
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
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...
KICAD_T Type() const
Returns the type of object.
void SetAnchorPadShape(PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
static bool m_Pad_Shape_Filter