KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_footprint_properties.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) 2016 Mario Luzeiro <[email protected]>
5 * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
6 * Copyright (C) 2015 Dick Hollenbeck, [email protected]
7 * Copyright The 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, see <https://www.gnu.org/licenses/>.
21 */
22
24#include <bitmaps.h>
25#include <board_commit.h>
27#include <board.h>
28#include <footprint.h>
29#include <confirm.h>
31#include <filename_resolver.h>
32#include <pcb_edit_frame.h>
33#include <pcbnew_settings.h>
35#include <pgm_base.h>
36#include <project_pcb.h>
37#include <kiplatform/ui.h>
46#include <tool/tool_manager.h>
48
49
50int DIALOG_FOOTPRINT_PROPERTIES::m_page = 0; // remember the last open page during session
51
52
55 m_frame( aParent ),
56 m_footprint( aFootprint ),
64 m_initialized( false )
65{
66 // Create the extra panels. Embedded files is referenced by the 3D model panel.
69
70 m_NoteBook->AddPage( m_3dPanel, _("3D Models"), false );
71 m_NoteBook->AddPage( m_embeddedFiles, _( "Embedded Files" ) );
72
73 // Configure display origin transforms
76
77 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
78 embeddedFilesStack.push_back( m_embeddedFiles->GetLocalFiles() );
79 embeddedFilesStack.push_back( m_frame->GetBoard()->GetEmbeddedFiles() );
80
81 m_fields = new PCB_FIELDS_GRID_TABLE( m_frame, this, std::move( embeddedFilesStack ) );
82
83 m_delayedErrorMessage = wxEmptyString;
84 m_delayedFocusGrid = nullptr;
87 m_initialFocus = false;
88
89 // Give an icon
90 wxIcon icon;
91 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
92 SetIcon( icon );
93
94 m_itemsGrid->SetTable( m_fields );
95 m_itemsGrid->OverrideMinSize( 1.0, 1.0 );
96 m_itemsGrid->PushEventHandler( new GRID_TRICKS( m_itemsGrid ) );
97 m_itemsGrid->SetupColumnAutosizer( PFC_VALUE );
98 m_itemsGrid->ShowHideColumns( "0 1 2 3 4 5 7" );
99
101 m_orientation.SetPrecision( 3 );
102
103 // Set predefined rotations in combo dropdown, according to the locale floating point
104 // separator notation
105 double rot_list[] = { 0.0, 90.0, -90.0, 180.0 };
106
107 for( size_t ii = 0; ii < m_orientationCtrl->GetCount() && ii < 4; ++ii )
108 m_orientationCtrl->SetString( ii, wxString::Format( "%.1f", rot_list[ii] ) );
109
110 // Set font size for items showing long strings:
111 wxFont infoFont = KIUI::GetSmallInfoFont( this );
112 m_libraryIDLabel->SetFont( infoFont );
113 m_tcLibraryID->SetFont( infoFont );
114
115 infoFont = KIUI::GetInfoFont( this ).Italic();
116 m_staticTextInfoCopper->SetFont( infoFont );
117 m_staticTextInfoPaste->SetFont( infoFont );
118
119 m_NoteBook->SetSelection( m_page );
120
121 if( m_page == 0 )
122 {
126 }
127 else if( m_page == 1 )
128 {
130 }
131
132 // Update label text and tooltip for combined offset + ratio field
133 m_SolderPasteMarginLabel->SetLabel( _( "Solder paste clearance:" ) );
134 m_SolderPasteMarginLabel->SetToolTip( _( "Local solder paste clearance for this footprint.\n"
135 "Enter an absolute value (e.g., -0.1mm), a percentage "
136 "(e.g., -5%), or both (e.g., -0.1mm - 5%).\n"
137 "If blank, the global value is used." ) );
138
139 // Configure button logos
142
143 m_tcLibraryID->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
144
145 // We can't set the tab order through wxWidgets due to shortcomings in their mnemonics
146 // implementation on MSW
147 m_tabOrder = {
156 m_cbDNP,
164 };
165
167
168 // The 3D model tab was added after the base dtor. The final dialog size needs to be set
169 // accordingly.
170 SetSizer( m_GeneralBoxSizer );
171 Layout();
172 m_GeneralBoxSizer->Fit( this );
173
175}
176
177
179{
180 // Prevents crash bug in wxGrid's d'tor
181 m_itemsGrid->DestroyTable( m_fields );
182
183 // Delete the GRID_TRICKS.
184 m_itemsGrid->PopEventHandler( true );
185
186 // free the memory used by all models, otherwise models which were
187 // browsed but not used would consume memory
189
190 // the GL canvas has to be visible before it is destroyed
191 m_page = m_NoteBook->GetSelection();
192 m_NoteBook->SetSelection( 1 );
193}
194
195
197{
199 {
201 Close();
202 }
203}
204
205
207{
209 {
211 Close();
212 }
213}
214
215
217{
219 {
221 Close();
222 }
223}
224
225
227{
229 {
231 Close();
232 }
233}
234
235
237{
238 if( !wxDialog::TransferDataToWindow() )
239 return false;
240
241 if( !m_PanelGeneral->TransferDataToWindow() )
242 return false;
243
244 // Add the models to the panel
245 if( !m_3dPanel->TransferDataToWindow() )
246 return false;
247
248 if( !m_embeddedFiles->TransferDataToWindow() )
249 return false;
250
251 wxString variantName;
252
253 if( m_footprint->GetBoard() )
254 variantName = m_footprint->GetBoard()->GetCurrentVariant();
255
256 // Footprint Fields
257 for( PCB_FIELD* srcField : m_footprint->GetFields() )
258 {
259 wxCHECK2( srcField, continue );
260
261 PCB_FIELD field( *srcField );
262 wxString text = m_footprint->GetFieldValueForVariant( variantName, field.GetName() );
263 field.SetText( m_footprint->GetBoard()->ConvertKIIDsToCrossReferences( text ) );
264
265 m_fields->push_back( field );
266 }
267
268 // notify the grid
269 wxGridTableMessage tmsg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->GetNumberRows() );
270 m_itemsGrid->ProcessTableMessage( tmsg );
271
272 // Footprint Properties
273
274 m_posX.SetValue( m_footprint->GetPosition().x );
275 m_posY.SetValue( m_footprint->GetPosition().y );
276
277 m_BoardSideCtrl->SetSelection( (m_footprint->GetLayer() == B_Cu) ? 1 : 0 );
278
279 EDA_ANGLE orientation = m_footprint->GetOrientation();
280 m_orientation.SetAngleValue( orientation.Normalize180() );
281
282 m_cbLocked->SetValue( m_footprint->IsLocked() );
283 m_cbLocked->SetToolTip( _( "Locked footprints cannot be freely moved or oriented on the canvas and can only be "
284 "selected when the 'Locked items' checkbox is checked in the selection filter." ) );
285
286 if( m_footprint->GetAttributes() & FP_THROUGH_HOLE )
287 m_componentType->SetSelection( 0 );
288 else if( m_footprint->GetAttributes() & FP_SMD )
289 m_componentType->SetSelection( 1 );
290 else
291 m_componentType->SetSelection( 2 );
292
293 m_boardOnly->SetValue( m_footprint->GetAttributes() & FP_BOARD_ONLY );
294
295 m_excludeFromPosFiles->SetValue( m_footprint->GetExcludedFromPosFilesForVariant( variantName ) );
296 m_excludeFromBOM->SetValue( m_footprint->GetExcludedFromBOMForVariant( variantName ) );
297 m_cbDNP->SetValue( m_footprint->GetDNPForVariant( variantName ) );
298
299 // Local Clearances
300
301 if( m_footprint->GetLocalClearance().has_value() )
302 m_netClearance.SetValue( m_footprint->GetLocalClearance().value() );
303 else
304 m_netClearance.SetValue( wxEmptyString );
305
306 if( m_footprint->GetLocalSolderMaskMargin().has_value() )
307 m_solderMask.SetValue( m_footprint->GetLocalSolderMaskMargin().value() );
308 else
309 m_solderMask.SetValue( wxEmptyString );
310
311 m_solderPaste.SetOffsetValue( m_footprint->GetLocalSolderPasteMargin() );
312 m_solderPaste.SetRatioValue( m_footprint->GetLocalSolderPasteMarginRatio() );
313
314 m_allowSolderMaskBridges->SetValue( m_footprint->AllowSolderMaskBridges() );
315
316 switch( m_footprint->GetLocalZoneConnection() )
317 {
318 default:
319 case ZONE_CONNECTION::INHERITED: m_ZoneConnectionChoice->SetSelection( 0 ); break;
320 case ZONE_CONNECTION::FULL: m_ZoneConnectionChoice->SetSelection( 1 ); break;
321 case ZONE_CONNECTION::THERMAL: m_ZoneConnectionChoice->SetSelection( 2 ); break;
322 case ZONE_CONNECTION::NONE: m_ZoneConnectionChoice->SetSelection( 3 ); break;
323 }
324
325 wxString jumperGroups;
326
327 if( m_footprint->GetDuplicatePadNumbersAreJumpers() )
328 jumperGroups = _( "all pads with duplicate numbers" );
329
330 for( const std::set<wxString>& group : m_footprint->JumperPadGroups() )
331 {
332 wxString groupTxt;
333
334 for( const wxString& pinNumber : group )
335 {
336 if( !groupTxt.IsEmpty() )
337 groupTxt << ", ";
338
339 groupTxt << pinNumber;
340 }
341
342 if( !jumperGroups.IsEmpty() )
343 jumperGroups << "; ";
344
345 jumperGroups << "(" << groupTxt << ")";
346 }
347
348 if( jumperGroups.IsEmpty() )
349 {
350 m_jumperGroupsText->SetLabel( _( "none" ) );
352 }
353 else
354 {
355 m_jumperGroupsText->SetLabel( jumperGroups );
356 }
357
358 // Show the footprint's FPID.
359 m_tcLibraryID->SetValue( m_footprint->GetFPID().Format() );
360
361 for( int col = 0; col < m_itemsGrid->GetNumberCols(); col++ )
362 {
363 m_itemsGrid->SetColMinimalWidth( col, m_itemsGrid->GetVisibleWidth( col, true, false ) );
364
365 // Adjust the column size.
366 int col_size = m_itemsGrid->GetVisibleWidth( col );
367
368 if( col == PFC_LAYER ) // This one's a drop-down. Check all possible values.
369 {
370 BOARD* board = m_footprint->GetBoard();
371
372 for( PCB_LAYER_ID layer : board->GetEnabledLayers() )
373 col_size = std::max( col_size, GetTextExtent( board->GetLayerName( layer ) ).x );
374
375 // Swatch and gaps:
376 col_size += KiROUND( 14 * GetDPIScaleFactor() ) + 12;
377 }
378
379 if( m_itemsGrid->IsColShown( col ) )
380 m_itemsGrid->SetColSize( col, col_size );
381 }
382
383 m_itemsGrid->SetRowLabelSize( 0 );
384
385 Layout();
386 m_itemsGrid->SetMinVisibleRows( this, 4 );
387 m_initialized = true;
388
389 return true;
390}
391
392
394{
395 if( !m_itemsGrid->CommitPendingChanges() )
396 return false;
397
398 if( !DIALOG_SHIM::Validate() )
399 return false;
400
401 // Validate texts.
402 for( size_t i = 0; i < m_fields->size(); ++i )
403 {
404 PCB_FIELD& field = m_fields->at( i );
405
406 // Check for missing field names.
407 if( field.GetName( false ).IsEmpty() )
408 {
410 m_delayedErrorMessage = wxString::Format( _( "Fields must have a name." ) );
413
414 return false;
415 }
416
417 int minSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
418 int maxSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
419 int width = m_frame->ValueFromString( m_itemsGrid->GetCellValue( i, PFC_WIDTH ) );
420 int height = m_frame->ValueFromString( m_itemsGrid->GetCellValue( i, PFC_HEIGHT ) );
421
422 if( width < minSize )
423 {
424 wxString min = m_frame->StringFromValue( minSize, true );
425
426 m_itemsGrid->SetCellValue( i, PFC_WIDTH, min );
427
429 m_delayedErrorMessage = wxString::Format( _( "Text width must be at least %s." ), min );
432
433 return false;
434 }
435 else if( width > maxSize )
436 {
437 wxString max = m_frame->StringFromValue( maxSize, true );
438
439 m_itemsGrid->SetCellValue( i, PFC_WIDTH, max );
440
442 m_delayedErrorMessage = wxString::Format( _( "Text width must be at most %s." ), max );
445
446 return false;
447 }
448
449 if( height < minSize )
450 {
451 wxString min = m_frame->StringFromValue( minSize, true );
452
453 m_itemsGrid->SetCellValue( i, PFC_HEIGHT, min );
454
456 m_delayedErrorMessage = wxString::Format( _( "Text height must be at least %s." ), min );
459
460 return false;
461 }
462 else if( height > maxSize )
463 {
464 wxString max = m_frame->StringFromValue( maxSize, true );
465
466 m_itemsGrid->SetCellValue( i, PFC_HEIGHT, max );
467
469 m_delayedErrorMessage = wxString::Format( _( "Text height must be at most %s." ), max );
472
473 return false;
474 }
475
476 // Test for acceptable values for thickness and size and clamp if fails
477 int maxPenWidth = ClampTextPenSize( field.GetTextThickness(), field.GetTextSize() );
478
479 if( field.GetTextThickness() > maxPenWidth )
480 {
481 wxString clamped = m_frame->StringFromValue( maxPenWidth, true );
482
483 m_itemsGrid->SetCellValue( i, PFC_THICKNESS, clamped );
484
486 m_delayedErrorMessage = wxString::Format( _( "Text thickness is too large for the text size.\n"
487 "It will be clamped at %s." ),
488 clamped );
491
492 return false;
493 }
494 }
495
496 if( !m_netClearance.Validate( 0, INT_MAX ) )
497 return false;
498
499 return true;
500}
501
502
504{
505 if( !Validate() )
506 return false;
507
508 if( !m_itemsGrid->CommitPendingChanges() )
509 return false;
510
511 KIGFX::PCB_VIEW* view = m_frame->GetCanvas()->GetView();
512 PCB_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
513 BOARD_COMMIT commit( m_frame );
514 commit.Modify( m_footprint );
515
516 // Make sure this happens inside a commit to capture any changed files
517 if( !m_3dPanel->TransferDataFromWindow() )
518 return false;
519
520 if( !m_embeddedFiles->TransferDataFromWindow() )
521 return false;
522
523 // Clear out embedded files that are no longer in use
524 std::set<wxString> files;
525 std::set<wxString> files_to_delete;
526
527 // Get the new files from the footprint fields
528 for( PCB_FIELD& field : *m_fields )
529 {
530 if( field.GetText().StartsWith( FILEEXT::KiCadUriPrefix ) )
531 files.insert( field.GetText() );
532 }
533
534 // Find any files referenced in the old fields that are not in the new fields
535 for( PCB_FIELD* field : m_footprint->GetFields() )
536 {
537 wxCHECK2( field, continue );
538
539 if( field->GetText().StartsWith( FILEEXT::KiCadUriPrefix ) )
540 {
541 if( files.find( field->GetText() ) == files.end() )
542 files_to_delete.insert( field->GetText() );
543 }
544 }
545
546 for( const wxString& file : files_to_delete )
547 {
548 wxString name = file.Mid( FILEEXT::KiCadUriPrefix.size() + 3 ); // Skip "kicad-embed://"
549 m_footprint->RemoveFile( name );
550 }
551
552 // Update fields
553 BOARD* board = m_footprint->GetBoard();
554
555 wxString variantName;
556
557 if( board )
558 variantName = board->GetCurrentVariant();
559
560 // Save base field values before deletion so we can detect variant changes
561 std::map<wxString, wxString> baseFieldValues;
562
563 for( PCB_FIELD* existing : m_footprint->GetFields() )
564 baseFieldValues[existing->GetName()] = existing->GetText();
565
566 for( PCB_FIELD* existing : m_footprint->GetFields() )
567 {
568 if( board )
569 board->UncacheItemById( existing->m_Uuid );
570
571 delete existing;
572 }
573
574 m_footprint->GetFields().clear();
575
576 int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
577
578 for( PCB_FIELD& field : *m_fields )
579 {
580 PCB_FIELD* newField = field.CloneField();
581 wxString newText = commit.GetBoard()->ConvertCrossReferencesToKIIDs( field.GetText() );
582
583 if( !variantName.IsEmpty() )
584 {
585 auto it = baseFieldValues.find( field.GetName() );
586 wxString baseText = ( it != baseFieldValues.end() ) ? it->second : wxString();
587
588 FOOTPRINT_VARIANT* variant = m_footprint->GetVariant( variantName );
589
590 if( !variant )
591 variant = m_footprint->AddVariant( variantName );
592
593 if( variant )
594 variant->SetFieldValue( field.GetName(), newText );
595
596 newField->SetText( baseText );
597 }
598 else
599 {
600 newField->SetText( newText );
601 }
602
603 if( !field.IsMandatory() )
604 newField->SetOrdinal( ordinal++ );
605
606 m_footprint->Add( newField );
607 view->Add( newField );
608
609 if( newField->IsSelected() )
610 {
611 // The old copy was in the selection list, but this one is not. Remove the
612 // out-of-sync selection flag so we can re-add the field to the selection.
613 newField->ClearSelected();
614 selectionTool->AddItemToSel( newField, true );
615 }
616 }
617
618 // Initialize masks clearances
619 if( m_netClearance.IsNull() )
620 m_footprint->SetLocalClearance( {} );
621 else
622 m_footprint->SetLocalClearance( m_netClearance.GetValue() );
623
624 if( m_solderMask.IsNull() )
625 m_footprint->SetLocalSolderMaskMargin( {} );
626 else
627 m_footprint->SetLocalSolderMaskMargin( m_solderMask.GetValue() );
628
629 m_footprint->SetLocalSolderPasteMargin( m_solderPaste.GetOffsetValue() );
630 m_footprint->SetLocalSolderPasteMarginRatio( m_solderPaste.GetRatioValue() );
631
632 switch( m_ZoneConnectionChoice->GetSelection() )
633 {
634 default:
635 case 0: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::INHERITED ); break;
636 case 1: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::FULL ); break;
637 case 2: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::THERMAL ); break;
638 case 3: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::NONE ); break;
639 }
640
641 // Set Footprint Position
642 VECTOR2I pos( m_posX.GetValue(), m_posY.GetValue() );
643 m_footprint->SetPosition( pos );
644 m_footprint->SetLocked( m_cbLocked->GetValue() );
645
646 int attributes = 0;
647
648 switch( m_componentType->GetSelection() )
649 {
650 case 0: attributes |= FP_THROUGH_HOLE; break;
651 case 1: attributes |= FP_SMD; break;
652 default: break;
653 }
654
655 if( m_boardOnly->GetValue() )
656 attributes |= FP_BOARD_ONLY;
657
658 if( !variantName.IsEmpty() )
659 {
660 FOOTPRINT_VARIANT* variant = m_footprint->GetVariant( variantName );
661
662 if( !variant )
663 variant = m_footprint->AddVariant( variantName );
664
665 if( variant )
666 {
667 variant->SetExcludedFromPosFiles( m_excludeFromPosFiles->GetValue() );
668 variant->SetExcludedFromBOM( m_excludeFromBOM->GetValue() );
669 variant->SetDNP( m_cbDNP->GetValue() );
670 }
671
672 // Preserve base attribute flags for these three properties
673 if( m_footprint->GetAttributes() & FP_EXCLUDE_FROM_POS_FILES )
674 attributes |= FP_EXCLUDE_FROM_POS_FILES;
675
676 if( m_footprint->GetAttributes() & FP_EXCLUDE_FROM_BOM )
677 attributes |= FP_EXCLUDE_FROM_BOM;
678
679 if( m_footprint->GetAttributes() & FP_DNP )
680 attributes |= FP_DNP;
681 }
682 else
683 {
684 if( m_excludeFromPosFiles->GetValue() )
685 attributes |= FP_EXCLUDE_FROM_POS_FILES;
686
687 if( m_excludeFromBOM->GetValue() )
688 attributes |= FP_EXCLUDE_FROM_BOM;
689
690 if( m_cbDNP->GetValue() )
691 attributes |= FP_DNP;
692 }
693
694 m_footprint->SetAttributes( attributes );
695
696 m_footprint->SetAllowSolderMaskBridges( m_allowSolderMaskBridges->GetValue() );
697
698 EDA_ANGLE orient = m_orientation.GetAngleValue().Normalize();
699
700 if( m_footprint->GetOrientation() != orient )
701 m_footprint->Rotate( m_footprint->GetPosition(), orient - m_footprint->GetOrientation() );
702
703 // Set component side, that also have effect on the fields positions on board
704 bool change_layer = false;
705
706 if( m_BoardSideCtrl->GetSelection() == 0 ) // layer req = COMPONENT
707 {
708 if( m_footprint->GetLayer() == B_Cu )
709 change_layer = true;
710 }
711 else if( m_footprint->GetLayer() == F_Cu )
712 {
713 change_layer = true;
714 }
715
716 if( change_layer )
717 m_footprint->Flip( m_footprint->GetPosition(), m_frame->GetPcbNewSettings()->m_FlipDirection );
718
719 // Copy the models from the panel to the footprint
720 std::vector<FP_3DMODEL>& panelList = m_3dPanel->GetModelList();
721 std::vector<FP_3DMODEL>* fpList = &m_footprint->Models();
722 fpList->clear();
723 fpList->insert( fpList->end(), panelList.begin(), panelList.end() );
724
725 // This is a simple edit, we must create an undo entry
726 if( m_footprint->GetEditFlags() == 0 ) // i.e. not edited, or moved
727 commit.Push( _( "Edit Footprint Properties" ) );
728
730 return true;
731}
732
733
735{
736 m_itemsGrid->OnAddRow(
737 [&]() -> std::pair<int, int>
738 {
740
741 newField.SetVisible( false );
742 newField.SetLayer( m_footprint->GetLayer() == F_Cu ? F_Fab : B_Fab );
743 newField.SetFPRelativePosition( { 0, 0 } );
744 newField.StyleFromSettings( m_frame->GetDesignSettings(), true );
745
746 m_fields->push_back( newField );
747
748 // notify the grid
749 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
750 m_itemsGrid->ProcessTableMessage( msg );
751 OnModify();
752
753 return { m_fields->size() - 1, PFC_NAME };
754 } );
755}
756
757
759{
760 m_itemsGrid->OnDeleteRows(
761 [&]( int row )
762 {
763 if( row < m_fields->GetMandatoryRowCount() )
764 {
765 DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
766 m_fields->GetMandatoryRowCount() ) );
767 return false;
768 }
769
770 return true;
771 },
772 [&]( int row )
773 {
774 m_fields->erase( m_fields->begin() + row );
775
776 // notify the grid
777 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
778 m_itemsGrid->ProcessTableMessage( msg );
779 } );
780
781 OnModify();
782}
783
784
786{
787 if( !m_initialized )
788 return;
789
790 // Handle a grid error. This is delayed to OnUpdateUI so that we can change focus
791 // even when the original validation was triggered from a killFocus event, and so
792 // that the corresponding notebook page can be shown in the background when triggered
793 // from an OK.
794 if( m_delayedFocusRow >= 0 )
795 {
796 // We will re-enter this routine if an error dialog is displayed, so make sure we
797 // zero out our member variables first.
798 wxGrid* grid = m_delayedFocusGrid;
799 int row = m_delayedFocusRow;
800 int col = m_delayedFocusColumn;
801 wxString msg = m_delayedErrorMessage;
802
803 m_delayedFocusGrid = nullptr;
806 m_delayedErrorMessage = wxEmptyString;
807
808 if( !msg.IsEmpty() )
809 {
810 // Do not use DisplayErrorMessage(); it screws up window order on Mac
811 DisplayError( nullptr, msg );
812 }
813
814 grid->SetFocus();
815 grid->MakeCellVisible( row, col );
816
817 // Selecting the first grid item only makes sense for the
818 // items grid
819 if( !m_initialFocus || grid == m_itemsGrid )
820 {
821 grid->SetGridCursor( row, col );
822
823 if( !( col == 0 && row < m_fields->GetMandatoryRowCount() ) )
824 grid->EnableCellEditControl( true );
825
826 grid->ShowCellEditControl();
827
828 if( grid == m_itemsGrid && row == 0 && col == 0 )
829 {
830 wxGridCellEditor* referenceEditor = grid->GetCellEditor( 0, 0 );
831
832 if( wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( referenceEditor->GetControl() ) )
833 KIUI::SelectReferenceNumber( textEntry );
834
835 referenceEditor->DecRef();
836 }
837 }
838
839 m_initialFocus = false;
840 }
841}
842
843
844void DIALOG_FOOTPRINT_PROPERTIES::OnPageChanging( wxNotebookEvent& aEvent )
845{
846 if( !m_itemsGrid->CommitPendingChanges() )
847 aEvent.Veto();
848}
849
850
851void DIALOG_FOOTPRINT_PROPERTIES::OnCheckBox( wxCommandEvent& event )
852{
853 if( m_initialized )
854 OnModify();
855}
856
857
858void DIALOG_FOOTPRINT_PROPERTIES::OnCombobox( wxCommandEvent& event )
859{
860 if( m_initialized )
861 OnModify();
862}
863
864
865void DIALOG_FOOTPRINT_PROPERTIES::OnText( wxCommandEvent& event )
866{
867 if( m_initialized )
868 OnModify();
869}
870
871
872void DIALOG_FOOTPRINT_PROPERTIES::OnChoice( wxCommandEvent& event )
873{
874 if( m_initialized )
875 OnModify();
876}
const char * name
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
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:100
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:986
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:313
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
void SetFPRelativePosition(const VECTOR2I &aPos)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:373
void UncacheItemById(const KIID &aId) const
Remove an item from the item-by-id cache.
Definition board.cpp:2066
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
Definition board.cpp:2280
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition board.cpp:793
wxString GetCurrentVariant() const
Definition board.h:469
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition board.cpp:1034
DIALOG_FOOTPRINT_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Footprint Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void OnDeleteField(wxCommandEvent &) override
void OnUpdateUI(wxUpdateUIEvent &) override
void OnAddField(wxCommandEvent &) override
void OnText(wxCommandEvent &event) override
void OnCombobox(wxCommandEvent &event) override
PANEL_FP_PROPERTIES_3D_MODEL * m_3dPanel
void OnPageChanging(wxNotebookEvent &event) override
void EditLibraryFootprint(wxCommandEvent &) override
DIALOG_FOOTPRINT_PROPERTIES(PCB_EDIT_FRAME *aParent, FOOTPRINT *aFootprint)
void OnChoice(wxCommandEvent &event) override
void EditFootprint(wxCommandEvent &) override
void OnCheckBox(wxCommandEvent &event) override
void UpdateFootprint(wxCommandEvent &) override
void ChangeFootprint(wxCommandEvent &) override
std::vector< wxWindow * > m_tabOrder
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition dialog_shim.h:79
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...
EDA_ANGLE Normalize180()
Definition eda_angle.h:268
void ClearSelected()
Definition eda_item.h:147
bool IsSelected() const
Definition eda_item.h:132
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:381
virtual void SetText(const wxString &aText)
Definition eda_text.cpp:265
Variant information for a footprint.
Definition footprint.h:215
void SetExcludedFromPosFiles(bool aExclude)
Definition footprint.h:235
void SetDNP(bool aDNP)
Definition footprint.h:229
void SetFieldValue(const wxString &aFieldName, const wxString &aValue)
Set a field value override for this variant.
Definition footprint.h:257
void SetExcludedFromBOM(bool aExclude)
Definition footprint.h:232
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition grid_tricks.h:57
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition pcb_view.cpp:53
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
The main frame for Pcbnew.
void SetOrdinal(int aOrdinal)
Definition pcb_field.h:116
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
PCB_FIELD * CloneField() const
Same as Clone, but returns a PCB_FIELD item.
Definition pcb_field.h:90
The selection tool: currently supports:
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings, bool aCheckSide) override
Definition pcb_text.cpp:354
int GetTextThickness() const override
Definition pcb_text.cpp:480
VECTOR2I GetTextSize() const override
Definition pcb_text.cpp:453
static S3D_CACHE * Get3DCacheManager(PROJECT *aProject, bool updateProjDir=false)
Return a pointer to an instance of the 3D cache manager.
void FlushCache(bool closePlugins=true)
Free all data in the cache and by default closes all plugins.
Definition 3d_cache.cpp:553
int AddItemToSel(const TOOL_EVENT &aEvent)
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:192
This file is part of the common library.
const int minSize
Push and Shove router track width and via size dialog.
#define _(s)
Declaration of the eda_3d_viewer class.
#define TEXT_MIN_SIZE_MM
Minimum text size (1 micron).
Definition eda_text.h:56
#define TEXT_MAX_SIZE_MM
Maximum text size in mm (~10 inches)
Definition eda_text.h:57
@ FP_SMD
Definition footprint.h:84
@ FP_DNP
Definition footprint.h:89
@ FP_EXCLUDE_FROM_POS_FILES
Definition footprint.h:85
@ FP_BOARD_ONLY
Definition footprint.h:87
@ FP_EXCLUDE_FROM_BOM
Definition footprint.h:86
@ FP_THROUGH_HOLE
Definition footprint.h:83
int ClampTextPenSize(int aPenSize, int aSize, bool aStrict)
Pen width should not allow characters to become cluttered up in their own fatness.
Definition gr_text.cpp:69
static const std::string KiCadUriPrefix
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ B_Cu
Definition layer_ids.h:61
@ F_Fab
Definition layer_ids.h:115
@ F_Cu
Definition layer_ids.h:60
@ B_Fab
Definition layer_ids.h:114
wxColour GetDialogBGColour()
Definition wxgtk/ui.cpp:63
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
KICOMMON_API wxFont GetControlFont(wxWindow *aWindow)
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
@ PFC_THICKNESS
see class PGM_BASE
wxString GetUserFieldName(int aFieldNdx, bool aTranslateForHI)
#define DO_TRANSLATE
@ USER
The field ID hasn't been set yet; field is invalid.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
@ THERMAL
Use thermal relief for pads.
Definition zones.h:46
@ NONE
Pads are not covered.
Definition zones.h:45
@ FULL
pads are covered by copper
Definition zones.h:47