KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
panel_assign_component_classes.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
26
27#include <bitmaps.h>
28#include <board.h>
31#include <footprint.h>
32#include <kiway.h>
33#include <pcb_edit_frame.h>
35#include <tool/selection_tool.h>
36#include <tool/tool_manager.h>
40
41
42/**************************************************************************************************
43 *
44 * PANEL_ASSIGN_COMPONENT_CLASSES implementation
45 * This is the top-level panel for component class configuration
46 *
47 *************************************************************************************************/
48
50 wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame,
51 std::shared_ptr<COMPONENT_CLASS_SETTINGS> aSettings, DIALOG_SHIM* aDlg ) :
52 PANEL_ASSIGN_COMPONENT_CLASSES_BASE( aParentWindow ), m_dlg( aDlg ), m_frame( aFrame ),
53 m_componentClassSettings( std::move( aSettings ) ),
54 m_assignmentsList( static_cast<wxBoxSizer*>( m_assignmentsScrollWindow->GetSizer() ) )
55{
56 // Load footprint fields and sheet names
57 const BOARD* board = dynamic_cast<BOARD*>( m_frame->GetModel() );
58 std::set<wxString> fieldsSet;
59 std::set<wxString> sheetsSet;
60
61 for( const FOOTPRINT* fp : board->Footprints() )
62 {
63 wxString sheetName = fp->GetSheetname();
64
65 if( !sheetName.empty() )
66 {
67 sheetName.Replace( wxT( "\"" ), wxT( "" ) );
68 sheetName.Replace( wxT( "'" ), wxT( "" ) );
69 sheetsSet.insert( fp->GetSheetname() );
70 }
71
72 for( const PCB_FIELD* field : fp->GetFields() )
73 fieldsSet.insert( field->GetName() );
74 }
75
76 // Sort field names
77 std::vector<wxString> fieldNames( fieldsSet.begin(), fieldsSet.end() );
78 std::ranges::sort( fieldNames,
79 []( const wxString& a, const wxString& b )
80 {
81 return a.Cmp( b ) < 0;
82 } );
83
84 m_fieldNames = std::move( fieldNames );
85
86 // Sort sheet names
87 std::vector<wxString> sheetNames( sheetsSet.begin(), sheetsSet.end() );
88 std::ranges::sort( sheetNames,
89 []( const wxString& a, const wxString& b )
90 {
91 return a.Cmp( b ) < 0;
92 } );
93
94 m_sheetNames = std::move( sheetNames );
95
96 // Get references of currently selected items
97 std::set<wxString> refsSet;
98
99 for( const EDA_ITEM* item : m_frame->GetCurrentSelection() )
100 {
101 if( item->Type() != PCB_FOOTPRINT_T )
102 continue;
103
104 const FOOTPRINT* fp = static_cast<const FOOTPRINT*>( item );
105 wxString ref = fp->GetReferenceAsString();
106 refsSet.insert( ref );
107 }
108
109 std::vector<wxString> refs( refsSet.begin(), refsSet.end() );
110 std::ranges::sort( refs,
111 []( const wxString& a, const wxString& b )
112 {
113 return a.Cmp( b ) < 0;
114 } );
115
116 m_selectionRefs = std::move( refs );
117}
118
119
121{
122 BOARD* board = dynamic_cast<BOARD*>( m_frame->GetModel() );
124
125 for( FOOTPRINT* fp : board->Footprints() )
126 selTool->UnbrightenItem( fp );
127
129}
130
131
133{
134 // Load sheet-level settings
135 m_assignSheetClasses->SetValue( m_componentClassSettings->GetEnableSheetComponentClasses() );
136
137 // Load dynamic component class assignments
138 for( const COMPONENT_CLASS_ASSIGNMENT_DATA& assignmentData :
139 m_componentClassSettings->GetComponentClassAssignments() )
140 {
142 assignment->SetComponentClass( assignmentData.GetComponentClass() );
143 assignment->SetConditionsOperator( assignmentData.GetConditionsOperator() );
144
145 for( const auto& [conditionType, conditionData] : assignmentData.GetConditions() )
146 {
147 CONDITION_DATA* match = assignment->AddCondition( conditionType );
148 match->SetPrimaryField( conditionData.first );
149 match->SetSecondaryField( conditionData.second );
150 }
151 }
152
153 return true;
154}
155
156
158{
159 if( !Validate() )
160 return false;
161
162 // Save sheet-level settings
163 m_componentClassSettings->SetEnableSheetComponentClasses( m_assignSheetClasses->GetValue() );
164
165 // Save dynamic component class assignments
166 m_componentClassSettings->ClearComponentClassAssignments();
167
168 for( const auto assignment : m_assignments )
169 {
170 COMPONENT_CLASS_ASSIGNMENT_DATA assignmentData = assignment->GenerateAssignmentData();
171 m_componentClassSettings->AddComponentClassAssignment( assignmentData );
172 }
173
174 return true;
175}
176
177
179{
180 PCB_EDIT_FRAME* frame = GetFrame();
181 BOARD* board = dynamic_cast<BOARD*>( frame->GetModel() );
182
183 frame->GetCanvas()->Refresh();
184
186 {
187 const COMPONENT_CLASS_ASSIGNMENT_DATA assignmentData = assignment->GenerateAssignmentData();
188 const std::shared_ptr<COMPONENT_CLASS_ASSIGNMENT_RULE> rule =
189 board->GetComponentClassManager().CompileAssignmentRule( assignmentData );
190
191 if( !rule )
192 {
193 const wxString msg = wxString::Format(
194 _( "Error with conditions for component class assignment %s" ),
195 assignment->GetComponentClass() );
196 PAGED_DIALOG::GetDialog( this )->SetError( msg, this, assignment );
197 scrollToAssignment( assignment );
198 assignment->SetFocus();
199 return false;
200 }
201 }
202
203 return true;
204}
205
206
208{
210 scrollToAssignment( assignment );
211}
212
213
215{
216 PANEL_COMPONENT_CLASS_ASSIGNMENT* assignmentPanel =
218
219#if __OSX__
220 m_assignmentsList->Add( assignmentPanel, 0, wxEXPAND, 5 );
221#else
222 m_assignmentsList->Add( assignmentPanel, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
223#endif
224
225 Layout();
226
227 m_assignments.push_back( assignmentPanel );
228
229 return assignmentPanel;
230}
231
232
234 const PANEL_COMPONENT_CLASS_ASSIGNMENT* aAssignment ) const
235{
236 const wxPoint viewStart = m_assignmentsScrollWindow->GetViewStart();
237 const wxPoint panelPosition = aAssignment->GetPosition();
238 const wxSize panelSize = aAssignment->GetClientSize();
239
240 m_assignmentsScrollWindow->Scroll( viewStart.x, panelPosition.y + panelSize.y );
241}
242
243
245{
246 m_assignments.erase( std::ranges::find( m_assignments, aPanel ) );
247 m_assignmentsList->Detach( aPanel );
248 aPanel->Destroy();
249 Layout();
250}
251
252
254 const std::shared_ptr<COMPONENT_CLASS_SETTINGS>& aOtherSettings )
255{
256 std::shared_ptr<COMPONENT_CLASS_SETTINGS> savedSettings = m_componentClassSettings;
257
258 m_componentClassSettings = aOtherSettings;
260
261 m_componentClassSettings = std::move( savedSettings );
262}
263
264
265/**************************************************************************************************
266 *
267 * CONDITION_DATA implementation
268 * Provides a common interface for all condition panel types
269 *
270 *************************************************************************************************/
271
273{
274 wxString data = m_primaryCtrl->GetValue();
275 data.Trim( true );
276 data.Trim( false );
277
279 {
280 data.Replace( wxT( "\"" ), wxT( "" ) );
281 data.Replace( wxT( "'" ), wxT( "" ) );
282 }
283
284 return data;
285}
286
287
288void CONDITION_DATA::SetPrimaryField( const wxString& aVal )
289{
290 m_primaryCtrl->SetValue( aVal );
291}
292
293
295{
296 if( !m_secondaryCtrl )
297 return wxEmptyString;
298
299 wxString data = m_secondaryCtrl->GetValue();
300 data.Trim( true );
301 data.Trim( false );
302
304 {
305 data.Replace( wxT( "\"" ), wxT( "" ) );
306 data.Replace( wxT( "'" ), wxT( "" ) );
307 }
308
309 return data;
310}
311
312
313void CONDITION_DATA::SetSecondaryField( const wxString& aVal )
314{
315 if( m_secondaryCtrl )
316 m_secondaryCtrl->SetValue( aVal );
317};
318
319/**************************************************************************************************
320 *
321 * PANEL_COMPONENT_CLASS_ASSIGNMENT implementation
322 * This is the dynamically-added panel for each component class assignment rule set
323 *
324 *************************************************************************************************/
325
327 wxWindow* aParent, PANEL_ASSIGN_COMPONENT_CLASSES* aPanelParent, DIALOG_SHIM* aDlg ) :
328 PANEL_COMPONENT_CLASS_ASSIGNMENT_BASE( aParent ), m_parentPanel( aPanelParent ),
329 m_matchesList( static_cast<wxStaticBoxSizer*>( GetSizer() ) ), m_dlg( aDlg )
330{
331 m_buttonAddCondition->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
332 m_buttonDeleteAssignment->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
333 m_buttonHighlightItems->SetBitmap( KiBitmapBundle( BITMAPS::net_highlight ) );
334
335 Connect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_ASSIGNMENT::onMenu ), nullptr,
336 this );
337}
338
339
341{
342 Disconnect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_ASSIGNMENT::onMenu ),
343 nullptr, this );
344}
345
346
348{
349 COMPONENT_CLASS_ASSIGNMENT_DATA assignmentData;
350 assignmentData.SetComponentClass( GetComponentClass() );
352
353 for( const auto& condition : GetConditions() )
354 {
355 assignmentData.SetCondition( condition->GetConditionType(), condition->GetPrimaryField(),
356 condition->GetSecondaryField() );
357 }
358
359 return assignmentData;
360}
361
362
364{
365 auto hasCondition = [this]( const COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE aCondition )
366 {
367 return m_conditionTypes.contains( aCondition );
368 };
369
370 wxMenu menu;
371 menu.Append( ID_REFERENCE, _( "Reference..." ) );
372 menu.Append( ID_FOOTPRINT, _( "Footprint..." ) );
373 menu.Append( ID_SIDE, _( "Side..." ) );
374 menu.Append( ID_ROTATION, _( "Rotation..." ) );
375 menu.Append( ID_FOOTPRINT_FIELD, _( "Footprint Field..." ) );
376 menu.Append( ID_SHEET_NAME, _( "Sheet Name..." ) );
377 menu.Append( ID_CUSTOM, _( "Custom..." ) );
378 menu.Enable( ID_REFERENCE,
380 menu.Enable( ID_FOOTPRINT,
382 menu.Enable( ID_SIDE, !hasCondition( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::SIDE ) );
383 menu.Enable( ID_ROTATION,
385 menu.Enable(
388 menu.Enable( ID_CUSTOM,
390 menu.Enable( ID_SHEET_NAME,
392 PopupMenu( &menu );
393}
394
395
397{
399}
400
401
402void PANEL_COMPONENT_CLASS_ASSIGNMENT::SetComponentClass( const wxString& aComponentClass ) const
403{
404 m_componentClass->SetValue( aComponentClass );
405}
406
407
409{
410 return m_componentClass->GetValue();
411}
412
413
414void PANEL_COMPONENT_CLASS_ASSIGNMENT::onMenu( wxCommandEvent& aEvent )
415{
416 switch( aEvent.GetId() )
417 {
418 case ID_REFERENCE:
420 break;
421 case ID_FOOTPRINT:
423 break;
425 case ID_ROTATION:
427 break;
430 break;
432 case ID_SHEET_NAME:
434 break;
435
436 default: wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
437 }
438}
439
440
443{
444 wxASSERT_MSG( !m_conditionTypes.contains( aCondition ), "Condition type already exists" );
445
446 wxPanel* panelToAdd = nullptr;
447
448 switch( aCondition )
449 {
451 {
455 panelToAdd = refsPanel;
457 break;
458 }
460 {
461 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT( this, m_dlg );
463 break;
464 }
466 {
467 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_SIDE( this );
469 break;
470 }
472 {
473 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_ROTATION( this );
475 break;
476 }
478 {
481 fieldPanel->SetFieldsList( m_parentPanel->GetFieldNames() );
482 panelToAdd = fieldPanel;
484 break;
485 }
487 {
488 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_CUSTOM( this );
490 break;
491 }
493 {
496 sheetPanel->SetSheetsList( m_parentPanel->GetSheetNames() );
497 panelToAdd = sheetPanel;
499 break;
500 }
501 }
502
503 const size_t numItems = m_matchesList->GetItemCount();
504 m_matchesList->Insert( numItems - 1, panelToAdd, 0, wxEXPAND | wxTOP, 5 );
505 Layout();
506 GetParent()->Layout();
507 m_parentPanel->Layout();
508
509 CONDITION_DATA* conditionIface = dynamic_cast<CONDITION_DATA*>( panelToAdd );
510 m_matches.push_back( conditionIface );
511
512 return conditionIface;
513}
514
515
517{
518 if( CONDITION_DATA* matchData = dynamic_cast<CONDITION_DATA*>( aMatch ) )
519 {
520 m_conditionTypes.erase( matchData->GetConditionType() );
521 m_matches.erase( std::ranges::find( m_matches, matchData ) );
522 }
523
524 m_matchesList->Detach( aMatch );
525 aMatch->Destroy();
526 Layout();
527 m_parentPanel->Layout();
528}
529
530
533{
535 {
536 m_radioAll->SetValue( true );
537 m_radioAny->SetValue( false );
538 }
539 else
540 {
541 m_radioAll->SetValue( false );
542 m_radioAny->SetValue( true );
543 }
544}
545
546
549{
550 if( m_radioAll->GetValue() == true )
552
554}
555
556
558{
560 BOARD* board = dynamic_cast<BOARD*>( frame->GetModel() );
562
564 const std::shared_ptr<COMPONENT_CLASS_ASSIGNMENT_RULE> rule =
565 board->GetComponentClassManager().CompileAssignmentRule( assignment );
566
567 if( !rule )
568 return;
569
570 for( FOOTPRINT* fp : board->Footprints() )
571 {
572 if( rule->Matches( fp ) )
573 selTool->BrightenItem( fp );
574 else
575 selTool->UnbrightenItem( fp );
576 }
577
578 frame->GetCanvas()->Refresh();
579}
580
581
582/**************************************************************************************************
583 *
584 * PANEL_COMPONENT_CLASS_CONDITION_* implementations
585 * These are the dynamically-added panels for each condition / match type
586 *
587 *************************************************************************************************/
588
590 wxWindow* aParent ) :
592 CONDITION_DATA( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::REFERENCE, m_refs ),
593 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
594{
595 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) ).x, -1 } );
596
597 m_buttonImportRefs->SetBitmap( KiBitmapBundle( BITMAPS::config ) );
598 m_buttonDeleteMatch->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
599
600 Connect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_CONDITION_REFERENCE::onMenu ),
601 nullptr, this );
602}
603
604
606{
608
609 Disconnect( wxEVT_MENU,
610 wxCommandEventHandler( PANEL_COMPONENT_CLASS_CONDITION_REFERENCE::onMenu ), nullptr,
611 this );
612}
613
614
616{
617 wxMenu menu;
618 menu.Append( ID_IMPORT_REFS, _( "Import references from selection" ) );
619 menu.Enable( ID_IMPORT_REFS, !m_selectionRefs.empty() );
620 PopupMenu( &menu );
621}
622
623
625{
626 if( aEvent.GetId() != ID_IMPORT_REFS )
627 wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
628
629 if( m_selectionRefs.empty() )
630 return;
631
632 wxString refs = m_selectionRefs[0];
633
634 for( size_t i = 1; i < m_selectionRefs.size(); i++ )
635 {
636 refs += wxT( "," );
637 refs += m_selectionRefs[i];
638 }
639
640 m_refs->SetValue( refs );
641}
642
643
645 wxWindow* aParent, DIALOG_SHIM* aDlg ) :
647 CONDITION_DATA( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::FOOTPRINT, m_footprint ),
648 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) ), m_dlg( aDlg )
649{
650 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) ).x, -1 } );
651
652 m_buttonDeleteMatch->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
653 m_buttonShowLibrary->SetBitmap( KiBitmapBundle( BITMAPS::small_library ) );
654}
655
656
658{
660}
661
662
664{
665 wxString fpId = m_footprint->GetValue();
666
667 if( KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, m_dlg ) )
668 {
669 if( frame->ShowModal( &fpId, this ) )
670 {
671 m_footprint->SetValue( fpId );
672 }
673
674 frame->Destroy();
675 }
676}
677
678
681 CONDITION_DATA( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::SIDE, m_side ),
682 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
683{
684 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) ).x, -1 } );
685
686 m_buttonDeleteMatch->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
687 m_side->Append( wxT( "Any" ) );
688 m_side->Append( wxT( "Front" ) );
689 m_side->Append( wxT( "Back" ) );
690 m_side->SetValue( wxT( "Any" ) );
691}
692
693
695{
697}
698
699
701 wxWindow* aParent ) :
703 CONDITION_DATA( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::ROTATION, m_rotation ),
704 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
705{
706 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) ).x, -1 } );
707 m_rotUnit->SetLabel( wxT( "°" ) );
708
709 m_buttonDeleteMatch->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
710 m_rotation->Append( wxT( "Any" ) );
711 m_rotation->Append( wxT( "0" ) );
712 m_rotation->Append( wxT( "90" ) );
713 m_rotation->Append( wxT( "180" ) );
714 m_rotation->Append( wxT( "-90" ) );
715 m_rotation->SetValue( wxT( "Any" ) );
716}
717
718
720{
722}
723
724
727 CONDITION_DATA( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::FOOTPRINT_FIELD,
728 m_fieldName, m_fieldValue ),
729 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
730{
731 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) ).x, -1 } );
732
733 m_buttonDeleteMatch->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
734}
735
736
738{
740}
741
742
743void PANEL_COMPONENT_CLASS_CONDITION_FIELD::SetFieldsList( const std::vector<wxString>& aFields )
744{
745 m_fieldName->Append( aFields );
746}
747
748
750 wxWindow* aParent ) :
753 m_customCondition ),
754 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
755{
756 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) ).x, -1 } );
757
758 m_buttonDeleteMatch->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
759}
760
761
763{
765}
766
767
770 CONDITION_DATA( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::SHEET_NAME, m_sheetName ),
771 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
772{
773 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) ).x, -1 } );
774
775 m_buttonDeleteMatch->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
776}
777
778
780{
782}
783
784
785void PANEL_COMPONENT_CLASS_CONDITION_SHEET::SetSheetsList( const std::vector<wxString>& aSheets )
786{
787 m_sheetName->Append( aSheets );
788}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition: bitmap.cpp:110
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:297
const FOOTPRINTS & Footprints() const
Definition: board.h:338
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
Definition: board.h:1316
void SetConditionsOperation(const CONDITIONS_OPERATOR aOperator)
Sets the boolean operation in use for all conditions.
void SetCondition(const CONDITION_TYPE aCondition, const wxString &aPrimaryData, const wxString &aSecondaryData)
Sets the given condition type with the assocated match data.
CONDITIONS_OPERATOR
Whether conditions are applied with OR or AND logic.
void SetComponentClass(const wxString &aComponentClass)
Sets the resulting component class for matching footprints.
static std::shared_ptr< COMPONENT_CLASS_ASSIGNMENT_RULE > CompileAssignmentRule(const COMPONENT_CLASS_ASSIGNMENT_DATA &aAssignment)
Class used to provide a unified interface from condition panels Handles determining the type of condi...
virtual void SetSecondaryField(const wxString &aVal)
Sets the primary data member for the condition (e.g.
virtual wxString GetPrimaryField() const
Gets the primary data member for the condition (e.g. Reference, Side)
COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE m_conditionType
The type of condition being referenced.
virtual wxString GetSecondaryField() const
Gets the primary data member for the condition (e.g. FOOTPRITNT field value)
wxTextEntry * m_secondaryCtrl
The Secondary data field in the condition panel.
wxTextEntry * m_primaryCtrl
The primary data field in the condition panel.
virtual void SetPrimaryField(const wxString &aVal)
Sets the primary data member for the condition (e.g. Reference, Side)
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:52
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:95
static bool Replace(const EDA_SEARCH_DATA &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
Definition: eda_item.cpp:208
wxString GetReferenceAsString() const
Definition: footprint.h:628
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:55
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:406
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
Class PANEL_ASSIGN_COMPONENT_CLASSES_BASE.
wxBoxSizer * m_assignmentsList
The list of all currently present component class assignments.
bool Validate() override
Validates that all assignment rules can compile successfully.
std::vector< wxString > m_sheetNames
All sheet names present on the board.
std::vector< wxString > m_fieldNames
All footprint fields names present on the board.
const std::vector< wxString > & GetFieldNames() const
Returns names of all fields present in footprints.
std::vector< PANEL_COMPONENT_CLASS_ASSIGNMENT * > m_assignments
Vector of all currently displayed assignment rules.
void OnAddAssignmentClick(wxCommandEvent &event) override
Adds a new component class assignment rule.
void RemoveAssignment(PANEL_COMPONENT_CLASS_ASSIGNMENT *aPanel)
Removes a given component class assignment rule.
PCB_EDIT_FRAME * m_frame
The active edit frame.
PANEL_COMPONENT_CLASS_ASSIGNMENT * addAssignment()
Adds a new component class assignment rule.
bool TransferDataFromWindow() override
Saves the component class assignments to the board settings.
const std::vector< wxString > & GetSelectionRefs() const
Returns references for all currently selected footprints.
DIALOG_SHIM * m_dlg
The parent dialog.
std::shared_ptr< COMPONENT_CLASS_SETTINGS > m_componentClassSettings
The active settings object.
PCB_EDIT_FRAME * GetFrame() const
Gets the active edit frame.
PANEL_ASSIGN_COMPONENT_CLASSES(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame, std::shared_ptr< COMPONENT_CLASS_SETTINGS > aSettings, DIALOG_SHIM *aDlg)
const std::vector< wxString > & GetSheetNames() const
Returns names of all sheets present in footprints.
std::vector< wxString > m_selectionRefs
All currently selected footprint references.
void ImportSettingsFrom(const std::shared_ptr< COMPONENT_CLASS_SETTINGS > &aOtherSettings)
Loads component class assignments from the given settings object.
bool TransferDataToWindow() override
Loads current component class assignments from the board settings.
void scrollToAssignment(const PANEL_COMPONENT_CLASS_ASSIGNMENT *aAssignment) const
Scrolls the panel to specified assignment rule.
Class PANEL_COMPONENT_CLASS_ASSIGNMENT_BASE.
Panel which configures a set of conditions for a component class assignment rule.
void OnDeleteAssignmentClick(wxCommandEvent &event) override
Deletes this component class assignment rule.
std::vector< CONDITION_DATA * > m_matches
All match conditions for this component class assignment rule.
COMPONENT_CLASS_ASSIGNMENT_DATA GenerateAssignmentData() const
Converts the UI representation in to the internal assignment data representation.
void SetComponentClass(const wxString &aComponentClass) const
Sets the resulting component class for this assignment.
void OnHighlightItemsClick(wxCommandEvent &event) override
Highlights footprints matching this set of conditions.
COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITIONS_OPERATOR GetConditionsOperator() const
Gets the boolean operator applied to all assignment conditions.
PANEL_ASSIGN_COMPONENT_CLASSES * m_parentPanel
The top-level configuration panel which owns this assignment rule.
const std::vector< CONDITION_DATA * > & GetConditions() const
CONDITION_DATA * AddCondition(COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE aCondition)
Adds a condition to this component class assignment rule.
void SetConditionsOperator(COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITIONS_OPERATOR aCondition) const
Sets the boolean operator applied to all assignment conditions.
wxStaticBoxSizer * m_matchesList
The sizer containing match condition panels.
const wxString GetComponentClass() const
Gets the resulting component class for this assignment.
PANEL_COMPONENT_CLASS_ASSIGNMENT(wxWindow *aParent, PANEL_ASSIGN_COMPONENT_CLASSES *aPanelParent, DIALOG_SHIM *aDlg)
void RemoveCondition(wxPanel *aMatch)
Removes a given condition from this component class assignment rule (note: called from the child cond...
void OnAddConditionClick(wxCommandEvent &event) override
Adds a match condition to this component class assignment rule.
void onMenu(wxCommandEvent &aEvent)
Handles add match condition popup menu selections.
DIALOG_SHIM * m_dlg
The parent configuration dialog.
std::unordered_set< COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE > m_conditionTypes
Set containing all currently configured match condition types.
Class PANEL_COMPONENT_CLASS_CONDITION_CUSTOM_BASE.
Configures matching based on a custom DRC expression.
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
void OnDeleteConditionClick(wxCommandEvent &event) override
Class PANEL_COMPONENT_CLASS_CONDITION_FIELD_BASE.
Configures matching based on footprint field contents.
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
void OnDeleteConditionClick(wxCommandEvent &event) override
void SetFieldsList(const std::vector< wxString > &aFields)
Class PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT_BASE.
Configures matching based on footprint library identifier.
void OnShowLibraryClick(wxCommandEvent &event) override
void OnDeleteConditionClick(wxCommandEvent &event) override
PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT(wxWindow *aParent, DIALOG_SHIM *aDlg)
Class PANEL_COMPONENT_CLASS_CONDITION_REFERENCE_BASE.
Configures matching based on footprint reference.
void OnDeleteConditionClick(wxCommandEvent &event) override
void onMenu(wxCommandEvent &aEvent)
Handles import references popup menu selections.
void SetSelectionRefs(const std::vector< wxString > &aRefs)
void OnImportRefsClick(wxCommandEvent &event) override
Class PANEL_COMPONENT_CLASS_CONDITION_ROTATION_BASE.
Configures matching based on footprint rotation.
void OnDeleteConditionClick(wxCommandEvent &event) override
Class PANEL_COMPONENT_CLASS_CONDITION_SHEET_BASE.
Configures matching based on a custom DRC expression.
void OnDeleteConditionClick(wxCommandEvent &event) override
void SetSheetsList(const std::vector< wxString > &aSheets)
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
Class PANEL_COMPONENT_CLASS_CONDITION_SIDE_BASE.
Configures matching based on which side of the board a footprint is on.
void OnDeleteConditionClick(wxCommandEvent &event) override
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
The main frame for Pcbnew.
BOARD_ITEM_CONTAINER * GetModel() const override
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
The selection tool: currently supports:
void BrightenItem(EDA_ITEM *aItem)
void UnbrightenItem(EDA_ITEM *aItem)
void SetBitmap(const wxBitmapBundle &aBmp)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
#define _(s)
@ FRAME_FOOTPRINT_CHOOSER
Definition: frame_type.h:44
STL namespace.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86