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 );
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 )
219 topSizer->Fit(
this );
230 m_grid->PopEventHandler(
true );
247 if( row >=
m_grid->GetNumberRows() )
255 switch(
pad->GetAttribute() )
261 default: attrStr =
_(
"Through-hole" );
break;
268 pad->Padstack().ForEachUniqueLayer(
271 if(
pad->GetSize( aLayer ).x != size_x )
274 if(
pad->GetSize( aLayer ).y != size_y )
277 if(
pad->ShowPadShape( aLayer ) != padShape )
281 if(
pad->IsAperturePad() )
282 attrStr =
_(
"Aperture" );
312 if(
pad->GetPadToDieLength() )
316 if(
pad->GetPadToDieDelay() )
323 m_grid->AutoSizeColumns();
330 dc.SetFont(
m_grid->GetFont() );
346 dc.GetTextExtent( str, &w, &h );
347 maxWidth = std::max( maxWidth, w );
351 int padding = FromDIP( 30 );
361 wxSizeEvent sizeEvt( GetSize(), GetId() );
365 wxSizeEvent evt( sizeEvt );
370 if(
m_grid->GetNumberRows() > 0 )
372 m_grid->SetGridCursor( 0, 0 );
375 wxGridEvent ev(
m_grid->GetId(), wxEVT_GRID_SELECT_CELL,
m_grid, 0, 0, -1, -1,
true );
425 pad->ClearBrightened();
443 if( !
m_grid->CommitPendingChanges() )
461 if( typeStr ==
_(
"Through-hole" ) )
463 else if( typeStr ==
_(
"SMD" ) )
465 else if( typeStr ==
_(
"Connector" ) )
467 else if( typeStr ==
_(
"NPTH" ) )
477 pad->Padstack().ForEachUniqueLayer(
480 pad->SetShape( aLayer, newShape );
487 pad->SetPosition( pos );
495 pad->Padstack().ForEachUniqueLayer(
499 pad->SetSize( aLayer, size );
509 pad->Padstack().ForEachUniqueLayer(
513 pad->SetSize( aLayer, size );
523 if( drill_x > 0 || drill_y > 0 )
531 pad->SetDrillSize( { drill_x, drill_y } );
539 if( !lenStr.IsEmpty() )
542 pad->SetPadToDieLength( 0 );
544 if( !delayStr.IsEmpty() )
548 if( delayStr.ToLong( &delayVal ) )
549 pad->SetPadToDieDelay( (
int) delayVal );
551 pad->SetPadToDieDelay( 0 );
554 pad->SetPadToDieDelay( 0 );
559 commit.
Push(
_(
"Edit Pads" ) );
575 int cols =
m_grid->GetNumberCols();
577 std::vector<int> widths;
578 widths.reserve( cols );
580 for(
int c = 0; c < cols; ++c )
582 int w =
m_grid->GetColSize( c );
583 widths.push_back( w );
590 for(
int w : widths )
607 int cols =
m_grid->GetNumberCols();
610 for(
int c = 0; c < cols; ++c )
611 available +=
m_grid->GetColSize( c );
614 int clientW =
m_grid->GetClientSize().x;
621 for(
int c = 0; c < cols; ++c )
630 m_grid->SetColSize( c, target );
649 int row = aEvent.GetRow();
650 int col = aEvent.GetCol();
657 PAD* target =
nullptr;
673 bool needCanvasRefresh =
false;
679 needCanvasRefresh =
true;
685 wxString typeStr =
m_grid->GetCellValue( row, col );
688 if( typeStr ==
_(
"Through-hole" ) )
690 else if( typeStr ==
_(
"SMD" ) )
692 else if( typeStr ==
_(
"Connector" ) )
694 else if( typeStr ==
_(
"NPTH" ) )
705 needCanvasRefresh =
true;
713 needCanvasRefresh =
true;
722 pos.
x =
m_grid->GetUnitValue( row, col );
724 pos.
y =
m_grid->GetUnitValue( row, col );
727 needCanvasRefresh =
true;
737 size.
x =
m_grid->GetUnitValue( row, col );
739 size.
y =
m_grid->GetUnitValue( row, col );
742 needCanvasRefresh =
true;
754 if( dx > 0 || dy > 0 )
763 needCanvasRefresh =
true;
771 if( !
m_grid->GetCellValue( row, col ).IsEmpty() )
778 wxString d =
m_grid->GetCellValue( row, col );
781 if( d.ToLong( &val ) )
794 if( needCanvasRefresh )
797 base->GetCanvas()->ForceRefresh();
804 int row = aEvent.GetRow();
815 if(
pad->IsBrightened() )
817 pad->ClearBrightened();
830 pad->SetBrightened();
852 int row =
m_grid->GetGridCursorRow();
853 int col =
m_grid->GetGridCursorCol();
855 PAD* target =
nullptr;
884 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