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, 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
28#include <bitmaps.h>
29#include <board_commit.h>
31#include <board.h>
32#include <footprint.h>
33#include <confirm.h>
35#include <filename_resolver.h>
36#include <pcb_edit_frame.h>
37#include <pcbnew_settings.h>
38#include <pgm_base.h>
39#include <project_pcb.h>
40#include <kiplatform/ui.h>
49#include <tool/tool_manager.h>
51
52
53int DIALOG_FOOTPRINT_PROPERTIES::m_page = 0; // remember the last open page during session
54
55
57 FOOTPRINT* aFootprint ) :
59 m_frame( aParent ),
60 m_footprint( aFootprint ),
61 m_posX( aParent, m_XPosLabel, m_ModPositionX, m_XPosUnit ),
62 m_posY( aParent, m_YPosLabel, m_ModPositionY, m_YPosUnit ),
63 m_orientation( aParent, m_orientationLabel, m_orientationCtrl, nullptr ),
64 m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits ),
65 m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl,
66 m_SolderMaskMarginUnits ),
67 m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl,
68 m_SolderPasteMarginUnits ),
69 m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl,
70 m_PasteMarginRatioUnits ),
71 m_returnValue( FP_PROPS_CANCEL ),
72 m_initialized( false ),
73 m_gridSize( 0, 0 ),
74 m_lastRequestedSize( 0, 0 )
75{
76 // Create the extra panels. Embedded files is referenced by the 3D model panel.
79
80 m_NoteBook->AddPage( m_3dPanel, _("3D Models"), false );
81 m_NoteBook->AddPage( m_embeddedFiles, _( "Embedded Files" ) );
82
83 // Configure display origin transforms
86
87 std::vector<EMBEDDED_FILES*> embeddedFilesStack;
88 embeddedFilesStack.push_back( m_embeddedFiles->GetLocalFiles() );
89 embeddedFilesStack.push_back( m_frame->GetBoard()->GetEmbeddedFiles() );
90
91 m_fields = new PCB_FIELDS_GRID_TABLE( m_frame, this, embeddedFilesStack );
92
93 m_delayedErrorMessage = wxEmptyString;
94 m_delayedFocusGrid = nullptr;
97 m_initialFocus = false;
98
99 // Give an icon
100 wxIcon icon;
101 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
102 SetIcon( icon );
103
104 // Give a bit more room for combobox editors
105 m_itemsGrid->SetDefaultRowSize( m_itemsGrid->GetDefaultRowSize() + 4 );
106
108 m_itemsGrid->PushEventHandler( new GRID_TRICKS( m_itemsGrid ) );
109
110 // Show/hide text item columns according to the user's preference
112 m_itemsGrid->ShowHideColumns( cfg->m_FootprintTextShownColumns );
113
114 m_orientation.SetUnits( EDA_UNITS::DEGREES );
116
117 // Set predefined rotations in combo dropdown, according to the locale floating point
118 // separator notation
119 double rot_list[] = { 0.0, 90.0, -90.0, 180.0 };
120
121 for( size_t ii = 0; ii < m_orientationCtrl->GetCount() && ii < 4; ++ii )
122 m_orientationCtrl->SetString( ii, wxString::Format( "%.1f", rot_list[ii] ) );
123
124 // Set font size for items showing long strings:
125 wxFont infoFont = KIUI::GetSmallInfoFont( this );
126 m_libraryIDLabel->SetFont( infoFont );
127 m_tcLibraryID->SetFont( infoFont );
128
129 infoFont = KIUI::GetInfoFont( this ).Italic();
130 m_staticTextInfoCopper->SetFont( infoFont );
131 m_staticTextInfoPaste->SetFont( infoFont );
132
133 m_NoteBook->SetSelection( m_page );
134
135 if( m_page == 0 )
136 {
140 }
141 else if( m_page == 1 )
142 {
144 }
145
147
148 m_solderPasteRatio.SetUnits( EDA_UNITS::PERCENT );
150
151 // Configure button logos
152 m_bpAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
153 m_bpDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
154
155 m_tcLibraryID->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
156
157 // We can't set the tab order through wxWidgets due to shortcomings in their mnemonics
158 // implementation on MSW
159 m_tabOrder = {
171 m_cbDNP,
178 };
179
181
182 // The 3D model tab was added after the base dtor. The final dialog size needs to be set
183 // accordingly.
184 SetSizer( m_GeneralBoxSizer );
185 Layout();
186 m_GeneralBoxSizer->Fit( this );
187
189}
190
191
193{
194 PCBNEW_SETTINGS* cfg = nullptr;
195
196 try
197 {
198 cfg = m_frame->GetPcbNewSettings();
199 }
200 catch( const std::runtime_error& e )
201 {
202 wxFAIL_MSG( e.what() );
203 }
204
205 if( cfg )
206 {
208 }
209
210 // Prevents crash bug in wxGrid's d'tor
212
213 // Delete the GRID_TRICKS.
214 m_itemsGrid->PopEventHandler( true );
215
216 // free the memory used by all models, otherwise models which were
217 // browsed but not used would consume memory
219
220 // the GL canvas has to be visible before it is destroyed
221 m_page = m_NoteBook->GetSelection();
222 m_NoteBook->SetSelection( 1 );
223}
224
225
227{
229 {
231 Close();
232 }
233}
234
235
237{
239 {
241 Close();
242 }
243}
244
245
247{
249 {
251 Close();
252 }
253}
254
255
257{
259 {
261 Close();
262 }
263}
264
265
267{
268 if( !wxDialog::TransferDataToWindow() )
269 return false;
270
271 if( !m_PanelGeneral->TransferDataToWindow() )
272 return false;
273
274 // Add the models to the panel
276 return false;
277
279 return false;
280
281 // Footprint Fields
282 for( PCB_FIELD* srcField : m_footprint->GetFields() )
283 {
284 PCB_FIELD field( *srcField );
286
287 m_fields->push_back( field );
288 }
289
290 // notify the grid
291 wxGridTableMessage tmsg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
293 m_itemsGrid->ProcessTableMessage( tmsg );
294
295 // Footprint Properties
296
299
300 m_BoardSideCtrl->SetSelection( (m_footprint->GetLayer() == B_Cu) ? 1 : 0 );
301
302 EDA_ANGLE orientation = m_footprint->GetOrientation();
304
305 m_cbLocked->SetValue( m_footprint->IsLocked() );
306 m_cbLocked->SetToolTip( _( "Locked footprints cannot be freely moved and oriented on the "
307 "canvas and can only be selected when the 'Locked items' checkbox "
308 "is checked in the selection filter." ) );
309
311 m_componentType->SetSelection( 0 );
312 else if( m_footprint->GetAttributes() & FP_SMD )
313 m_componentType->SetSelection( 1 );
314 else
315 m_componentType->SetSelection( 2 );
316
321 m_cbDNP->SetValue( m_footprint->GetAttributes() & FP_DNP );
322
323 // Local Clearances
324
325 if( m_footprint->GetLocalClearance().has_value() )
327 else
328 m_netClearance.SetValue( wxEmptyString );
329
330 if( m_footprint->GetLocalSolderMaskMargin().has_value() )
332 else
333 m_solderMask.SetValue( wxEmptyString );
334
335 if( m_footprint->GetLocalSolderPasteMargin().has_value() )
337 else
338 m_solderPaste.SetValue( wxEmptyString );
339
342 else
343 m_solderPasteRatio.SetValue( wxEmptyString );
344
346
348 {
349 default:
350 case ZONE_CONNECTION::INHERITED: m_ZoneConnectionChoice->SetSelection( 0 ); break;
351 case ZONE_CONNECTION::FULL: m_ZoneConnectionChoice->SetSelection( 1 ); break;
352 case ZONE_CONNECTION::THERMAL: m_ZoneConnectionChoice->SetSelection( 2 ); break;
353 case ZONE_CONNECTION::NONE: m_ZoneConnectionChoice->SetSelection( 3 ); break;
354 }
355
356 // Show the footprint's FPID.
357 m_tcLibraryID->SetValue( m_footprint->GetFPID().Format() );
358
359 for( int col = 0; col < m_itemsGrid->GetNumberCols(); col++ )
360 {
361 m_itemsGrid->SetColMinimalWidth( col, m_itemsGrid->GetVisibleWidth( col, true, false ) );
362
363 // Adjust the column size.
364 int col_size = m_itemsGrid->GetVisibleWidth( col );
365
366 if( col == PFC_LAYER ) // This one's a drop-down. Check all possible values.
367 {
368 BOARD* board = m_footprint->GetBoard();
369
370 for( PCB_LAYER_ID layer : board->GetEnabledLayers().Seq() )
371 col_size = std::max( col_size, GetTextExtent( board->GetLayerName( layer ) ).x );
372
373 // Swatch and gaps:
374 col_size += KiROUND( 14 * GetDPIScaleFactor() ) + 12;
375 }
376
377 if( m_itemsGrid->IsColShown( col ) )
378 m_itemsGrid->SetColSize( col, col_size );
379 }
380
381 m_itemsGrid->SetRowLabelSize( 0 );
382
383 Layout();
385 m_initialized = true;
386
387 return true;
388}
389
390
392{
394 return false;
395
396 if( !DIALOG_SHIM::Validate() )
397 return false;
398
399 // Validate texts.
400 for( size_t i = 0; i < m_fields->size(); ++i )
401 {
402 PCB_FIELD& field = m_fields->at( i );
403
404 // Check for missing field names.
405 if( field.GetName( false ).IsEmpty() )
406 {
408 m_delayedErrorMessage = wxString::Format( _( "Fields must have a name." ) );
411
412 return false;
413 }
414
416 int maxSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
417 int width = m_frame->ValueFromString( m_itemsGrid->GetCellValue( i, PFC_WIDTH ) );
418 int height = m_frame->ValueFromString( m_itemsGrid->GetCellValue( i, PFC_HEIGHT ) );
419
420 if( width < minSize )
421 {
422 wxString min = m_frame->StringFromValue( minSize, true );
423
424 m_itemsGrid->SetCellValue( i, PFC_WIDTH, min );
425
427 m_delayedErrorMessage = wxString::Format( _( "Text width must be at least %s." ), min );
430
431 return false;
432 }
433 else if( width > maxSize )
434 {
435 wxString max = m_frame->StringFromValue( maxSize, true );
436
437 m_itemsGrid->SetCellValue( i, PFC_WIDTH, max );
438
440 m_delayedErrorMessage = wxString::Format( _( "Text width must be at most %s." ), max );
443
444 return false;
445 }
446
447 if( height < minSize )
448 {
449 wxString min = m_frame->StringFromValue( minSize, true );
450
451 m_itemsGrid->SetCellValue( i, PFC_HEIGHT, min );
452
454 m_delayedErrorMessage = wxString::Format( _( "Text height must be at least %s." ), min );
457
458 return false;
459 }
460 else if( height > maxSize )
461 {
462 wxString max = m_frame->StringFromValue( maxSize, true );
463
464 m_itemsGrid->SetCellValue( i, PFC_HEIGHT, max );
465
467 m_delayedErrorMessage = wxString::Format( _( "Text height must be at most %s." ), max );
470
471 return false;
472 }
473
474 // Test for acceptable values for thickness and size and clamp if fails
475 int maxPenWidth = ClampTextPenSize( field.GetTextThickness(), field.GetTextSize() );
476
477 if( field.GetTextThickness() > maxPenWidth )
478 {
479 wxString clamped = m_frame->StringFromValue( maxPenWidth, true );
480
481 m_itemsGrid->SetCellValue( i, PFC_THICKNESS, clamped );
482
484 m_delayedErrorMessage = wxString::Format( _( "Text thickness is too large for the "
485 "text size.\n"
486 "It will be clamped at %s." ),
487 clamped );
490
491 return false;
492 }
493 }
494
495 if( !m_netClearance.Validate( 0, INT_MAX ) )
496 return false;
497
498 return true;
499}
500
501
503{
504 if( !Validate() )
505 return false;
506
508 return false;
509
512 BOARD_COMMIT commit( m_frame );
513 commit.Modify( m_footprint );
514
515 // Make sure this happens inside a commit to capture any changed files
517 return false;
518
520 return false;
521
522 // Clear out embedded files that are no longer in use
523 std::set<wxString> files;
524 std::set<wxString> files_to_delete;
525
526 // Get the new files from the footprint fields
527 for( PCB_FIELD& field : *m_fields )
528 {
529 if( field.GetText().StartsWith( FILEEXT::KiCadUriPrefix ) )
530 files.insert( field.GetText() );
531 }
532
533 // Find any files referenced in the old fields that are not in the new fields
534 for( PCB_FIELD* field : m_footprint->GetFields() )
535 {
536 if( field->GetText().StartsWith( FILEEXT::KiCadUriPrefix ) )
537 {
538 if( files.find( field->GetText() ) == files.end() )
539 files_to_delete.insert( field->GetText() );
540 }
541 }
542
543 for( const wxString& file : files_to_delete )
544 {
545 wxString name = file.Mid( FILEEXT::KiCadUriPrefix.size() + 3 ); // Skip "kicad-embed://"
547 }
548
549 // Update fields
550 for( PCB_FIELD* existing : m_footprint->GetFields() )
551 delete existing;
552
553 m_footprint->GetFields().clear();
554
555 int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
556
557 for( PCB_FIELD& field : *m_fields )
558 {
559 PCB_FIELD* newField = field.CloneField();
560 newField->SetText( commit.GetBoard()->ConvertCrossReferencesToKIIDs( field.GetText() ) );
561
562 if( !field.IsMandatory() )
563 newField->SetOrdinal( ordinal++ );
564
565 m_footprint->Add( newField );
566 view->Add( newField );
567
568 if( newField->IsSelected() )
569 {
570 // The old copy was in the selection list, but this one is not. Remove the
571 // out-of-sync selection flag so we can re-add the field to the selection.
572 newField->ClearSelected();
573 selectionTool->AddItemToSel( newField, true );
574 }
575 }
576
577 // Initialize masks clearances
578 if( m_netClearance.IsNull() )
580 else
582
583 if( m_solderMask.IsNull() )
585 else
587
588 if( m_solderPaste.IsNull() )
590 else
592
595 else
597
598 switch( m_ZoneConnectionChoice->GetSelection() )
599 {
600 default:
601 case 0: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::INHERITED ); break;
602 case 1: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::FULL ); break;
603 case 2: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::THERMAL ); break;
604 case 3: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::NONE ); break;
605 }
606
607 // Set Footprint Position
609 m_footprint->SetPosition( pos );
610 m_footprint->SetLocked( m_cbLocked->GetValue() );
611
612 int attributes = 0;
613
614 switch( m_componentType->GetSelection() )
615 {
616 case 0: attributes |= FP_THROUGH_HOLE; break;
617 case 1: attributes |= FP_SMD; break;
618 default: break;
619 }
620
621 if( m_boardOnly->GetValue() )
622 attributes |= FP_BOARD_ONLY;
623
624 if( m_excludeFromPosFiles->GetValue() )
625 attributes |= FP_EXCLUDE_FROM_POS_FILES;
626
627 if( m_excludeFromBOM->GetValue() )
628 attributes |= FP_EXCLUDE_FROM_BOM;
629
630 if( m_cbDNP->GetValue() )
631 attributes |= FP_DNP;
632
633 if( m_noCourtyards->GetValue() )
634 attributes |= FP_ALLOW_MISSING_COURTYARD;
635
636 if( m_allowSolderMaskBridges->GetValue() )
637 attributes |= FP_ALLOW_SOLDERMASK_BRIDGES;
638
639 m_footprint->SetAttributes( attributes );
640
642
643 if( m_footprint->GetOrientation() != orient )
645
646 // Set component side, that also have effect on the fields positions on board
647 bool change_layer = false;
648 if( m_BoardSideCtrl->GetSelection() == 0 ) // layer req = COMPONENT
649 {
650 if( m_footprint->GetLayer() == B_Cu )
651 change_layer = true;
652 }
653 else if( m_footprint->GetLayer() == F_Cu )
654 change_layer = true;
655
656 if( change_layer )
657 {
660 }
661
662 // Copy the models from the panel to the footprint
663 std::vector<FP_3DMODEL>& panelList = m_3dPanel->GetModelList();
664 std::vector<FP_3DMODEL>* fpList = &m_footprint->Models();
665 fpList->clear();
666 fpList->insert( fpList->end(), panelList.begin(), panelList.end() );
667
668 // This is a simple edit, we must create an undo entry
669 if( m_footprint->GetEditFlags() == 0 ) // i.e. not edited, or moved
670 commit.Push( _( "Edit Footprint Properties" ) );
671
673 return true;
674}
675
676
678{
680 return;
681
682 PCB_FIELD newField( m_footprint, FIELD_T::USER,
684
685 newField.SetVisible( false );
686 newField.SetLayer( m_footprint->GetLayer() == F_Cu ? F_Fab : B_Fab );
687 newField.SetFPRelativePosition( { 0, 0 } );
689
690 m_fields->push_back( newField );
691
692 // notify the grid
693 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
694 m_itemsGrid->ProcessTableMessage( msg );
695
696 m_itemsGrid->SetFocus();
697 m_itemsGrid->MakeCellVisible( m_fields->size() - 1, 0 );
698 m_itemsGrid->SetGridCursor( m_fields->size() - 1, 0 );
699
700 m_itemsGrid->EnableCellEditControl( true );
701 m_itemsGrid->ShowCellEditControl();
702
703 OnModify();
704}
705
706
708{
710 return;
711
712 wxArrayInt selectedRows = m_itemsGrid->GetSelectedRows();
713
714 if( selectedRows.empty() && m_itemsGrid->GetGridCursorRow() >= 0 )
715 selectedRows.push_back( m_itemsGrid->GetGridCursorRow() );
716
717 if( selectedRows.empty() )
718 return;
719
720 for( int row : selectedRows )
721 {
722
723 if( row < m_fields->GetMandatoryRowCount() )
724 {
725 DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
727 return;
728 }
729 }
730
731 m_itemsGrid->CommitPendingChanges( true /* quiet mode */ );
732 m_itemsGrid->ClearSelection();
733
734 // Reverse sort so deleting a row doesn't change the indexes of the other rows.
735 selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
736
737 for( int row : selectedRows )
738 {
739 m_fields->erase( m_fields->begin() + row );
740
741 // notify the grid
742 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
743 m_itemsGrid->ProcessTableMessage( msg );
744
745 if( m_itemsGrid->GetNumberRows() > 0 )
746 {
747 m_itemsGrid->MakeCellVisible( std::max( 0, row-1 ), m_itemsGrid->GetGridCursorCol() );
748 m_itemsGrid->SetGridCursor( std::max( 0, row-1 ), m_itemsGrid->GetGridCursorCol() );
749 }
750 }
751
752 OnModify();
753}
754
755
757{
758 // Account for scroll bars
760
761 itemsWidth -= m_itemsGrid->GetRowLabelSize();
762
763 for( int i = 0; i < m_itemsGrid->GetNumberCols(); i++ )
764 {
765 if( i == 1 )
766 continue;
767
768 itemsWidth -= m_itemsGrid->GetColSize( i );
769 }
770
771 m_itemsGrid->SetColSize(
772 1, std::max( itemsWidth, m_itemsGrid->GetVisibleWidth( 0, true, false ) ) );
773
774 // Update the width of the 3D panel
776}
777
778
780{
781 if( !m_initialized )
782 return;
783
784 // Handle a grid error. This is delayed to OnUpdateUI so that we can change focus
785 // even when the original validation was triggered from a killFocus event, and so
786 // that the corresponding notebook page can be shown in the background when triggered
787 // from an OK.
788 if( m_delayedFocusRow >= 0 )
789 {
790 // We will re-enter this routine if an error dialog is displayed, so make sure we
791 // zero out our member variables first.
792 wxGrid* grid = m_delayedFocusGrid;
793 int row = m_delayedFocusRow;
794 int col = m_delayedFocusColumn;
795 wxString msg = m_delayedErrorMessage;
796
797 m_delayedFocusGrid = nullptr;
800 m_delayedErrorMessage = wxEmptyString;
801
802 if( !msg.IsEmpty() )
803 {
804 // Do not use DisplayErrorMessage(); it screws up window order on Mac
805 DisplayError( nullptr, msg );
806 }
807
808 grid->SetFocus();
809 grid->MakeCellVisible( row, col );
810
811 // Selecting the first grid item only makes sense for the
812 // items grid
813 if( !m_initialFocus || grid == m_itemsGrid )
814 {
815 grid->SetGridCursor( row, col );
816
817 if( !( col == 0 && row < m_fields->GetMandatoryRowCount() ) )
818 grid->EnableCellEditControl( true );
819
820 grid->ShowCellEditControl();
821
822 if( grid == m_itemsGrid && row == 0 && col == 0 )
823 {
824 auto referenceEditor = grid->GetCellEditor( 0, 0 );
825
826 if( auto textEntry = dynamic_cast<wxTextEntry*>( referenceEditor->GetControl() ) )
827 KIUI::SelectReferenceNumber( textEntry );
828
829 referenceEditor->DecRef();
830 }
831 }
832
833 m_initialFocus = false;
834 }
835}
836
837
839{
840 wxSize new_size = aEvent.GetSize();
841
842 if( ( !m_itemsGrid->IsCellEditControlShown() || m_lastRequestedSize != new_size )
843 && m_gridSize != new_size )
844 {
845 m_gridSize = new_size;
846
847 // A trick to fix a cosmetic issue: when, in m_itemsGrid, a layer selector widget has
848 // the focus (is activated in column 6) when resizing the grid, the widget is not moved.
849 // So just change the widget having the focus in this case
850 if( m_NoteBook->GetSelection() == 0 && !m_itemsGrid->HasFocus() )
851 {
852 int col = m_itemsGrid->GetGridCursorCol();
853
854 if( col == 6 ) // a layer selector widget can be activated
855 m_itemsGrid->SetFocus();
856 }
857
859 }
860
861 // We store this value to check whether the dialog is changing size. This might indicate
862 // that the user is scaling the dialog with an editor shown. Some editors do not close
863 // (at least on GTK) when the user drags a dialog corner
864 m_lastRequestedSize = new_size;
865
866 // Always propagate for a grid repaint (needed if the height changes, as well as width)
867 aEvent.Skip();
868
869}
870
871
872void DIALOG_FOOTPRINT_PROPERTIES::OnPageChanging( wxNotebookEvent& aEvent )
873{
875 aEvent.Veto();
876}
877
878
879void DIALOG_FOOTPRINT_PROPERTIES::OnCheckBox( wxCommandEvent& event )
880{
881 if( m_initialized )
882 OnModify();
883}
884
885
886void DIALOG_FOOTPRINT_PROPERTIES::OnCombobox( wxCommandEvent& event )
887{
888 if( m_initialized )
889 OnModify();
890}
891
892
893void DIALOG_FOOTPRINT_PROPERTIES::OnText( wxCommandEvent& event )
894{
895 if( m_initialized )
896 OnModify();
897}
898
899
900void DIALOG_FOOTPRINT_PROPERTIES::OnChoice( wxCommandEvent& event )
901{
902 if( m_initialized )
903 OnModify();
904}
const char * name
Definition: DXF_plotter.cpp:62
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:110
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:104
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition: bitmap.cpp:110
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:280
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:48
void SetFPRelativePosition(const VECTOR2I &aPos)
Definition: board_item.cpp:342
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:297
EMBEDDED_FILES * GetEmbeddedFiles() override
Definition: board.cpp:2583
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:623
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:838
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
Definition: board.cpp:1707
Class DIALOG_FOOTPRINT_PROPERTIES_BASE.
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 OnGridSize(wxSizeEvent &aEvent) override
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
Definition: dialog_shim.h:214
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:66
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void OnModify()
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
EDA_ANGLE Normalize()
Definition: eda_angle.h:224
EDA_ANGLE Normalize180()
Definition: eda_angle.h:263
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:144
void ClearSelected()
Definition: eda_item.h:133
bool IsSelected() const
Definition: eda_item.h:123
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:97
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:386
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:270
int GetTextThickness() const
Definition: eda_text.h:125
VECTOR2I GetTextSize() const
Definition: eda_text.h:258
void RemoveFile(const wxString &name, bool aErase=true)
Remove a file from the collection and frees the memory.
void SetPosition(const VECTOR2I &aPos) override
Definition: footprint.cpp:2462
ZONE_CONNECTION GetLocalZoneConnection() const
Definition: footprint.h:293
void SetLocked(bool isLocked) override
Set the #MODULE_is_LOCKED bit in the m_ModuleStatus.
Definition: footprint.h:426
EDA_ANGLE GetOrientation() const
Definition: footprint.h:232
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition: footprint.h:290
void SetAttributes(int aAttributes)
Definition: footprint.h:296
std::optional< int > GetLocalSolderPasteMargin() const
Definition: footprint.h:286
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: footprint.cpp:2371
std::optional< int > GetLocalClearance() const
Definition: footprint.h:280
int GetAttributes() const
Definition: footprint.h:295
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition: footprint.h:292
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: footprint.h:241
const LIB_ID & GetFPID() const
Definition: footprint.h:253
bool IsLocked() const override
Definition: footprint.h:416
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:1072
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition: footprint.h:289
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: footprint.cpp:2403
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly) const
Populate a std::vector with PCB_TEXTs.
Definition: footprint.cpp:630
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:225
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition: footprint.h:284
void SetLocalClearance(std::optional< int > aClearance)
Definition: footprint.h:281
std::optional< int > GetLocalSolderMaskMargin() const
Definition: footprint.h:283
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition: footprint.h:287
VECTOR2I GetPosition() const override
Definition: footprint.h:229
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:57
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
UTF8 Format() const
Definition: lib_id.cpp:119
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:297
EMBEDDED_FILES * GetLocalFiles()
bool TransferDataToWindow() override
bool TransferDataFromWindow() override
std::vector< FP_3DMODEL > & GetModelList()
FLIP_DIRECTION m_FlipDirection
wxString m_FootprintTextShownColumns
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Return the BOARD_DESIGN_SETTINGS for the open project.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
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).
Definition: pcb_field.cpp:100
PCB_FIELD * CloneField() const
Same as Clone, but returns a PCB_FIELD item.
Definition: pcb_field.h:92
The selection tool: currently supports:
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
Definition: pcb_text.cpp:310
static S3D_CACHE * Get3DCacheManager(PROJECT *aProject, bool updateProjDir=false)
Return a pointer to an instance of the 3D cache manager.
Definition: project_pcb.cpp:77
void FlushCache(bool closePlugins=true)
Free all data in the cache and by default closes all plugins.
Definition: 3d_cache.cpp:525
int AddItemToSel(const TOOL_EVENT &aEvent)
void SetBitmap(const wxBitmapBundle &aBmp)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aValue in internal units into a united string.
int ValueFromString(const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aTextValue in aUnits to internal units used by the frame.
virtual long long int GetValue()
Return the current value in Internal Units.
virtual void SetPrecision(int aLength)
Normally not needed, but can be used to set the precision when using internal units that are floats (...
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 EDA_ANGLE GetAngleValue()
virtual void SetNegativeZero()
Definition: unit_binder.h:73
virtual double GetDoubleValue()
Return the current value in Internal Units.
virtual void SetAngleValue(const EDA_ANGLE &aValue)
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.
void SetCoordType(ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
Set the current origin transform mode.
Definition: unit_binder.h:200
bool IsNull() const
Return true if the control holds no value (ie: empty string, not 0).
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=true, bool aKeep=false)
Calculate the specified column based on the actual size of the text on screen.
Definition: wx_grid.cpp:785
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:499
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:275
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:454
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:469
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:649
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
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:46
#define TEXT_MAX_SIZE_MM
Maximum text size in mm (~10 inches)
Definition: eda_text.h:47
@ FP_SMD
Definition: footprint.h:81
@ FP_DNP
Definition: footprint.h:88
@ FP_ALLOW_MISSING_COURTYARD
Definition: footprint.h:87
@ FP_EXCLUDE_FROM_POS_FILES
Definition: footprint.h:82
@ FP_BOARD_ONLY
Definition: footprint.h:84
@ FP_EXCLUDE_FROM_BOM
Definition: footprint.h:83
@ FP_THROUGH_HOLE
Definition: footprint.h:80
@ FP_ALLOW_SOLDERMASK_BRIDGES
Definition: footprint.h:86
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:72
static const std::string KiCadUriPrefix
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Cu
Definition: layer_ids.h:65
@ F_Fab
Definition: layer_ids.h:119
@ F_Cu
Definition: layer_ids.h:64
@ B_Fab
Definition: layer_ids.h:118
wxColour GetDialogBGColour()
Definition: wxgtk/ui.cpp:61
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition: wxgtk/ui.cpp:252
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:156
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:162
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:236
@ PFC_HEIGHT
@ PFC_THICKNESS
see class PGM_BASE
constexpr int mmToIU(double mm) const
Definition: base_units.h:90
wxString GetUserFieldName(int aFieldNdx, bool aTranslateForHI)
#define DO_TRANSLATE