KiCad PCB EDA Suite
dialog_lib_edit_pin_table.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
25 #include "lib_pin.h"
26 #include "pin_number.h"
27 #include "grid_tricks.h"
29 #include <widgets/wx_grid.h>
30 #include <queue>
31 #include <base_units.h>
32 #include <bitmaps.h>
33 #include <wx/bmpcbox.h>
34 #include <kiface_i.h>
35 #include <kicad_string.h>
36 #include <confirm.h>
37 
38 #define PinTableShownColumnsKey wxT( "PinTableShownColumns" )
39 
40 
41 static std::vector<BITMAP_DEF> g_typeIcons;
42 static wxArrayString g_typeNames;
43 
44 static std::vector<BITMAP_DEF> g_shapeIcons;
45 static wxArrayString g_shapeNames;
46 
47 static std::vector<BITMAP_DEF> g_orientationIcons;
48 static wxArrayString g_orientationNames;
49 
50 
51 class PIN_TABLE_DATA_MODEL : public wxGridTableBase
52 {
53 
54 private:
55  // Because the rows of the grid can either be a single pin or a group of pins, the
56  // data model is a 2D vector. If we're in the single pin case, each row's LIB_PINS
57  // contains only a single pin.
58  std::vector<LIB_PINS> m_rows;
59 
61  bool m_edited;
62 
63 public:
65  m_userUnits( aUserUnits ), m_edited( false )
66  {}
67 
68  int GetNumberRows() override { return (int) m_rows.size(); }
69  int GetNumberCols() override { return COL_COUNT; }
70 
71  wxString GetColLabelValue( int aCol ) override
72  {
73  switch( aCol )
74  {
75  case COL_NUMBER: return _( "Number" );
76  case COL_NAME: return _( "Name" );
77  case COL_TYPE: return _( "Electrical Type" );
78  case COL_SHAPE: return _( "Graphic Style" );
79  case COL_ORIENTATION: return _( "Orientation" );
80  case COL_NUMBER_SIZE: return _( "Number Text Size" );
81  case COL_NAME_SIZE: return _( "Name Text Size" );
82  case COL_LENGTH: return _( "Length" );
83  case COL_POSX: return _( "X Position" );
84  case COL_POSY: return _( "Y Position" );
85  default: wxFAIL; return wxEmptyString;
86  }
87  }
88 
89  bool IsEmptyCell( int row, int col ) override
90  {
91  return false; // don't allow adjacent cell overflow, even if we are actually empty
92  }
93 
94  wxString GetValue( int aRow, int aCol ) override
95  {
96  return GetValue( m_rows[ aRow ], aCol, m_userUnits );
97  }
98 
99  static wxString GetValue( const LIB_PINS& pins, int aCol, EDA_UNITS_T aUserUnits )
100  {
101  wxString fieldValue;
102 
103  if( pins.empty())
104  return fieldValue;
105 
106  for( LIB_PIN* pin : pins )
107  {
108  wxString val;
109 
110  switch( aCol )
111  {
112  case COL_NUMBER:
113  val = pin->GetNumber();
114  break;
115  case COL_NAME:
116  val = pin->GetName();
117  break;
118  case COL_TYPE:
119  val = g_typeNames[ pin->GetType() ];
120  break;
121  case COL_SHAPE:
122  val = g_shapeNames[ pin->GetShape() ];
123  break;
124  case COL_ORIENTATION:
125  val = g_orientationNames[ LIB_PIN::GetOrientationIndex( pin->GetOrientation() ) ];
126  break;
127  case COL_NUMBER_SIZE:
128  val = StringFromValue( aUserUnits, pin->GetNumberTextSize(), true, true );
129  break;
130  case COL_NAME_SIZE:
131  val = StringFromValue( aUserUnits, pin->GetNameTextSize(), true, true );
132  break;
133  case COL_LENGTH:
134  val = StringFromValue( aUserUnits, pin->GetLength(), true );
135  break;
136  case COL_POSX:
137  val = StringFromValue( aUserUnits, pin->GetPosition().x, true );
138  break;
139  case COL_POSY:
140  val = StringFromValue( aUserUnits, pin->GetPosition().y, true );
141  break;
142  default:
143  wxFAIL;
144  break;
145  }
146 
147  if( aCol == COL_NUMBER )
148  {
149  if( fieldValue.length() )
150  fieldValue += wxT( ", " );
151  fieldValue += val;
152  }
153  else
154  {
155  if( !fieldValue.Length() )
156  fieldValue = val;
157  else if( val != fieldValue )
158  fieldValue = INDETERMINATE;
159  }
160  }
161 
162  return fieldValue;
163  }
164 
165  void SetValue( int aRow, int aCol, const wxString &aValue ) override
166  {
167  if( aValue == INDETERMINATE )
168  return;
169 
170  LIB_PINS pins = m_rows[ aRow ];
171 
172  for( LIB_PIN* pin : pins )
173  {
174  switch( aCol )
175  {
176  case COL_NUMBER:
177  pin->SetNumber( aValue );
178  break;
179  case COL_NAME:
180  pin->SetName( aValue );
181  break;
182  case COL_TYPE:
183  pin->SetType( (ELECTRICAL_PINTYPE) g_typeNames.Index( aValue ), false );
184  break;
185  case COL_SHAPE:
186  pin->SetShape( (GRAPHIC_PINSHAPE) g_shapeNames.Index( aValue ) );
187  break;
188  case COL_ORIENTATION:
189  pin->SetOrientation( LIB_PIN::GetOrientationCode(
190  g_orientationNames.Index( aValue ) ), false );
191  break;
192  case COL_NUMBER_SIZE:
193  pin->SetNumberTextSize( ValueFromString( m_userUnits, aValue, true ) );
194  break;
195  case COL_NAME_SIZE:
196  pin->SetNameTextSize( ValueFromString( m_userUnits, aValue, true ) );
197  break;
198  case COL_LENGTH:
199  pin->SetLength( ValueFromString( m_userUnits, aValue ) );
200  break;
201  case COL_POSX:
202  pin->SetPinPosition( wxPoint( ValueFromString( m_userUnits, aValue ),
203  pin->GetPosition().y ) );
204  break;
205  case COL_POSY:
206  pin->SetPinPosition( wxPoint( pin->GetPosition().x,
207  ValueFromString( m_userUnits, aValue ) ) );
208  break;
209  default:
210  wxFAIL;
211  break;
212  }
213  }
214 
215  m_edited = true;
216  }
217 
218  static int findRow( const std::vector<LIB_PINS>& aRowSet, const wxString& aName )
219  {
220  for( size_t i = 0; i < aRowSet.size(); ++i )
221  {
222  if( aRowSet[ i ][ 0 ] && aRowSet[ i ][ 0 ]->GetName() == aName )
223  return i;
224  }
225 
226  return -1;
227  }
228 
229  static bool compare( const LIB_PINS& lhs, const LIB_PINS& rhs,
230  int sortCol, bool ascending, EDA_UNITS_T units )
231  {
232  wxString lhStr = GetValue( lhs, sortCol, units );
233  wxString rhStr = GetValue( rhs, sortCol, units );
234 
235  if( lhStr == rhStr )
236  {
237  // Secondary sort key is always COL_NUMBER
238  sortCol = COL_NUMBER;
239  lhStr = GetValue( lhs, sortCol, units );
240  rhStr = GetValue( rhs, sortCol, units );
241  }
242 
243  bool cmp;
244 
245  switch( sortCol )
246  {
247  case COL_NUMBER:
248  case COL_NAME:
249  cmp = PinNumbers::Compare( lhStr, rhStr ) < 0;
250  break;
251  case COL_NUMBER_SIZE:
252  case COL_NAME_SIZE:
253  cmp = ValueFromString( units, lhStr, true ) < ValueFromString( units, rhStr, true );
254  break;
255  case COL_LENGTH:
256  case COL_POSX:
257  case COL_POSY:
258  cmp = ValueFromString( units, lhStr ) < ValueFromString( units, rhStr );
259  break;
260  default:
261  cmp = StrNumCmp( lhStr, rhStr ) < 0;
262  break;
263  }
264 
265  return ascending == cmp;
266  }
267 
268  void RebuildRows( LIB_PINS& aPins, bool groupByName )
269  {
270  if ( GetView() )
271  {
272  // Commit any pending in-place edits before the row gets moved out from under
273  // the editor.
274  dynamic_cast<WX_GRID*>( GetView() )->CommitPendingChanges( true );
275 
276  wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, m_rows.size() );
277  GetView()->ProcessTableMessage( msg );
278  }
279 
280  m_rows.clear();
281 
282  for( LIB_PIN* pin : aPins )
283  {
284  int rowIndex = -1;
285 
286  if( groupByName )
287  rowIndex = findRow( m_rows, pin->GetName() );
288 
289  if( rowIndex < 0 )
290  {
291  m_rows.emplace_back( LIB_PINS() );
292  rowIndex = m_rows.size() - 1;
293  }
294 
295  m_rows[ rowIndex ].push_back( pin );
296  }
297 
298  int sortCol = 0;
299  bool ascending = true;
300 
301  if( GetView() && GetView()->GetSortingColumn() != wxNOT_FOUND )
302  {
303  sortCol = GetView()->GetSortingColumn();
304  ascending = GetView()->IsSortOrderAscending();
305  }
306 
307  SortRows( sortCol, ascending );
308 
309  if ( GetView() )
310  {
311  wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_rows.size() );
312  GetView()->ProcessTableMessage( msg );
313  }
314  }
315 
316  void SortRows( int aSortCol, bool ascending )
317  {
318  std::sort( m_rows.begin(), m_rows.end(),
319  [ aSortCol, ascending, this ]( LIB_PINS lhs, LIB_PINS rhs ) -> bool
320  { return compare( lhs, rhs, aSortCol, ascending, m_userUnits ); } );
321  }
322 
323  void AppendRow( LIB_PIN* aPin )
324  {
325  LIB_PINS row;
326  row.push_back( aPin );
327  m_rows.push_back( row );
328 
329  if ( GetView() )
330  {
331  wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
332  GetView()->ProcessTableMessage( msg );
333  }
334  }
335 
336  LIB_PINS RemoveRow( int aRow )
337  {
338  LIB_PINS removedRow = m_rows[ aRow ];
339 
340  m_rows.erase( m_rows.begin() + aRow );
341 
342  if ( GetView() )
343  {
344  wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aRow, 1 );
345  GetView()->ProcessTableMessage( msg );
346  }
347 
348  return removedRow;
349  }
350 
351  bool IsEdited()
352  {
353  return m_edited;
354  }
355 };
356 
357 
360  m_part( aPart )
361 {
363 
364  if( g_typeNames.empty())
365  {
366  for( unsigned i = 0; i < PINTYPE_COUNT; ++i )
367  g_typeIcons.push_back( GetBitmap( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
368  for( unsigned i = 0; i < PINTYPE_COUNT; ++i )
369  g_typeNames.push_back( GetText( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
370  g_typeNames.push_back( INDETERMINATE );
371 
372  for( unsigned i = 0; i < PINSHAPE_COUNT; ++i )
373  g_shapeIcons.push_back( GetBitmap( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
374  for( unsigned i = 0; i < PINSHAPE_COUNT; ++i )
375  g_shapeNames.push_back( GetText( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
376  g_shapeNames.push_back( INDETERMINATE );
377 
378  for( unsigned i = 0; i < LIB_PIN::GetOrientationNames().size(); ++i )
381  g_orientationNames.push_back( INDETERMINATE );
382  }
383 
385 
386  // Save original columns widths so we can do proportional sizing.
387  for( int i = 0; i < COL_COUNT; ++i )
388  m_originalColWidths[ i ] = m_grid->GetColSize( i );
389 
390  // Give a bit more room for combobox editors
391  m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
392 
394  m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
395 
396  // Show/hide columns according to the user's preference
397  m_config->Read( PinTableShownColumnsKey, &m_columnsShown, wxT( "0 1 2 3 4 8 9" ) );
399 
400  // Set special attributes
401  wxGridCellAttr* attr;
402 
403  attr = new wxGridCellAttr;
404  attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( g_typeIcons, g_typeNames ) );
405  attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( g_typeIcons, g_typeNames ) );
406  m_grid->SetColAttr( COL_TYPE, attr );
407 
408  attr = new wxGridCellAttr;
409  attr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( g_shapeIcons, g_shapeNames ) );
410  attr->SetEditor( new GRID_CELL_ICON_TEXT_POPUP( g_shapeIcons, g_shapeNames ) );
411  m_grid->SetColAttr( COL_SHAPE, attr );
412 
413  attr = new wxGridCellAttr;
416  m_grid->SetColAttr( COL_ORIENTATION, attr );
417 
418  /* Right-aligned position values look much better, but only MSW and GTK2+
419  * currently support righ-aligned textEditCtrls, so the text jumps on all
420  * the other platforms when you edit it.
421  attr = new wxGridCellAttr;
422  attr->SetAlignment( wxALIGN_RIGHT, wxALIGN_TOP );
423  m_grid->SetColAttr( COL_POSX, attr );
424 
425  attr = new wxGridCellAttr;
426  attr->SetAlignment( wxALIGN_RIGHT, wxALIGN_TOP );
427  m_grid->SetColAttr( COL_POSY, attr );
428  */
429 
430  m_addButton->SetBitmap( KiBitmap( small_plus_xpm ) );
431  m_deleteButton->SetBitmap( KiBitmap( trash_xpm ) );
432  m_refreshButton->SetBitmap( KiBitmap( refresh_xpm ) );
433 
434  GetSizer()->SetSizeHints(this);
435  Centre();
436 
437  m_ButtonsOK->SetDefault();
438  m_initialized = true;
439 
440  // Connect Events
441  m_grid->Connect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_LIB_EDIT_PIN_TABLE::OnColSort ), nullptr, this );
442 }
443 
444 
446 {
448 
449  // Disconnect Events
450  m_grid->Disconnect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_LIB_EDIT_PIN_TABLE::OnColSort ), nullptr, this );
451 
452  // Prevents crash bug in wxGrid's d'tor
454 
455  // Delete the GRID_TRICKS.
456  m_grid->PopEventHandler( true );
457 
458  // This is our copy of the pins. If they were transfered to the part on an OK, then
459  // m_pins will already be empty.
460  for( auto pin : m_pins )
461  delete pin;
462 }
463 
464 
466 {
467  // Make a copy of the pins for editing
468  for( LIB_PIN* pin = m_part->GetNextPin( nullptr ); pin; pin = m_part->GetNextPin( pin ) )
469  m_pins.push_back( new LIB_PIN( *pin ) );
470 
471  m_dataModel->RebuildRows( m_pins, m_cbGroup->GetValue() );
472 
473  updateSummary();
474 
475  return true;
476 }
477 
478 
480 {
481  if( !m_grid->CommitPendingChanges() )
482  return false;
483 
484  // Delete the part's pins
485  while( LIB_PIN* pin = m_part->GetNextPin( nullptr ) )
486  m_part->RemoveDrawItem( pin );
487 
488  // Transfer our pins to the part
489  for( LIB_PIN* pin : m_pins )
490  {
491  pin->SetParent( m_part );
492  m_part->AddDrawItem( pin );
493  }
494 
495  m_pins.clear();
496 
497  return true;
498 }
499 
500 
501 void DIALOG_LIB_EDIT_PIN_TABLE::OnColSort( wxGridEvent& aEvent )
502 {
503  int sortCol = aEvent.GetCol();
504  bool ascending;
505 
506  // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
507  // event, and if we ask it will give us pre-event info.
508  if( m_grid->IsSortingBy( sortCol ) )
509  // same column; invert ascending
510  ascending = !m_grid->IsSortOrderAscending();
511  else
512  // different column; start with ascending
513  ascending = true;
514 
515  m_dataModel->SortRows( sortCol, ascending );
516 }
517 
518 
519 void DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow( wxCommandEvent& event )
520 {
521  if( !m_grid->CommitPendingChanges() )
522  return;
523 
524  m_pins.push_back( new LIB_PIN( nullptr ) );
525 
526  m_dataModel->AppendRow( m_pins[ m_pins.size() - 1 ] );
527 
528  m_grid->MakeCellVisible( m_grid->GetNumberRows() - 1, 0 );
529  m_grid->SetGridCursor( m_grid->GetNumberRows() - 1, 0 );
530 
531  m_grid->EnableCellEditControl( true );
532  m_grid->ShowCellEditControl();
533 
534  updateSummary();
535 }
536 
537 
538 void DIALOG_LIB_EDIT_PIN_TABLE::OnDeleteRow( wxCommandEvent& event )
539 {
540  if( !m_grid->CommitPendingChanges() )
541  return;
542 
543  int curRow = m_grid->GetGridCursorRow();
544 
545  if( curRow < 0 )
546  return;
547 
548  LIB_PINS removedRow = m_dataModel->RemoveRow( curRow );
549 
550  for( auto pin : removedRow )
551  m_pins.erase( std::find( m_pins.begin(), m_pins.end(), pin ) );
552 
553  curRow = std::max( 0, curRow - 1 );
554  m_grid->MakeCellVisible( curRow, m_grid->GetGridCursorCol() );
555  m_grid->SetGridCursor( curRow, m_grid->GetGridCursorCol() );
556 
557  updateSummary();
558 }
559 
560 
561 void DIALOG_LIB_EDIT_PIN_TABLE::OnCellEdited( wxGridEvent& event )
562 {
563  updateSummary();
564 }
565 
566 
568 {
569  if( !m_grid->CommitPendingChanges() )
570  return;
571 
572  m_dataModel->RebuildRows( m_pins, m_cbGroup->GetValue() );
573 
574  adjustGridColumns( m_grid->GetRect().GetWidth() );
575 }
576 
577 
579 {
580  // Account for scroll bars
581  aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
582 
583  wxGridUpdateLocker deferRepaintsTillLeavingScope;
584 
585  // The Number and Name columns must be at least wide enough to hold their contents, but
586  // no less wide than their original widths.
587 
588  m_grid->AutoSizeColumn( COL_NUMBER );
589 
590  if( m_grid->GetColSize( COL_NUMBER ) < m_originalColWidths[ COL_NUMBER ] )
591  m_grid->SetColSize( COL_NUMBER, m_originalColWidths[ COL_NUMBER ] );
592 
593  m_grid->AutoSizeColumn( COL_NAME );
594 
595  if( m_grid->GetColSize( COL_NAME ) < m_originalColWidths[ COL_NAME ] )
596  m_grid->SetColSize( COL_NAME, m_originalColWidths[ COL_NAME ] );
597 
598  // If the grid is still wider than the columns, then stretch the Number and Name columns
599  // to fit.
600 
601  for( int i = 0; i < COL_COUNT; ++i )
602  aWidth -= m_grid->GetColSize( i );
603 
604  if( aWidth > 0 )
605  {
606  m_grid->SetColSize( COL_NUMBER, m_grid->GetColSize( COL_NUMBER ) + aWidth / 2 );
607  m_grid->SetColSize( COL_NAME, m_grid->GetColSize( COL_NAME ) + aWidth / 2 );
608  }
609 }
610 
611 
612 void DIALOG_LIB_EDIT_PIN_TABLE::OnSize( wxSizeEvent& event )
613 {
614  if( m_initialized )
615  adjustGridColumns( event.GetSize().GetX() );
616 
617  event.Skip();
618 }
619 
620 
621 void DIALOG_LIB_EDIT_PIN_TABLE::OnUpdateUI( wxUpdateUIEvent& event )
622 {
623  wxString columnsShown = m_grid->GetShownColumns();
624 
625  if( columnsShown != m_columnsShown )
626  {
627  m_columnsShown = columnsShown;
628 
629  if( !m_grid->IsCellEditControlShown() )
630  adjustGridColumns( m_grid->GetRect().GetWidth() );
631  }
632 }
633 
634 
635 void DIALOG_LIB_EDIT_PIN_TABLE::OnCancel( wxCommandEvent& event )
636 {
637  Close();
638 }
639 
640 
641 void DIALOG_LIB_EDIT_PIN_TABLE::OnClose( wxCloseEvent& event )
642 {
643  // This is a cancel, so commit quietly as we're going to throw the results away anyway.
644  m_grid->CommitPendingChanges( true );
645 
646  if( m_dataModel->IsEdited() )
647  {
648  if( !HandleUnsavedChanges( this, wxEmptyString,
649  [&]()->bool { return TransferDataFromWindow(); } ) )
650  {
651  event.Veto();
652  return;
653  }
654  }
655 
656  if( IsQuasiModal() )
657  EndQuasiModal( wxID_OK );
658  else if( IsModal() )
659  EndModal( wxID_OK );
660  else
661  event.Skip();
662 }
663 
664 
666 {
667  PinNumbers pinNumbers;
668 
669  for( LIB_PIN* pin : m_pins )
670  {
671  if( pin->GetNumber().Length() )
672  pinNumbers.insert( pin->GetNumber() );
673  }
674 
675  m_summary->SetLabel( pinNumbers.GetSummary() );
676 }
static int Compare(PinNumber const &lhs, PinNumber const &rhs)
Definition: pin_number.cpp:110
static wxArrayString g_typeNames
static std::vector< BITMAP_DEF > g_orientationIcons
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Function HandleUnsavedChanges displays a dialog with Save, Cancel and Discard Changes buttons...
Definition: confirm.cpp:213
void OnClose(wxCloseEvent &event) override
static wxArrayString g_shapeNames
static std::vector< BITMAP_DEF > g_shapeIcons
void OnSize(wxSizeEvent &event) override
static int GetOrientationIndex(int aCode)
Get the index of the orientation code.
Definition: lib_pin.cpp:1910
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
static wxArrayString GetOrientationNames()
Get a list of pin orientation names.
Definition: lib_pin.cpp:1890
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:108
void OnAddRow(wxCommandEvent &event) override
PIN_TABLE_DATA_MODEL(EDA_UNITS_T aUserUnits)
void OnCellEdited(wxGridEvent &event) override
Class GRID_TRICKS is used to add cut, copy, and paste to an otherwise unmodied wxGrid instance...
Definition: grid_tricks.h:51
static const BITMAP_DEF * GetOrientationSymbols()
Get a list of pin orientation bitmaps for menus and dialogs.
Definition: lib_pin.cpp:1952
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid&#39;s SetTable() method with one which doesn&#39;t mess up the grid column widths when setting th...
Definition: wx_grid.cpp:46
int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application...
Definition: base_units.cpp:409
void insert(value_type const &v)
Definition: pin_number.h:57
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
DIALOG_LIB_EDIT_PIN_TABLE(wxWindow *parent, LIB_PART *aPart)
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
Definition: wx_grid.cpp:77
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
wxString GetSummary() const
Definition: pin_number.cpp:70
GRAPHIC_PINSHAPE
Definition: pin_shape.h:35
bool IsEmptyCell(int row, int col) override
void SortRows(int aSortCol, bool ascending)
#define INDETERMINATE
void OnRebuildRows(wxCommandEvent &event) override
void OnUpdateUI(wxUpdateUIEvent &event) override
Define a library symbol object.
bool IsQuasiModal()
Definition: dialog_shim.h:124
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
static wxArrayString g_orientationNames
void RebuildRows(LIB_PINS &aPins, bool groupByName)
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:156
static bool compare(const LIB_PINS &lhs, const LIB_PINS &rhs, int sortCol, bool ascending, EDA_UNITS_T units)
wxString GetColLabelValue(int aCol) override
PIN_TABLE_DATA_MODEL * m_dataModel
wxString GetValue(int aRow, int aCol) override
#define PinTableShownColumnsKey
YYCODETYPE lhs
Class DIALOG_LIB_EDIT_PIN_TABLE_BASE.
LIB_PIN * GetNextPin(LIB_PIN *aItem=NULL)
Return the next pin object from the draw list.
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:90
void EndQuasiModal(int retCode)
static int findRow(const std::vector< LIB_PINS > &aRowSet, const wxString &aName)
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_draw_item.h:61
static wxString GetValue(const LIB_PINS &pins, int aCol, EDA_UNITS_T aUserUnits)
void OnDeleteRow(wxCommandEvent &event) override
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:37
#define max(a, b)
Definition: auxiliary.h:86
size_t i
Definition: json11.cpp:597
void RemoveDrawItem(LIB_ITEM *aItem, EDA_DRAW_PANEL *aPanel=NULL, wxDC *aDc=NULL)
Remove draw aItem from list.
void OnColSort(wxGridEvent &aEvent)
wxString StringFromValue(EDA_UNITS_T aUnits, int aValue, bool aAddUnitSymbol, bool aUseMils)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:210
void SetValue(int aRow, int aCol, const wxString &aValue) override
static std::vector< BITMAP_DEF > g_typeIcons
BITMAP_DEF GetBitmap(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:70
int StrNumCmp(const wxString &aString1, const wxString &aString2, int aLength, bool aIgnoreCase)
Function StrNumCmp is a routine compatible with qsort() to sort by alphabetical order.
Definition: string.cpp:315
std::vector< LIB_PINS > m_rows
void OnCancel(wxCommandEvent &event) override
EDA_UNITS_T
Definition: common.h:159
static int GetOrientationCode(int aIndex)
Get the orientation code by index used to set the pin orientation.
Definition: lib_pin.cpp:1901
EDA_UNITS_T GetUserUnits() const override
Definition: dialog_shim.h:132