28#include <wx/dcclient.h>
29#include <wx/stattext.h>
59 DIALOG_SHIM( (wxWindow*)aParent, wxID_ANY,
_(
"Pad Table" ), wxDefaultPosition, wxDefaultSize,
60 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
67 wxBoxSizer* topSizer =
new wxBoxSizer( wxVERTICAL );
69 wxBoxSizer* bSummarySizer;
70 bSummarySizer =
new wxBoxSizer( wxHORIZONTAL );
80 bSummarySizer->Add( 0, 0, 1, wxEXPAND, 5 );
86 m_pin_count =
new wxStaticText(
this, wxID_ANY,
_(
"0" ) );
88 bSummarySizer->Add(
m_pin_count, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
90 bSummarySizer->Add( 0, 0, 1, wxEXPAND, 5 );
98 bSummarySizer->Add(
m_duplicate_pins, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
100 topSizer->Add( bSummarySizer, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
103 m_grid->CreateGrid( 0, 11 );
115 m_grid->SetColLabelSize( 24 );
117 m_grid->EnableEditing(
true );
119 wxGridCellAttr* attr;
122 attr =
new wxGridCellAttr;
123 wxArrayString typeNames;
124 typeNames.push_back(
_(
"Through-hole" ) );
125 typeNames.push_back(
_(
"SMD" ) );
126 typeNames.push_back(
_(
"Connector" ) );
127 typeNames.push_back(
_(
"NPTH" ) );
128 typeNames.push_back(
_(
"Aperture" ) );
132 attr =
new wxGridCellAttr;
144 attr =
new wxGridCellAttr;
148 attr =
new wxGridCellAttr;
152 attr =
new wxGridCellAttr;
156 attr =
new wxGridCellAttr;
161 attr =
new wxGridCellAttr;
166 attr =
new wxGridCellAttr;
171 attr =
new wxGridCellAttr;
176 attr =
new wxGridCellAttr;
191 topSizer->Add(
m_grid, 1, wxEXPAND | wxALL, 5 );
193 wxStdDialogButtonSizer* buttons =
new wxStdDialogButtonSizer();
194 buttons->AddButton(
new wxButton(
this, wxID_OK ) );
195 buttons->AddButton(
new wxButton(
this, wxID_CANCEL ) );
197 topSizer->Add( buttons, 0, wxALIGN_RIGHT | wxALL, 5 );
199 SetSizer( topSizer );
211 [
this]( wxCommandEvent& aEvt )
228 m_grid->PopEventHandler(
true );
251 switch(
pad->GetAttribute() )
257 default: attrStr =
_(
"Through-hole" );
break;
264 pad->Padstack().ForEachUniqueLayer(
267 if(
pad->GetSize( aLayer ).x != size_x )
270 if(
pad->GetSize( aLayer ).y != size_y )
273 if(
pad->ShowPadShape( aLayer ) != padShape )
277 if(
pad->IsAperturePad() )
278 attrStr =
_(
"Aperture" );
308 if(
pad->GetPadToDieLength() )
311 if(
pad->GetPadToDieDelay() )
318 m_grid->AutoSizeColumns();
325 dc.SetFont(
m_grid->GetFont() );
341 dc.GetTextExtent( str, &w, &h );
342 maxWidth = std::max( maxWidth, w );
346 int padding = FromDIP( 30 );
356 wxSizeEvent sizeEvt( GetSize(), GetId() );
360 wxSizeEvent evt( sizeEvt );
365 if(
m_grid->GetNumberRows() > 0 )
367 m_grid->SetGridCursor( 0, 0 );
369 wxGridEvent ev(
m_grid->GetId(), wxEVT_GRID_SELECT_CELL,
m_grid, 0, 0, -1, -1,
true );
419 pad->ClearBrightened();
437 if( !
m_grid->CommitPendingChanges() )
455 if( typeStr ==
_(
"Through-hole" ) )
457 else if( typeStr ==
_(
"SMD" ) )
459 else if( typeStr ==
_(
"Connector" ) )
461 else if( typeStr ==
_(
"NPTH" ) )
471 pad->Padstack().ForEachUniqueLayer(
474 pad->SetShape( aLayer, newShape );
481 pad->SetPosition( pos );
489 pad->Padstack().ForEachUniqueLayer(
493 pad->SetSize( aLayer, size );
503 pad->Padstack().ForEachUniqueLayer(
507 pad->SetSize( aLayer, size );
517 if( drill_x > 0 || drill_y > 0 )
525 pad->SetDrillSize( { drill_x, drill_y } );
533 if( !lenStr.IsEmpty() )
536 pad->SetPadToDieLength( 0 );
538 if( !delayStr.IsEmpty() )
542 if( delayStr.ToLong( &delayVal ) )
543 pad->SetPadToDieDelay( (
int) delayVal );
545 pad->SetPadToDieDelay( 0 );
548 pad->SetPadToDieDelay( 0 );
553 commit.
Push(
_(
"Edit Pads" ) );
569 int cols =
m_grid->GetNumberCols();
571 std::vector<int> widths;
572 widths.reserve( cols );
574 for(
int c = 0; c < cols; ++c )
576 int w =
m_grid->GetColSize( c );
577 widths.push_back( w );
584 for(
int w : widths )
601 int cols =
m_grid->GetNumberCols();
604 for(
int c = 0; c < cols; ++c )
605 available +=
m_grid->GetColSize( c );
608 int clientW =
m_grid->GetClientSize().x;
615 for(
int c = 0; c < cols; ++c )
624 m_grid->SetColSize( c, target );
643 int row = aEvent.GetRow();
644 int col = aEvent.GetCol();
651 PAD* target =
nullptr;
667 bool needCanvasRefresh =
false;
673 needCanvasRefresh =
true;
679 wxString typeStr =
m_grid->GetCellValue( row, col );
682 if( typeStr ==
_(
"Through-hole" ) )
684 else if( typeStr ==
_(
"SMD" ) )
686 else if( typeStr ==
_(
"Connector" ) )
688 else if( typeStr ==
_(
"NPTH" ) )
699 needCanvasRefresh =
true;
706 needCanvasRefresh =
true;
715 pos.
x =
m_grid->GetUnitValue( row, col );
717 pos.
y =
m_grid->GetUnitValue( row, col );
720 needCanvasRefresh =
true;
730 size.
x =
m_grid->GetUnitValue( row, col );
732 size.
y =
m_grid->GetUnitValue( row, col );
735 needCanvasRefresh =
true;
746 if( dx > 0 || dy > 0 )
748 if( dx <= 0 ) dx = dy;
749 if( dy <= 0 ) dy = dx;
751 needCanvasRefresh =
true;
759 if( !
m_grid->GetCellValue( row, col ).IsEmpty() )
766 wxString d =
m_grid->GetCellValue( row, col );
769 if( d.ToLong( &val ) )
782 if( needCanvasRefresh )
785 base->GetCanvas()->ForceRefresh();
792 int row = aEvent.GetRow();
803 if(
pad->IsBrightened() )
805 pad->ClearBrightened();
818 pad->SetBrightened();
840 int row =
m_grid->GetGridCursorRow();
841 int col =
m_grid->GetGridCursorCol();
843 PAD* target =
nullptr;
872 if(
pad->GetNumber().Length() )
constexpr EDA_IU_SCALE pcbIUScale
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
DIALOG_FP_EDIT_PAD_TABLE(PCB_BASE_FRAME *aParent, FOOTPRINT *aFootprint)
void OnCharHook(wxKeyEvent &aEvent) override
void CaptureOriginalPadState()
void OnUpdateUI(wxUpdateUIEvent &aEvent)
std::vector< PAD_SNAPSHOT > m_originalPads
void InitColumnProportions()
wxStaticText * m_pin_count
wxStaticText * m_staticTextDuplicatePins
wxStaticText * m_staticTextPinNumbers
bool TransferDataFromWindow() override
bool TransferDataToWindow() override
void OnSize(wxSizeEvent &aEvent)
std::vector< int > m_minColWidths
wxStaticText * m_pin_numbers_summary
wxStaticText * m_duplicate_pins
void OnCellChanged(wxGridEvent &aEvent)
wxStaticText * m_staticTextPinCount
~DIALOG_FP_EDIT_PAD_TABLE() override
void RestoreOriginalPadState()
std::vector< double > m_colProportions
std::unique_ptr< UNITS_PROVIDER > m_unitsProvider
void OnSelectCell(wxGridEvent &aEvent)
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...
DIALOG_SHIM(wxWindow *aParent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, const wxString &name=wxDialogNameStr)
virtual void OnCharHook(wxKeyEvent &aEvt)
EDA_UNITS GetUserUnits() const
void ForceRefresh()
Force a redraw.
This class works around a bug in wxGrid where the first keystroke doesn't get sent through the valida...
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
void SetAttribute(PAD_ATTRIB aAttribute)
static wxString ShowPadShape(PAD_SHAPE aShape)
PAD_ATTRIB GetAttribute() const
void SetShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the new shape of this pad.
VECTOR2I GetPosition() const override
void SetPadToDieDelay(int aDelay)
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
void SetPosition(const VECTOR2I &aPos) override
void SetDrillSize(const VECTOR2I &aSize)
void SetSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
void SetPadToDieLength(int aLength)
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
wxString GetDuplicates() const
Gets a formatted string of all the pins that have duplicate numbers.
void insert(value_type const &v)
wxString GetSummary() const
static PAD_SHAPE ShapeFromString(const wxString &shape)
static std::map< int, wxString > shapeNames
PCB_LAYER_ID
A quick note on layer IDs:
@ REPAINT
Item needs to be redrawn.
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ 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) Note: also has a special attribute in G...
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
VECTOR2< int32_t > VECTOR2I