26#include <wx/display.h>
27#include <wx/dcclient.h>
66 if(
m_grid->GetNumberRows() > 0 )
85 attr =
new wxGridCellAttr;
86 wxArrayString typeNames;
87 typeNames.push_back(
_(
"Through-hole" ) );
88 typeNames.push_back(
_(
"SMD" ) );
89 typeNames.push_back(
_(
"Connector" ) );
90 typeNames.push_back(
_(
"NPTH" ) );
91 typeNames.push_back(
_(
"Aperture" ) );
95 attr =
new wxGridCellAttr;
107 attr =
new wxGridCellAttr;
111 attr =
new wxGridCellAttr;
115 attr =
new wxGridCellAttr;
119 attr =
new wxGridCellAttr;
124 attr =
new wxGridCellAttr;
129 attr =
new wxGridCellAttr;
162 int displayIdx = wxDisplay::GetFromWindow( aParent );
164 if( displayIdx == wxNOT_FOUND )
167 wxRect displayArea = wxDisplay( (
unsigned int) displayIdx ).GetClientArea();
168 wxSize dlgSize = GetSize();
169 int maxH = ( displayArea.height * 4 ) / 5;
171 if( dlgSize.y > maxH )
178 wxSize minSz = GetMinSize();
193 m_grid->PopEventHandler(
true );
206 if( row >=
m_grid->GetNumberRows() )
214 switch(
pad->GetAttribute() )
220 default: attrStr =
_(
"Through-hole" );
break;
227 pad->Padstack().ForEachUniqueLayer(
230 if(
pad->GetSize( aLayer ).x != size_x )
233 if(
pad->GetSize( aLayer ).y != size_y )
236 if(
pad->ShowPadShape( aLayer ) != padShape )
240 if(
pad->IsAperturePad() )
241 attrStr =
_(
"Aperture" );
271 if(
pad->GetPadToDieLength() )
274 if(
pad->GetPadToDieDelay() )
283 m_grid->AutoSizeColumns();
290 dc.SetFont(
m_grid->GetFont() );
306 dc.GetTextExtent( str, &w, &h );
307 maxWidth = std::max( maxWidth, w );
311 int padding = FromDIP( 30 );
320 wxSizeEvent sizeEvt( GetSize(), GetId() );
324 wxSizeEvent evt( sizeEvt );
329 if(
m_grid->GetNumberRows() > 0 )
331 m_grid->SetGridCursor( 0, 0 );
334 wxGridEvent ev(
m_grid->GetId(), wxEVT_GRID_SELECT_CELL,
m_grid, 0, 0, -1, -1,
true );
346 [
this, aRowId](
int aCol )
349 wxGridCellAttr* attr =
m_grid->GetOrCreateCellAttr( aRowId, aCol );
350 attr->SetEditor( cellEditor );
401 pad->ClearBrightened();
419 if( !
m_grid->CommitPendingChanges() )
437 if( typeStr ==
_(
"Through-hole" ) )
439 else if( typeStr ==
_(
"SMD" ) )
441 else if( typeStr ==
_(
"Connector" ) )
443 else if( typeStr ==
_(
"NPTH" ) )
453 pad->Padstack().ForEachUniqueLayer(
456 pad->SetShape( aLayer, newShape );
463 pad->SetPosition( pos );
471 pad->Padstack().ForEachUniqueLayer(
475 pad->SetSize( aLayer, size );
485 pad->Padstack().ForEachUniqueLayer(
489 pad->SetSize( aLayer, size );
499 if( drill_x > 0 || drill_y > 0 )
507 pad->SetDrillSize( { drill_x, drill_y } );
515 if( !lenStr.IsEmpty() )
518 pad->SetPadToDieLength( 0 );
520 if( !delayStr.IsEmpty() )
523 pad->SetPadToDieDelay( 0 );
528 commit.
Push(
_(
"Edit Pads" ) );
544 int cols =
m_grid->GetNumberCols();
546 std::vector<int> widths;
547 widths.reserve( cols );
549 for(
int c = 0; c < cols; ++c )
551 int w =
m_grid->GetColSize( c );
552 widths.push_back( w );
559 for(
int w : widths )
576 int cols =
m_grid->GetNumberCols();
579 for(
int c = 0; c < cols; ++c )
580 available +=
m_grid->GetColSize( c );
583 int clientW =
m_grid->GetClientSize().x;
590 for(
int c = 0; c < cols; ++c )
599 m_grid->SetColSize( c, target );
618 int row = aEvent.GetRow();
619 int col = aEvent.GetCol();
629 bool needCanvasRefresh =
false;
635 needCanvasRefresh =
true;
641 wxString typeStr =
m_grid->GetCellValue( row, col );
644 if( typeStr ==
_(
"Through-hole" ) )
646 else if( typeStr ==
_(
"SMD" ) )
648 else if( typeStr ==
_(
"Connector" ) )
650 else if( typeStr ==
_(
"NPTH" ) )
661 needCanvasRefresh =
true;
669 needCanvasRefresh =
true;
678 pos.
x =
m_grid->GetUnitValue( row, col );
680 pos.
y =
m_grid->GetUnitValue( row, col );
683 needCanvasRefresh =
true;
693 size.
x =
m_grid->GetUnitValue( row, col );
695 size.
y =
m_grid->GetUnitValue( row, col );
698 needCanvasRefresh =
true;
710 if( dx > 0 || dy > 0 )
719 needCanvasRefresh =
true;
727 if( !
m_grid->GetCellValue( row, col ).IsEmpty() )
733 if( !
m_grid->GetCellValue( row, col ).IsEmpty() )
745 if( needCanvasRefresh )
748 base->GetCanvas()->ForceRefresh();
755 int row = aEvent.GetRow();
766 if(
pad->IsBrightened() )
768 pad->ClearBrightened();
780 pad->SetBrightened();
796 int row =
m_grid->GetGridCursorRow();
797 int col =
m_grid->GetGridCursorCol();
804 wxGridCellEditor*
editor =
m_grid->GetCellEditor( row, col );
832 if(
pad->GetNumber().Length() )
836 const wxString summary = pinNumbers.
GetSummary();
854 const auto targetItr = std::next(
m_originalPads.begin(), aRowId );
855 return targetItr->first;
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_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Pad Table"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxStaticText * m_pin_numbers_summary
wxStaticText * m_duplicate_pins
wxStaticText * m_pin_count
PAD * getPadForRow(int aRowId) const
void OnCellChanged(wxGridEvent &aEvent) override
DIALOG_FP_EDIT_PAD_TABLE(PCB_BASE_FRAME *aParent, FOOTPRINT *aFootprint)
void OnCharHook(wxKeyEvent &aEvent) override
void CaptureOriginalPadState()
void OnSelectCell(wxGridEvent &aEvent) override
void InitColumnProportions()
std::map< PAD *, PAD_SNAPSHOT, PAD_SNAPSHOT_COMPARE > m_originalPads
void setRowNullableEditors(int aRowId) const
bool TransferDataFromWindow() override
bool TransferDataToWindow() override
std::vector< int > m_minColWidths
void OnSize(wxSizeEvent &aEvent) override
~DIALOG_FP_EDIT_PAD_TABLE() override
void OnCancel(wxCommandEvent &aEvent) override
void RestoreOriginalPadState()
std::vector< double > m_colProportions
std::unique_ptr< UNITS_PROVIDER > m_unitsProvider
void OnUpdateUI(wxUpdateUIEvent &aEvent) override
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...
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