27#include <wx/display.h>
29#include <wx/dcclient.h>
30#include <wx/stattext.h>
60 DIALOG_SHIM( (wxWindow*)aParent, wxID_ANY,
_(
"Pad Table" ), wxDefaultPosition, wxDefaultSize,
61 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
68 wxBoxSizer* topSizer =
new wxBoxSizer( wxVERTICAL );
70 wxBoxSizer* bSummarySizer;
71 bSummarySizer =
new wxBoxSizer( wxHORIZONTAL );
81 bSummarySizer->Add( 0, 0, 1, wxEXPAND, 5 );
87 m_pin_count =
new wxStaticText(
this, wxID_ANY,
_(
"0" ) );
89 bSummarySizer->Add(
m_pin_count, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
91 bSummarySizer->Add( 0, 0, 1, wxEXPAND, 5 );
99 bSummarySizer->Add(
m_duplicate_pins, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
101 topSizer->Add( bSummarySizer, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
116 m_grid->SetColLabelSize( 24 );
118 m_grid->EnableEditing(
true );
120 wxGridCellAttr* attr;
123 attr =
new wxGridCellAttr;
124 wxArrayString typeNames;
125 typeNames.push_back(
_(
"Through-hole" ) );
126 typeNames.push_back(
_(
"SMD" ) );
127 typeNames.push_back(
_(
"Connector" ) );
128 typeNames.push_back(
_(
"NPTH" ) );
129 typeNames.push_back(
_(
"Aperture" ) );
133 attr =
new wxGridCellAttr;
145 attr =
new wxGridCellAttr;
149 attr =
new wxGridCellAttr;
153 attr =
new wxGridCellAttr;
157 attr =
new wxGridCellAttr;
162 attr =
new wxGridCellAttr;
167 attr =
new wxGridCellAttr;
172 attr =
new wxGridCellAttr;
177 attr =
new wxGridCellAttr;
192 topSizer->Add(
m_grid, 1, wxEXPAND | wxALL, 5 );
194 wxStdDialogButtonSizer* buttons =
new wxStdDialogButtonSizer();
195 buttons->AddButton(
new wxButton(
this, wxID_OK ) );
196 buttons->AddButton(
new wxButton(
this, wxID_CANCEL ) );
198 topSizer->Add( buttons, 0, wxALIGN_RIGHT | wxALL, 5 );
200 SetSizer( topSizer );
212 [
this]( wxCommandEvent& aEvt )
225 int displayIdx = wxDisplay::GetFromWindow( aParent );
227 if( displayIdx == wxNOT_FOUND )
230 wxRect displayArea = wxDisplay( (
unsigned int) displayIdx ).GetClientArea();
231 wxSize dlgSize = GetSize();
232 int maxH = ( displayArea.height * 4 ) / 5;
234 if( dlgSize.y > maxH )
241 wxSize minSz = GetMinSize();
256 m_grid->PopEventHandler(
true );
273 if( row >=
m_grid->GetNumberRows() )
281 switch(
pad->GetAttribute() )
287 default: attrStr =
_(
"Through-hole" );
break;
294 pad->Padstack().ForEachUniqueLayer(
297 if(
pad->GetSize( aLayer ).x != size_x )
300 if(
pad->GetSize( aLayer ).y != size_y )
303 if(
pad->ShowPadShape( aLayer ) != padShape )
307 if(
pad->IsAperturePad() )
308 attrStr =
_(
"Aperture" );
338 if(
pad->GetPadToDieLength() )
342 if(
pad->GetPadToDieDelay() )
349 m_grid->AutoSizeColumns();
356 dc.SetFont(
m_grid->GetFont() );
372 dc.GetTextExtent( str, &w, &h );
373 maxWidth = std::max( maxWidth, w );
377 int padding = FromDIP( 30 );
387 wxSizeEvent sizeEvt( GetSize(), GetId() );
391 wxSizeEvent evt( sizeEvt );
396 if(
m_grid->GetNumberRows() > 0 )
398 m_grid->SetGridCursor( 0, 0 );
401 wxGridEvent ev(
m_grid->GetId(), wxEVT_GRID_SELECT_CELL,
m_grid, 0, 0, -1, -1,
true );
451 pad->ClearBrightened();
469 if( !
m_grid->CommitPendingChanges() )
487 if( typeStr ==
_(
"Through-hole" ) )
489 else if( typeStr ==
_(
"SMD" ) )
491 else if( typeStr ==
_(
"Connector" ) )
493 else if( typeStr ==
_(
"NPTH" ) )
503 pad->Padstack().ForEachUniqueLayer(
506 pad->SetShape( aLayer, newShape );
513 pad->SetPosition( pos );
521 pad->Padstack().ForEachUniqueLayer(
525 pad->SetSize( aLayer, size );
535 pad->Padstack().ForEachUniqueLayer(
539 pad->SetSize( aLayer, size );
549 if( drill_x > 0 || drill_y > 0 )
557 pad->SetDrillSize( { drill_x, drill_y } );
565 if( !lenStr.IsEmpty() )
568 pad->SetPadToDieLength( 0 );
570 if( !delayStr.IsEmpty() )
574 if( delayStr.ToLong( &delayVal ) )
575 pad->SetPadToDieDelay( (
int) delayVal );
577 pad->SetPadToDieDelay( 0 );
580 pad->SetPadToDieDelay( 0 );
585 commit.
Push(
_(
"Edit Pads" ) );
601 int cols =
m_grid->GetNumberCols();
603 std::vector<int> widths;
604 widths.reserve( cols );
606 for(
int c = 0; c < cols; ++c )
608 int w =
m_grid->GetColSize( c );
609 widths.push_back( w );
616 for(
int w : widths )
633 int cols =
m_grid->GetNumberCols();
636 for(
int c = 0; c < cols; ++c )
637 available +=
m_grid->GetColSize( c );
640 int clientW =
m_grid->GetClientSize().x;
647 for(
int c = 0; c < cols; ++c )
656 m_grid->SetColSize( c, target );
675 int row = aEvent.GetRow();
676 int col = aEvent.GetCol();
683 PAD* target =
nullptr;
699 bool needCanvasRefresh =
false;
705 needCanvasRefresh =
true;
711 wxString typeStr =
m_grid->GetCellValue( row, col );
714 if( typeStr ==
_(
"Through-hole" ) )
716 else if( typeStr ==
_(
"SMD" ) )
718 else if( typeStr ==
_(
"Connector" ) )
720 else if( typeStr ==
_(
"NPTH" ) )
731 needCanvasRefresh =
true;
739 needCanvasRefresh =
true;
748 pos.
x =
m_grid->GetUnitValue( row, col );
750 pos.
y =
m_grid->GetUnitValue( row, col );
753 needCanvasRefresh =
true;
763 size.
x =
m_grid->GetUnitValue( row, col );
765 size.
y =
m_grid->GetUnitValue( row, col );
768 needCanvasRefresh =
true;
780 if( dx > 0 || dy > 0 )
789 needCanvasRefresh =
true;
797 if( !
m_grid->GetCellValue( row, col ).IsEmpty() )
804 wxString d =
m_grid->GetCellValue( row, col );
807 if( d.ToLong( &val ) )
820 if( needCanvasRefresh )
823 base->GetCanvas()->ForceRefresh();
830 int row = aEvent.GetRow();
841 if(
pad->IsBrightened() )
843 pad->ClearBrightened();
856 pad->SetBrightened();
878 int row =
m_grid->GetGridCursorRow();
879 int col =
m_grid->GetGridCursorCol();
881 PAD* target =
nullptr;
910 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