53 m_wasHighContrast( false ),
95 auto explodeCondition =
101 auto recombineCondition =
125 ctxMenu.AddSeparator( 1 );
135 getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus(
m_menu );
159 commit.
Push(
_(
"Paste Pad Properties" ) );
180 const PAD& selPad =
static_cast<const PAD&
>( *item );
190 bool aSameFootprints,
191 bool aPadShapeFilter,
192 bool aPadOrientFilter,
193 bool aPadLayerFilter,
194 bool aPadTypeFilter )
202 if( !aSameFootprints && ( footprint != refFootprint ) )
205 if( footprint->GetFPID() != refFootprint->
GetFPID() )
208 for(
PAD*
pad : footprint->Pads() )
210 if( aPadShapeFilter && (
pad->GetShape() != aSrcPad.
GetShape() ) )
213 EDA_ANGLE padAngle =
pad->GetOrientation() - footprint->GetOrientation();
215 if( aPadOrientFilter && ( padAngle != srcPadAngle ) )
218 if( aPadLayerFilter && (
pad->GetLayerSet() != aSrcPad.
GetLayerSet() ) )
221 if( aPadTypeFilter && (
pad->GetAttribute() != aSrcPad.
GetAttribute() ) )
234 pad->ImportSettingsFrom( aSrcPad );
259 int dialogRet = dlg.ShowModal();
261 if( dialogRet == wxID_CANCEL )
264 const bool edit_Same_Modules = (dialogRet == 1);
274 commit.
Push(
_(
"Push Pad Settings" ) );
285 if( !
board()->GetFirstFootprint() ||
board()->GetFirstFootprint()->Pads().
empty() )
298 if( settingsDlg.ShowModal() != wxID_OK )
302 wxString padPrefix = settingsDlg.
GetPrefix();
303 std::deque<int> storedPadNumbers;
304 std::map<wxString, std::pair<int, wxString>> oldNumbers;
311 std::list<PAD*> selectedPads;
313 bool isFirstPoint =
true;
322 grid.SetSnap(
true );
323 grid.SetUseGrid(
false );
339 wxString msg =
_(
"Click on pad %s%d\nPress <esc> to cancel all; double-click to finish" );
342 statusPopup.
Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
352 if( evt->IsCancelInteractive() )
360 else if( evt->IsActivate() )
362 commit.
Push(
_(
"Renumber pads" ) );
369 selectedPads.clear();
374 oldCursorPos = cursorPos;
375 isFirstPoint =
false;
384 const VECTOR2I line_step( ( cursorPos - oldCursorPos ) / segments );
388 for(
int j = 0; j < segments; ++j )
390 VECTOR2I testpoint( cursorPos.
x - j * line_step.
x, cursorPos.
y - j * line_step.
y );
393 for(
int i = 0; i < collector.
GetCount(); ++i )
394 selectedPads.push_back(
static_cast<PAD*
>( collector[i] ) );
397 selectedPads.unique();
399 for(
PAD*
pad : selectedPads )
402 if( !
pad->IsSelected() )
409 if( storedPadNumbers.size() > 0 )
411 newval = storedPadNumbers.front();
412 storedPadNumbers.pop_front();
415 newval = seqPadNum++;
418 oldNumbers[newNumber] = { newval,
pad->GetNumber() };
419 pad->SetNumber( newNumber );
425 if( storedPadNumbers.size() > 0 )
426 newval = storedPadNumbers.front();
434 else if(
pad->IsSelected() && evt->IsClick(
BUT_LEFT ) )
436 auto it = oldNumbers.find(
pad->GetNumber() );
437 wxASSERT( it != oldNumbers.end() );
439 if( it != oldNumbers.end() )
441 storedPadNumbers.push_back( it->second.first );
442 pad->SetNumber( it->second.second );
444 oldNumbers.erase( it );
446 int newval = storedPadNumbers.front();
451 pad->ClearSelected();
456 else if( evt->IsDblClick(
BUT_LEFT ) )
458 commit.
Push(
_(
"Renumber pads" ) );
474 statusPopup.
Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
477 for(
PAD* p :
board()->GetFirstFootprint()->Pads() )
494 if( !
board()->GetFirstFootprint() )
501 m_padTool = aPadTool;
504 virtual ~PAD_PLACER()
508 std::unique_ptr<BOARD_ITEM> CreateItem()
override
510 PAD*
pad =
new PAD( m_board->GetFirstFootprint() );
511 PAD* master = m_frame->GetDesignSettings().m_Pad_Master.get();
513 pad->ImportSettingsFrom( *master );
517 if( ( m_board->GetFirstFootprint()->GetAttributes() &
FP_SMD )
522 pad->SetSizeX( 1.5 *
pad->GetSizeY() );
525 else if( ( m_board->GetFirstFootprint()->GetAttributes() &
FP_THROUGH_HOLE )
534 if(
pad->CanHaveNumber() )
536 wxString padNumber = m_padTool->GetLastPadNumber();
537 padNumber = m_board->GetFirstFootprint()->GetNextPadNumber( padNumber );
538 pad->SetNumber( padNumber );
539 m_padTool->SetLastPadNumber( padNumber );
542 return std::unique_ptr<BOARD_ITEM>(
pad );
552 pad->SetLocalCoord();
553 aCommit.
Add( aItem );
563 PAD_PLACER placer(
this );
588 commit.
Push(
_(
"Recombine pad" ) );
606 return dynamic_cast<PAD*
>( aItem ) !=
nullptr;
614 msg.Printf(
_(
"Pad Edit Mode. Press %s again to exit." ),
619 msg.Printf(
_(
"Pad Edit Mode. Press %s to exit." ),
643 return dynamic_cast<PAD*
>( aItem ) !=
nullptr;
673 for(
const std::shared_ptr<PCB_SHAPE>& primitive : aPad->
GetPrimitives() )
677 shape->
SetShape( primitive->GetShape() );
679 shape->
SetFilled( primitive->IsFilled() );
680 shape->
SetStroke( primitive->GetStroke() );
687 shape->
SetStart( primitive->GetStart() );
688 shape->
SetEnd( primitive->GetEnd() );
692 shape->
SetStart( primitive->GetStart() );
693 shape->
SetEnd( primitive->GetEnd() );
694 shape->
SetCenter( primitive->GetCenter() );
698 shape->
SetStart( primitive->GetStart() );
699 shape->
SetEnd( primitive->GetEnd() );
726 commit.
Push(
_(
"Edit pad shapes") );
775 [&](
FP_SHAPE* aShape ) -> std::vector<FP_SHAPE*>
777 std::vector<FP_SHAPE*> matching;
787 && aShape->Compare( other ) == 0 )
789 matching.push_back( other );
797 std::vector<FP_SHAPE*> mergedShapes;
851 mergedShapes.push_back( fpShape );
857 pcbShape->
SetShape( fpShape->GetShape() );
858 pcbShape->
SetFilled( fpShape->IsFilled() );
859 pcbShape->
SetStroke( fpShape->GetStroke() );
866 pcbShape->
SetStart( fpShape->GetStart() );
867 pcbShape->
SetEnd( fpShape->GetEnd() );
871 pcbShape->
SetStart( fpShape->GetStart() );
872 pcbShape->
SetEnd( fpShape->GetEnd() );
873 pcbShape->
SetCenter( fpShape->GetCenter() );
877 pcbShape->
SetStart( fpShape->GetStart() );
878 pcbShape->
SetEnd( fpShape->GetEnd() );
896 aCommit.
Remove( fpShape );
901 for(
FP_SHAPE* other : findMatching( fpShape ) )
904 mergedShapes.push_back( other );
constexpr EDA_IU_SCALE pcbIUScale
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
static TOOL_ACTION cancelInteractive
static TOOL_ACTION highContrastMode
virtual void Revert() override
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
std::unique_ptr< PAD > m_Pad_Master
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 SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
BOARD_ITEM_CONTAINER * GetParentFootprint() const
Information pertinent to a Pcbnew printed circuit board.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
FOOTPRINTS & Footprints()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void Empty()
Clear the list.
int GetCount() const
Return the number of objects in the list.
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
static DELETED_BOARD_ITEM * GetInstance()
int GetStartNumber() const
Return common prefix for all enumerated pads.
wxString GetPrefix() const
static bool m_Pad_Shape_Filter
static bool m_Pad_Type_Filter
static bool m_Pad_Layer_Filter
static bool m_Pad_Orient_Filter
WX_INFOBAR * GetInfoBar()
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
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.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
EDA_ITEM_FLAGS GetFlags() const
void SetBezierC2(const VECTOR2I &aPt)
void SetCenter(const VECTOR2I &aCenter)
void SetFilled(bool aFlag)
void SetPolyShape(const SHAPE_POLY_SET &aShape)
void SetStart(const VECTOR2I &aStart)
void SetShape(SHAPE_T aShape)
void SetEnd(const VECTOR2I &aEnd)
void SetBezierC1(const VECTOR2I &aPt)
wxString SHAPE_T_asString() const
bool IsAnnotationProxy() const
void SetIsAnnotationProxy(bool aIsProxy=true)
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
virtual void SetLocalCoord()
Set relative coordinates from draw coordinates.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
A general implementation of a COLLECTORS_GUIDE.
void SetIgnoreMTextsMarkedNoShow(bool ignore)
void SetIgnoreModulesRefs(bool ignore)
void SetIgnoreModulesVals(bool ignore)
void SetIgnoreMTextsOnFront(bool ignore)
void SetIgnoreMTextsOnBack(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.
PCB specific render settings.
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.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
An abstract base class for deriving all objects that can be added to a VIEW.
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...
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
bool IsAperturePad() const
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
PAD_ATTRIB GetAttribute() const
static LSET PTHMask()
layer set for a through hole pad
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
void DeletePrimitivesList()
Clear the basic shapes list.
bool IsOnLayer(PCB_LAYER_ID aLayer, bool aIncludeCourtyards=false) const override
Test to see if this object is on the given layer.
VECTOR2I GetPosition() const override
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
void SetOffset(const VECTOR2I &aOffset)
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
FOOTPRINT * GetParent() const
PAD_SHAPE GetShape() const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
static LSET SMDMask()
layer set for a SMD pad on Front layer
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
void SetAnchorPadShape(PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
void AddPrimitive(PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
void SetSizeX(const int aX)
PAD_SHAPE GetAnchorPadShape() 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 selectionClear
Clear the current selection.
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
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
EDA_ITEM * GetItem(const KIID &aId) const override
Fetch an item by KIID.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
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.
virtual void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
virtual void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetStroke(const STROKE_PARAMS &aStroke) override
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.
Represent a set of closed polygons.
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,...
Simple container to manage line stroke parameters.
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 Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
static PCB_SHAPE * findNext(PCB_SHAPE *aShape, const VECTOR2I &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.
static bool empty(const wxTextEntryBase *aCtrl)
#define ENTERED
indicates a group has been entered
#define SKIP_STRUCT
flag indicating that the structure should be ignored
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.
#define UNIMPLEMENTED_FOR(type)
@ REPAINT
Item needs to be redrawn.
@ ALL
All except INITIAL_ADD.
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.
@ CONN
Like smd, does not appear on the solder paste layer (default)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
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.
double EuclideanNorm(const VECTOR2I &vector)
@ PCB_PAD_T
class PAD, a pad in a footprint