KiCad PCB EDA Suite
dialog_footprint_properties_fp_editor.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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2015 Dick Hollenbeck, [email protected]
6 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#include <confirm.h>
30#include <validators.h>
32#include <board_commit.h>
33#include <bitmaps.h>
34#include <kiplatform/ui.h>
36#include <widgets/wx_grid.h>
38#include <footprint.h>
44#include "filename_resolver.h"
45#include <pgm_base.h>
49#include <tool/tool_manager.h>
52
53#include <fp_lib_table.h>
54
56 m_frame( aFrame )
57{
58 m_layerColAttr = new wxGridCellAttr;
59 m_layerColAttr->SetRenderer( new GRID_CELL_LAYER_RENDERER( m_frame ) );
60
61 LSET forbiddenLayers = LSET::AllCuMask() | LSET::AllTechMask();
62 forbiddenLayers.set( Edge_Cuts );
63 forbiddenLayers.set( Margin );
64 m_layerColAttr->SetEditor( new GRID_CELL_LAYER_SELECTOR( m_frame, forbiddenLayers ) );
65}
66
67
69{
70 m_layerColAttr->DecRef();
71}
72
73
74bool PRIVATE_LAYERS_GRID_TABLE::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
75{
76 return aTypeName == wxGRID_VALUE_NUMBER;
77}
78
79
80bool PRIVATE_LAYERS_GRID_TABLE::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
81{
82 return aTypeName == wxGRID_VALUE_NUMBER;
83}
84
85
86wxGridCellAttr* PRIVATE_LAYERS_GRID_TABLE::GetAttr( int aRow, int aCol,
87 wxGridCellAttr::wxAttrKind )
88{
89 m_layerColAttr->IncRef();
90 return m_layerColAttr;
91}
92
93
94wxString PRIVATE_LAYERS_GRID_TABLE::GetValue( int aRow, int aCol )
95{
96 return m_frame->GetBoard()->GetLayerName( this->at( (size_t) aRow ) );
97}
98
99
101{
102 return this->at( (size_t) aRow );
103}
104
105
106void PRIVATE_LAYERS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
107{
108 wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
109}
110
111
112void PRIVATE_LAYERS_GRID_TABLE::SetValueAsLong( int aRow, int aCol, long aValue )
113{
114 this->at( (size_t) aRow ) = ToLAYER_ID( (int) aValue );
115}
116
117
118// Remember the last open page during session.
119
121
122
124 FOOTPRINT_EDIT_FRAME* aParent,
125 FOOTPRINT* aFootprint ) :
127 m_frame( aParent ),
128 m_footprint( aFootprint ),
129 m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits ),
130 m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl,
131 m_SolderMaskMarginUnits ),
132 m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl,
133 m_SolderPasteMarginUnits ),
134 m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl,
135 m_PasteMarginRatioUnits )
136{
137 // Create the 3D models page
139 m_NoteBook->AddPage( m_3dPanel, _("3D Models"), false );
140
143
144 m_delayedErrorMessage = wxEmptyString;
145 m_delayedFocusCtrl = nullptr;
146 m_delayedFocusGrid = nullptr;
150
151 // Give an icon
152 wxIcon icon;
153 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
154 SetIcon( icon );
155
156 // Give a bit more room for combobox editors
157 m_itemsGrid->SetDefaultRowSize( m_itemsGrid->GetDefaultRowSize() + 4 );
158 m_privateLayersGrid->SetDefaultRowSize( m_privateLayersGrid->GetDefaultRowSize() + 4 );
159
162
163 m_itemsGrid->PushEventHandler( new GRID_TRICKS( m_itemsGrid ) );
165 [this]( wxCommandEvent& aEvent )
166 {
167 OnAddLayer( aEvent );
168 } ) );
169 m_padGroupsGrid->PushEventHandler( new GRID_TRICKS( m_padGroupsGrid,
170 [this]( wxCommandEvent& aEvent )
171 {
172 OnAddPadGroup( aEvent );
173 } ) );
174
175 m_itemsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
176 m_privateLayersGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
177 m_padGroupsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
178
179 // Show/hide columns according to the user's preference
181
183
184 // Set font sizes
185 wxFont infoFont = KIUI::GetInfoFont( this );
186 infoFont.SetStyle( wxFONTSTYLE_ITALIC );
187 m_staticTextInfoCopper->SetFont( infoFont );
188 m_staticTextInfoPaste->SetFont( infoFont );
189
190 if( static_cast<int>( m_page ) >= 0 )
191 m_NoteBook->SetSelection( (unsigned) m_page );
192
194 {
199 }
201 {
203 }
204
206
209
210 // Configure button logos
211 m_bpAdd->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
217
219
221}
222
223
225{
227 m_itemsGrid->GetShownColumns().ToStdString();
228
229 // Prevents crash bug in wxGrid's d'tor
232
233 // Delete the GRID_TRICKS.
234 m_itemsGrid->PopEventHandler( true );
235 m_privateLayersGrid->PopEventHandler( true );
236 m_padGroupsGrid->PopEventHandler( true );
237
238 m_page = static_cast<NOTEBOOK_PAGES>( m_NoteBook->GetSelection() );
239
240 // the GL canvas on the 3D models page has to be visible before it is destroyed
241 m_NoteBook->SetSelection( static_cast<int>( NOTEBOOK_PAGES::PAGE_3D_MODELS ) );
242}
243
244
246{
247 LIB_ID fpID = m_footprint->GetFPID();
248 wxString footprintName = fpID.GetLibItemName();
249
250 m_FootprintNameCtrl->ChangeValue( footprintName );
251
252 m_DocCtrl->SetValue( m_footprint->GetDescription() );
253 m_KeywordCtrl->SetValue( m_footprint->GetKeywords() );
254
255 if( !wxDialog::TransferDataToWindow() )
256 return false;
257
258 if( !m_PanelGeneral->TransferDataToWindow() )
259 return false;
260
261 // Add the models to the panel
263 return false;
264
265 // Footprint Texts
266 m_texts->push_back( m_footprint->Reference() );
267 m_texts->push_back( m_footprint->Value() );
268
269 for( BOARD_ITEM* item : m_footprint->GraphicalItems() )
270 {
271 FP_TEXT* textItem = dyn_cast<FP_TEXT*>( item );
272
273 if( textItem )
274 m_texts->push_back( *textItem );
275 }
276
277 // Notify the grid
278 wxGridTableMessage tmsg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_texts->GetNumberRows() );
279 m_itemsGrid->ProcessTableMessage( tmsg );
280
282 m_componentType->SetSelection( 0 );
283 else if( m_footprint->GetAttributes() & FP_SMD )
284 m_componentType->SetSelection( 1 );
285 else
286 m_componentType->SetSelection( 2 );
287
288 // Private layers
289 for( PCB_LAYER_ID privateLayer : m_footprint->GetPrivateLayers().UIOrder() )
290 m_privateLayers->push_back( privateLayer );
291
292 // Notify the grid
293 wxGridTableMessage gridTableMessagesg( m_privateLayers, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
295 m_privateLayersGrid->ProcessTableMessage( gridTableMessagesg );
296
301
302 // Local Clearances
303
309
310 switch( m_footprint->GetZoneConnection() )
311 {
312 default:
313 case ZONE_CONNECTION::INHERITED: m_ZoneConnectionChoice->SetSelection( 0 ); break;
314 case ZONE_CONNECTION::FULL: m_ZoneConnectionChoice->SetSelection( 1 ); break;
315 case ZONE_CONNECTION::THERMAL: m_ZoneConnectionChoice->SetSelection( 2 ); break;
316 case ZONE_CONNECTION::NONE: m_ZoneConnectionChoice->SetSelection( 3 ); break;
317 }
318
319 for( const wxString& group : m_footprint->GetNetTiePadGroups() )
320 {
321 if( !group.IsEmpty() )
322 {
323 m_padGroupsGrid->AppendRows( 1 );
324 m_padGroupsGrid->SetCellValue( m_padGroupsGrid->GetNumberRows() - 1, 0, group );
325 }
326 }
327
328 // Items grid
329 for( int col = 0; col < m_itemsGrid->GetNumberCols(); col++ )
330 {
331 // Adjust min size to the column label size
332 m_itemsGrid->SetColMinimalWidth( col, m_itemsGrid->GetVisibleWidth( col, true, false ) );
333 // Adjust the column size.
334 int col_size = m_itemsGrid->GetVisibleWidth( col );
335
336 if( col == FPT_LAYER ) // This one's a drop-down. Check all possible values.
337 {
338 BOARD* board = m_footprint->GetBoard();
339
340 for( PCB_LAYER_ID layer : board->GetEnabledLayers().Seq() )
341 col_size = std::max( col_size, GetTextExtent( board->GetLayerName( layer ) ).x );
342
343 // And the swatch:
344 col_size += 20;
345 }
346
347 if( m_itemsGrid->IsColShown( col ) )
348 m_itemsGrid->SetColSize( col, col_size );
349 }
350
351 m_itemsGrid->SetRowLabelSize( m_itemsGrid->GetVisibleWidth( -1, true, true, true ) );
352
353 Layout();
355
356 return true;
357}
358
359
361{
362 if( aFootprintName.IsEmpty() )
363 {
364 m_delayedErrorMessage = _( "Footprint must have a name." );
365 return false;
366 }
367 else if( !FOOTPRINT::IsLibNameValid( aFootprintName ) )
368 {
369 m_delayedErrorMessage.Printf( _( "Footprint name may not contain '%s'." ),
371 return false;
372 }
373
374 return true;
375}
376
377
379{
381 return false;
382
383 if( !DIALOG_SHIM::Validate() )
384 return false;
385
386 // First, test for invalid chars in footprint name
387 wxString footprintName = m_FootprintNameCtrl->GetValue();
388
389 if( !checkFootprintName( footprintName ) )
390 {
391 if( m_NoteBook->GetSelection() != 0 )
392 m_NoteBook->SetSelection( 0 );
393
396
397 return false;
398 }
399
400 // Check for empty texts.
401 for( size_t i = 2; i < m_texts->size(); ++i )
402 {
403 FP_TEXT& text = m_texts->at( i );
404
405 if( text.GetText().IsEmpty() )
406 {
407 if( m_NoteBook->GetSelection() != 0 )
408 m_NoteBook->SetSelection( 0 );
409
410 m_delayedErrorMessage = _( "Text items must have some content." );
414
415 return false;
416 }
417 }
418
419 if( !m_netClearance.Validate( 0, INT_MAX ) )
420 return false;
421
422 return true;
423}
424
425
427{
428 if( !Validate() )
429 return false;
430
431 if( !DIALOG_SHIM::TransferDataFromWindow() )
432 return false;
433
437 {
438 return false;
439 }
440
441 // This only commits the editor, model updating is done below so it is inside
442 // the commit
444 return false;
445
447 BOARD_COMMIT commit( m_frame );
448 commit.Modify( m_footprint );
449
450 LIB_ID fpID = m_footprint->GetFPID();
451 fpID.SetLibItemName( m_FootprintNameCtrl->GetValue() );
452 m_footprint->SetFPID( fpID );
453
454 m_footprint->SetDescription( m_DocCtrl->GetValue() );
455 m_footprint->SetKeywords( m_KeywordCtrl->GetValue() );
456
457 // copy reference and value
458 m_footprint->Reference() = m_texts->at( 0 );
459 m_footprint->Value() = m_texts->at( 1 );
460
461 size_t i = 2;
462 std::vector<FP_TEXT*> items_to_remove;
463
464 for( BOARD_ITEM* item : m_footprint->GraphicalItems() )
465 {
466 FP_TEXT* textItem = dynamic_cast<FP_TEXT*>( item );
467
468 if( textItem )
469 {
470 // copy grid table entries till we run out, then delete any remaining texts
471 if( i < m_texts->size() )
472 *textItem = m_texts->at( i++ );
473 else // store this item to remove and delete it later,
474 // after the graphic list is explored:
475 items_to_remove.push_back( textItem );
476 }
477 }
478
479 // Remove text items:
481
482 for( FP_TEXT* item: items_to_remove )
483 {
484 selTool->RemoveItemFromSel( item );
485 view->Remove( item );
486 item->DeleteStructure();
487 }
488
489 // if there are still grid table entries, create new texts for them
490 while( i < m_texts->size() )
491 {
492 FP_TEXT* newText = new FP_TEXT( m_texts->at( i++ ) );
493 m_footprint->Add( newText, ADD_MODE::APPEND );
494 view->Add( newText );
495 }
496
497 LSET privateLayers;
498
499 for( PCB_LAYER_ID layer : *m_privateLayers )
500 privateLayers.set( layer );
501
502 m_footprint->SetPrivateLayers( privateLayers );
503
504 int attributes = 0;
505
506 switch( m_componentType->GetSelection() )
507 {
508 case 0: attributes |= FP_THROUGH_HOLE; break;
509 case 1: attributes |= FP_SMD; break;
510 default: break;
511 }
512
513 if( m_boardOnly->GetValue() )
514 attributes |= FP_BOARD_ONLY;
515
516 if( m_excludeFromPosFiles->GetValue() )
517 attributes |= FP_EXCLUDE_FROM_POS_FILES;
518
519 if( m_excludeFromBOM->GetValue() )
520 attributes |= FP_EXCLUDE_FROM_BOM;
521
522 if( m_noCourtyards->GetValue() )
523 attributes |= FP_ALLOW_MISSING_COURTYARD;
524
525 if( m_allowBridges->GetValue() )
526 attributes |= FP_ALLOW_SOLDERMASK_BRIDGES;
527
528 m_footprint->SetAttributes( attributes );
529
530 // Initialize masks clearances
535
536 switch( m_ZoneConnectionChoice->GetSelection() )
537 {
538 default:
543 }
544
546
547 for( int ii = 0; ii < m_padGroupsGrid->GetNumberRows(); ++ii )
548 {
549 wxString group = m_padGroupsGrid->GetCellValue( ii, 0 );
550
551 if( !group.IsEmpty() )
553 }
554
555 // Copy the models from the panel to the footprint
556 std::vector<FP_3DMODEL>& panelList = m_3dPanel->GetModelList();
557 std::vector<FP_3DMODEL>* fpList = &m_footprint->Models();
558 fpList->clear();
559 fpList->insert( fpList->end(), panelList.begin(), panelList.end() );
560
561 commit.Push( _( "Modify footprint properties" ) );
562
563 return true;
564}
565
566
567static bool footprintIsFromBoard( FOOTPRINT* aFootprint )
568{
569 return aFootprint->GetLink() != niluuid;
570}
571
572
574{
576 {
577 // Currently: nothing to do
578 }
579}
580
581
583{
585 return;
586
587 const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
588 FP_TEXT textItem( m_footprint );
589
590 // Set active layer if legal; otherwise copy layer from previous text item
592 textItem.SetLayer( m_frame->GetActiveLayer() );
593 else
594 textItem.SetLayer( m_texts->at( m_texts->size() - 1 ).GetLayer() );
595
596 textItem.SetTextSize( dsnSettings.GetTextSize( textItem.GetLayer() ) );
597 textItem.SetTextThickness( dsnSettings.GetTextThickness( textItem.GetLayer() ) );
598 textItem.SetItalic( dsnSettings.GetTextItalic( textItem.GetLayer() ) );
599
600 m_texts->push_back( textItem );
601
602 // notify the grid
603 wxGridTableMessage msg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
604 m_itemsGrid->ProcessTableMessage( msg );
605
606 m_itemsGrid->SetFocus();
607 m_itemsGrid->MakeCellVisible( m_texts->size() - 1, 0 );
608 m_itemsGrid->SetGridCursor( m_texts->size() - 1, 0 );
609
610 m_itemsGrid->EnableCellEditControl( true );
611 m_itemsGrid->ShowCellEditControl();
612}
613
614
616{
618 return;
619
620 wxArrayInt selectedRows = m_itemsGrid->GetSelectedRows();
621
622 if( selectedRows.empty() && m_itemsGrid->GetGridCursorRow() >= 0 )
623 selectedRows.push_back( m_itemsGrid->GetGridCursorRow() );
624
625 if( selectedRows.empty() )
626 return;
627
628 for( int row : selectedRows )
629 {
630 if( row < 2 )
631 {
632 DisplayError( nullptr, _( "Reference and value are mandatory." ) );
633 return;
634 }
635 }
636
637 // Reverse sort so deleting a row doesn't change the indexes of the other rows.
638 selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
639
640 for( int row : selectedRows )
641 {
642 m_texts->erase( m_texts->begin() + row );
643
644 // notify the grid
645 wxGridTableMessage msg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
646 m_itemsGrid->ProcessTableMessage( msg );
647
648 if( m_itemsGrid->GetNumberRows() > 0 )
649 {
650 m_itemsGrid->MakeCellVisible( std::max( 0, row-1 ), m_itemsGrid->GetGridCursorCol() );
651 m_itemsGrid->SetGridCursor( std::max( 0, row-1 ), m_itemsGrid->GetGridCursorCol() );
652 }
653 }
654}
655
656
658{
660 return;
661
662 PCB_LAYER_ID nextLayer = User_1;
663
664 while( alg::contains( *m_privateLayers, nextLayer ) && nextLayer < User_9 )
665 nextLayer = ToLAYER_ID( nextLayer + 1 );
666
667 m_privateLayers->push_back( nextLayer );
668
669 // notify the grid
670 wxGridTableMessage msg( m_privateLayers, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
671 m_privateLayersGrid->ProcessTableMessage( msg );
672
673 m_privateLayersGrid->SetFocus();
674 m_privateLayersGrid->MakeCellVisible( m_privateLayers->size() - 1, 0 );
675 m_privateLayersGrid->SetGridCursor( m_privateLayers->size() - 1, 0 );
676}
677
678
680{
682 return;
683
684 int curRow = m_privateLayersGrid->GetGridCursorRow();
685
686 if( curRow < 0 )
687 return;
688
689 m_privateLayers->erase( m_privateLayers->begin() + curRow );
690
691 // notify the grid
692 wxGridTableMessage msg( m_privateLayers, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 );
693 m_privateLayersGrid->ProcessTableMessage( msg );
694
695 if( m_privateLayersGrid->GetNumberRows() > 0 )
696 {
697 m_privateLayersGrid->MakeCellVisible( std::max( 0, curRow-1 ),
698 m_privateLayersGrid->GetGridCursorCol() );
699 m_privateLayersGrid->SetGridCursor( std::max( 0, curRow-1 ),
700 m_privateLayersGrid->GetGridCursorCol() );
701 }
702}
703
704
706{
708 return;
709
710 m_padGroupsGrid->AppendRows( 1 );
711
712 m_padGroupsGrid->SetFocus();
713 m_padGroupsGrid->MakeCellVisible( m_padGroupsGrid->GetNumberRows() - 1, 0 );
714 m_padGroupsGrid->SetGridCursor( m_padGroupsGrid->GetNumberRows() - 1, 0 );
715
716 m_padGroupsGrid->EnableCellEditControl( true );
717 m_padGroupsGrid->ShowCellEditControl();
718}
719
720
722{
724 return;
725
726 wxArrayInt selectedRows = m_padGroupsGrid->GetSelectedRows();
727 int curRow = m_padGroupsGrid->GetGridCursorRow();
728
729 if( selectedRows.empty() && curRow >= 0 && curRow < m_padGroupsGrid->GetNumberRows() )
730 selectedRows.Add( curRow );
731
732 for( int ii = selectedRows.Count() - 1; ii >= 0; --ii )
733 {
734 int row = selectedRows.Item( ii );
735 m_padGroupsGrid->DeleteRows( row, 1 );
736 curRow = std::min( curRow, row );
737 }
738
739 curRow = std::max( 0, curRow - 1 );
740 m_padGroupsGrid->MakeCellVisible( curRow, m_padGroupsGrid->GetGridCursorCol() );
741 m_padGroupsGrid->SetGridCursor( curRow, m_padGroupsGrid->GetGridCursorCol() );
742}
743
744
746{
747 // Account for scroll bars
749
750 itemsWidth -= m_itemsGrid->GetRowLabelSize();
751
752 for( int i = 1; i < m_itemsGrid->GetNumberCols(); i++ )
753 itemsWidth -= m_itemsGrid->GetColSize( i );
754
755 m_itemsGrid->SetColSize( 0, std::max( itemsWidth,
756 m_itemsGrid->GetVisibleWidth( 0, true, false ) ) );
757
758 // Update the width private layers grid
759 m_privateLayersGrid->SetColSize( 0, std::max( m_privateLayersGrid->GetClientSize().x,
761
762 // Update the width net tie pad groups grid
763 m_padGroupsGrid->SetColSize( 0, std::max( m_padGroupsGrid->GetClientSize().x,
765
766 // Update the width of the 3D panel
768}
769
770
772{
773 if( !m_itemsGrid->IsCellEditControlShown() )
775
776 // Handle a delayed focus. The delay allows us to:
777 // a) change focus when the error was triggered from within a killFocus handler
778 // b) show the correct notebook page in the background before the error dialog comes up
779 // when triggered from an OK or a notebook page change
780
781 if( static_cast<int>( m_delayedFocusPage ) >= 0 )
782 {
783 if( m_NoteBook->GetSelection() != static_cast<int>( m_delayedFocusPage ) )
784 m_NoteBook->ChangeSelection( static_cast<int>( m_delayedFocusPage ) );
785
787 }
788
789 if( !m_delayedErrorMessage.IsEmpty() )
790 {
791 // We will re-enter this routine when the error dialog is displayed, so make
792 // sure we don't keep putting up more dialogs.
793 wxString msg = m_delayedErrorMessage;
794 m_delayedErrorMessage = wxEmptyString;
795
796 // Do not use DisplayErrorMessage(); it screws up window order on Mac
797 DisplayError( nullptr, msg );
798 }
799
801 {
802 m_delayedFocusCtrl->SetFocus();
803
804 if( wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
805 textEntry->SelectAll();
806
807 m_delayedFocusCtrl = nullptr;
808 }
809 else if( m_delayedFocusGrid )
810 {
811 m_delayedFocusGrid->SetFocus();
814
815 m_delayedFocusGrid->EnableCellEditControl( true );
816 m_delayedFocusGrid->ShowCellEditControl();
817
818 m_delayedFocusGrid = nullptr;
821 }
822}
823
824
826{
828
829 event.Skip();
830}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ icon_modedit
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Container for design settings for a BOARD object.
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
int GetTextThickness(PCB_LAYER_ID aLayer) const
Return the default text thickness from the layer class for the given layer.
bool GetTextItalic(PCB_LAYER_ID aLayer) const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:50
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:167
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:201
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:37
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:501
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:400
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
Class DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR_BASE.
DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(FOOTPRINT_EDIT_FRAME *aParent, FOOTPRINT *aFootprint)
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
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...
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.cpp:185
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
void SetItalic(bool aItalic)
Definition: eda_text.cpp:201
BOARD_DESIGN_SETTINGS & GetDesignSettings() const override
Returns the BOARD_DESIGN_SETTINGS for the open project.
FOOTPRINT_EDITOR_SETTINGS * GetSettings()
This class provides a custom wxValidator object for limiting the allowable characters when defining f...
Definition: validators.h:64
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:208
static bool IsLibNameValid(const wxString &aName)
Test for validity of a name of a footprint to be used in a footprint library ( no spaces,...
Definition: footprint.cpp:1493
void SetDescription(const wxString &aDoc)
Definition: footprint.h:214
int GetLocalClearance() const
Definition: footprint.h:225
void SetKeywords(const wxString &aKeywords)
Definition: footprint.h:217
void SetAttributes(int aAttributes)
Definition: footprint.h:246
double GetLocalSolderPasteMarginRatio() const
Definition: footprint.h:239
const wxString & GetKeywords() const
Definition: footprint.h:216
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: footprint.h:240
void SetPrivateLayers(LSET aLayers)
Adds an item to the container.
Definition: footprint.h:125
void SetLocalSolderPasteMargin(int aMargin)
Definition: footprint.h:237
int GetAttributes() const
Definition: footprint.h:245
void ClearNetTiePadGroups()
Definition: footprint.h:269
LSET GetPrivateLayers() const
Definition: footprint.h:124
int GetLocalSolderPasteMargin() const
Definition: footprint.h:236
const std::vector< wxString > & GetNetTiePadGroups() const
Definition: footprint.h:267
void SetLocalClearance(int aClearance)
Definition: footprint.h:226
const LIB_ID & GetFPID() const
Definition: footprint.h:207
void SetLocalSolderMaskMargin(int aMargin)
Definition: footprint.h:223
void AddNetTiePadGroup(const wxString &aGroup)
Definition: footprint.h:274
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:555
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:549
const wxString & GetDescription() const
Definition: footprint.h:213
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: footprint.h:242
KIID GetLink() const
Definition: footprint.h:629
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:188
static const wxChar * StringLibNameInvalidChars(bool aUserReadable)
Test for validity of the name in a library of the footprint ( no spaces, dir separators ....
Definition: footprint.cpp:1504
ZONE_CONNECTION GetZoneConnection() const
Definition: footprint.h:243
DRAWINGS & GraphicalItems()
Definition: footprint.h:177
FP_TEXT & Reference()
Definition: footprint.h:556
int GetLocalSolderMaskMargin() const
Definition: footprint.h:222
int GetNumberRows() override
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:61
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition: lib_id.cpp:109
const UTF8 & GetLibItemName() const
Definition: lib_id.h:101
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
LSEQ UIOrder() const
Definition: lset.cpp:916
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:841
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
std::vector< FP_3DMODEL > & GetModelList()
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
virtual PCB_LAYER_ID GetActiveLayer() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
BOARD * GetBoard() const
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
The selection tool: currently supports:
wxString GetValue(int aRow, int aCol) override
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
long GetValueAsLong(int aRow, int aCol) override
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) override
void SetValueAsLong(int aRow, int aCol, long aValue) override
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
virtual long long int GetValue()
Return the current value in Internal Units.
virtual void SetUnits(EDA_UNITS aUnits)
Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DE...
virtual void SetNegativeZero()
Definition: unit_binder.h:70
virtual double GetDoubleValue()
Return the current value in Internal Units.
virtual void SetDoubleValue(double aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculates the specified column based on the actual size of the text on screen.
Definition: wx_grid.cpp:282
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:172
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
Definition: wx_grid.cpp:93
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:139
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:153
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:226
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
This file is part of the common library.
static bool footprintIsFromBoard(FOOTPRINT *aFootprint)
#define _(s)
@ FP_SMD
Definition: footprint.h:68
@ FP_ALLOW_MISSING_COURTYARD
Definition: footprint.h:74
@ FP_EXCLUDE_FROM_POS_FILES
Definition: footprint.h:69
@ FP_BOARD_ONLY
Definition: footprint.h:71
@ FP_EXCLUDE_FROM_BOM
Definition: footprint.h:70
@ FP_THROUGH_HOLE
Definition: footprint.h:67
@ FP_ALLOW_SOLDERMASK_BRIDGES
Definition: footprint.h:73
@ FPT_LAYER
@ FPT_TEXT
KIID niluuid(0)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ Edge_Cuts
Definition: layer_ids.h:113
@ User_9
Definition: layer_ids.h:131
@ Margin
Definition: layer_ids.h:114
@ User_1
Definition: layer_ids.h:123
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:926
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition: gtk/ui.cpp:126
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
see class PGM_BASE
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Custom text control validator definitions.
@ THERMAL
Use thermal relief for pads.
@ NONE
Pads are not covered.
@ FULL
pads are covered by copper