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;
159 int displayIdx = wxDisplay::GetFromWindow( aParent );
161 if( displayIdx == wxNOT_FOUND )
164 wxRect displayArea = wxDisplay( (
unsigned int) displayIdx ).GetClientArea();
165 wxSize dlgSize = GetSize();
166 int maxH = ( displayArea.height * 4 ) / 5;
168 if( dlgSize.y > maxH )
175 wxSize minSz = GetMinSize();
190 m_grid->PopEventHandler(
true );
203 if( row >=
m_grid->GetNumberRows() )
211 switch(
pad->GetAttribute() )
217 default: attrStr =
_(
"Through-hole" );
break;
224 pad->Padstack().ForEachUniqueLayer(
227 if(
pad->GetSize( aLayer ).x != size_x )
230 if(
pad->GetSize( aLayer ).y != size_y )
233 if(
pad->ShowPadShape( aLayer ) != padShape )
237 if(
pad->IsAperturePad() )
238 attrStr =
_(
"Aperture" );
268 if(
pad->GetPadToDieLength() )
271 if(
pad->GetPadToDieDelay() )
280 m_grid->AutoSizeColumns();
287 dc.SetFont(
m_grid->GetFont() );
303 dc.GetTextExtent( str, &w, &h );
304 maxWidth = std::max( maxWidth, w );
308 int padding = FromDIP( 30 );
317 wxSizeEvent sizeEvt( GetSize(), GetId() );
321 wxSizeEvent evt( sizeEvt );
326 if(
m_grid->GetNumberRows() > 0 )
328 m_grid->SetGridCursor( 0, 0 );
331 wxGridEvent ev(
m_grid->GetId(), wxEVT_GRID_SELECT_CELL,
m_grid, 0, 0, -1, -1,
true );
342 auto setCellEditor = [
this, aRowId](
int aCol )
345 wxGridCellAttr* attr =
m_grid->GetOrCreateCellAttr( aRowId, aCol );
346 attr->SetEditor( cellEditor );
397 pad->ClearBrightened();
415 if( !
m_grid->CommitPendingChanges() )
433 if( typeStr ==
_(
"Through-hole" ) )
435 else if( typeStr ==
_(
"SMD" ) )
437 else if( typeStr ==
_(
"Connector" ) )
439 else if( typeStr ==
_(
"NPTH" ) )
449 pad->Padstack().ForEachUniqueLayer(
452 pad->SetShape( aLayer, newShape );
459 pad->SetPosition( pos );
467 pad->Padstack().ForEachUniqueLayer(
471 pad->SetSize( aLayer, size );
481 pad->Padstack().ForEachUniqueLayer(
485 pad->SetSize( aLayer, size );
495 if( drill_x > 0 || drill_y > 0 )
503 pad->SetDrillSize( { drill_x, drill_y } );
511 if( !lenStr.IsEmpty() )
514 pad->SetPadToDieLength( 0 );
516 if( !delayStr.IsEmpty() )
519 pad->SetPadToDieDelay( 0 );
524 commit.
Push(
_(
"Edit Pads" ) );
540 int cols =
m_grid->GetNumberCols();
542 std::vector<int> widths;
543 widths.reserve( cols );
545 for(
int c = 0; c < cols; ++c )
547 int w =
m_grid->GetColSize( c );
548 widths.push_back( w );
555 for(
int w : widths )
572 int cols =
m_grid->GetNumberCols();
575 for(
int c = 0; c < cols; ++c )
576 available +=
m_grid->GetColSize( c );
579 int clientW =
m_grid->GetClientSize().x;
586 for(
int c = 0; c < cols; ++c )
595 m_grid->SetColSize( c, target );
614 int row = aEvent.GetRow();
615 int col = aEvent.GetCol();
625 bool needCanvasRefresh =
false;
631 needCanvasRefresh =
true;
637 wxString typeStr =
m_grid->GetCellValue( row, col );
640 if( typeStr ==
_(
"Through-hole" ) )
642 else if( typeStr ==
_(
"SMD" ) )
644 else if( typeStr ==
_(
"Connector" ) )
646 else if( typeStr ==
_(
"NPTH" ) )
657 needCanvasRefresh =
true;
665 needCanvasRefresh =
true;
674 pos.
x =
m_grid->GetUnitValue( row, col );
676 pos.
y =
m_grid->GetUnitValue( row, col );
679 needCanvasRefresh =
true;
689 size.
x =
m_grid->GetUnitValue( row, col );
691 size.
y =
m_grid->GetUnitValue( row, col );
694 needCanvasRefresh =
true;
706 if( dx > 0 || dy > 0 )
715 needCanvasRefresh =
true;
723 if( !
m_grid->GetCellValue( row, col ).IsEmpty() )
729 if( !
m_grid->GetCellValue( row, col ).IsEmpty() )
741 if( needCanvasRefresh )
744 base->GetCanvas()->ForceRefresh();
751 int row = aEvent.GetRow();
762 if(
pad->IsBrightened() )
764 pad->ClearBrightened();
776 pad->SetBrightened();
792 int row =
m_grid->GetGridCursorRow();
793 int col =
m_grid->GetGridCursorCol();
800 wxGridCellEditor*
editor =
m_grid->GetCellEditor( row, col );
828 if(
pad->GetNumber().Length() )
832 const wxString summary = pinNumbers.
GetSummary();
850 const auto targetItr = std::next(
m_originalPads.begin(), aRowId );
851 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