28#include <wx/dcclient.h>
52 DIALOG_SHIM( (wxWindow*)aParent, wxID_ANY,
_(
"Pad Table" ), wxDefaultPosition, wxDefaultSize,
53 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
58 wxBoxSizer* topSizer =
new wxBoxSizer( wxVERTICAL );
61 m_grid->CreateGrid( 0, 11 );
73 m_grid->EnableEditing(
true );
78 attr =
new wxGridCellAttr;
80 wxArrayString typeNames;
81 typeNames.push_back(
_(
"Through-hole" ) );
82 typeNames.push_back(
_(
"SMD" ) );
83 typeNames.push_back(
_(
"Connector" ) );
84 typeNames.push_back(
_(
"NPTH" ) );
85 typeNames.push_back(
_(
"Aperture" ) );
90 attr =
new wxGridCellAttr;
102 attr =
new wxGridCellAttr;
106 attr =
new wxGridCellAttr;
110 attr =
new wxGridCellAttr;
114 attr =
new wxGridCellAttr;
119 attr =
new wxGridCellAttr;
124 attr =
new wxGridCellAttr;
129 attr =
new wxGridCellAttr;
134 attr =
new wxGridCellAttr;
146 topSizer->Add(
m_grid, 1, wxEXPAND | wxALL, 5 );
148 wxStdDialogButtonSizer* buttons =
new wxStdDialogButtonSizer();
149 buttons->AddButton(
new wxButton(
this, wxID_OK ) );
150 buttons->AddButton(
new wxButton(
this, wxID_CANCEL ) );
152 topSizer->Add( buttons, 0, wxALIGN_RIGHT | wxALL, 5 );
154 SetSizerAndFit( topSizer );
166 [
this]( wxCommandEvent& aEvt )
197 switch(
pad->GetAttribute() )
203 default: attrStr =
_(
"Through-hole" );
break;
208 if(
pad->IsAperturePad() )
209 attrStr =
_(
"Aperture" );
236 if(
pad->GetPadToDieLength() )
238 if(
pad->GetPadToDieDelay() )
247 m_grid->AutoSizeColumns();
254 dc.SetFont(
m_grid->GetFont() );
262 shapeNames.push_back(
_(
"Chamfered rectangle" ) );
269 dc.GetTextExtent( str, &w, &h );
270 maxWidth = std::max( maxWidth, w );
274 int padding = FromDIP( 30 );
284 wxSizeEvent sizeEvt( GetSize(), GetId() );
288 wxSizeEvent evt( sizeEvt );
293 if(
m_grid->GetNumberRows() > 0 )
295 m_grid->SetGridCursor( 0, 0 );
297 wxGridEvent ev(
m_grid->GetId(), wxEVT_GRID_SELECT_CELL,
m_grid, 0, 0, -1, -1,
true );
346 pad->ClearBrightened();
362 if( !
m_grid->CommitPendingChanges() )
375 if( typeStr ==
_(
"Through-hole" ) )
377 else if( typeStr ==
_(
"SMD" ) )
379 else if( typeStr ==
_(
"Connector" ) )
381 else if( typeStr ==
_(
"NPTH" ) )
393 pad->SetPosition( pos );
405 if( dx > 0 || dy > 0 )
407 if( dx <= 0 ) dx = dy;
408 if( dy <= 0 ) dy = dx;
409 pad->SetDrillSize( { dx, dy } );
417 if( !lenStr.IsEmpty() )
420 pad->SetPadToDieLength( 0 );
422 if( !delayStr.IsEmpty() )
426 if( delayStr.ToLong( &delayVal ) )
427 pad->SetPadToDieDelay( (
int) delayVal );
429 pad->SetPadToDieDelay( 0 );
432 pad->SetPadToDieDelay( 0 );
449 int cols =
m_grid->GetNumberCols();
451 std::vector<int> widths;
452 widths.reserve( cols );
454 for(
int c = 0; c < cols; ++c )
456 int w =
m_grid->GetColSize( c );
457 widths.push_back( w );
464 for(
int w : widths )
480 int cols =
m_grid->GetNumberCols();
483 for(
int c = 0; c < cols; ++c )
484 available +=
m_grid->GetColSize( c );
487 int clientW =
m_grid->GetClientSize().x;
493 for(
int c = 0; c < cols; ++c )
502 m_grid->SetColSize( c, target );
511 int row = aEvent.GetRow();
512 int col = aEvent.GetCol();
519 PAD* target =
nullptr;
523 if( idx == row ) { target =
pad;
break; }
529 bool needCanvasRefresh =
false;
539 wxString typeStr =
m_grid->GetCellValue( row, col );
542 if( typeStr ==
_(
"Through-hole" ) )
544 else if( typeStr ==
_(
"SMD" ) )
546 else if( typeStr ==
_(
"Connector" ) )
548 else if( typeStr ==
_(
"NPTH" ) )
559 needCanvasRefresh =
true;
566 needCanvasRefresh =
true;
575 pos.
x =
m_grid->GetUnitValue( row, col );
577 pos.
y =
m_grid->GetUnitValue( row, col );
580 needCanvasRefresh =
true;
590 size.
x =
m_grid->GetUnitValue( row, col );
592 size.
y =
m_grid->GetUnitValue( row, col );
595 needCanvasRefresh =
true;
606 if( dx > 0 || dy > 0 )
608 if( dx <= 0 ) dx = dy;
609 if( dy <= 0 ) dy = dx;
611 needCanvasRefresh =
true;
618 if( !
m_grid->GetCellValue( row, col ).IsEmpty() )
624 wxString d =
m_grid->GetCellValue( row, col );
627 if( d.ToLong( &val ) )
639 if( needCanvasRefresh )
642 base->GetCanvas()->ForceRefresh();
648 int row = aEvent.GetRow();
659 if(
pad->IsBrightened() )
661 pad->ClearBrightened();
674 pad->SetBrightened();
constexpr EDA_IU_SCALE pcbIUScale
DIALOG_FP_EDIT_PAD_TABLE(PCB_BASE_FRAME *aParent, FOOTPRINT *aFootprint)
void CaptureOriginalPadState()
std::vector< PAD_SNAPSHOT > m_originalPads
void InitColumnProportions()
bool TransferDataFromWindow() override
void OnSize(wxSizeEvent &aEvent)
std::vector< int > m_minColWidths
void OnCellChanged(wxGridEvent &aEvent)
~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 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)
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...
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)
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.
static PAD_SHAPE ShapeFromString(const wxString &shape)
static std::map< int, wxString > shapeNames
@ 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()
VECTOR2< int32_t > VECTOR2I