KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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, see <https://www.gnu.org/licenses/>.
18 */
19
20
22
23#include <bitmaps.h>
24#include <board.h>
27#include <footprint.h>
28#include <kiway.h>
29#include <pcb_edit_frame.h>
31#include <tool/selection_tool.h>
32#include <tool/tool_manager.h>
36
37
38/**************************************************************************************************
39 *
40 * PANEL_ASSIGN_COMPONENT_CLASSES implementation
41 * This is the top-level panel for component class configuration
42 *
43 *************************************************************************************************/
44
46 wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame,
47 std::shared_ptr<COMPONENT_CLASS_SETTINGS> aSettings, DIALOG_SHIM* aDlg ) :
48 PANEL_ASSIGN_COMPONENT_CLASSES_BASE( aParentWindow ), m_dlg( aDlg ), m_frame( aFrame ),
49 m_componentClassSettings( std::move( aSettings ) ),
50 m_assignmentsList( static_cast<wxBoxSizer*>( m_assignmentsScrollWindow->GetSizer() ) )
51{
52 // Load footprint fields and sheet names
53 const BOARD* board = dynamic_cast<BOARD*>( m_frame->GetModel() );
54 std::set<wxString> fieldsSet;
55 std::set<wxString> sheetsSet;
56
57 for( const FOOTPRINT* fp : board->Footprints() )
58 {
59 wxString sheetName = fp->GetSheetname();
60
61 if( !sheetName.empty() )
62 {
63 sheetName.Replace( wxT( "\"" ), wxT( "" ) );
64 sheetName.Replace( wxT( "'" ), wxT( "" ) );
65 sheetsSet.insert( fp->GetSheetname() );
66 }
67
68 for( const PCB_FIELD* field : fp->GetFields() )
69 {
70 wxCHECK2( field, continue );
71
72 fieldsSet.insert( field->GetName() );
73 }
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() );
123 PCB_SELECTION_TOOL* selTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
124
125 for( FOOTPRINT* fp : board->Footprints() )
126 selTool->UnbrightenItem( fp );
127
128 m_frame->GetCanvas()->Refresh();
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 auto& assignmentData : m_componentClassSettings->GetComponentClassAssignments() )
139 {
141 assignment->SetComponentClass( assignmentData.GetComponentClass() );
142 assignment->SetConditionsOperator( assignmentData.GetConditionsOperator() );
143
144 for( const auto& [conditionType, primaryData, secondaryData] : assignmentData.GetConditions() )
145 {
146 CONDITION_DATA* match = assignment->AddCondition( conditionType );
147 match->SetPrimaryField( primaryData );
148 match->SetSecondaryField( secondaryData );
149 }
150 }
151
152 return true;
153}
154
155
157{
158 if( !Validate() )
159 return false;
160
161 // Save sheet-level settings
162 m_componentClassSettings->SetEnableSheetComponentClasses( m_assignSheetClasses->GetValue() );
163
164 // Save dynamic component class assignments
165 m_componentClassSettings->ClearComponentClassAssignments();
166
167 for( const auto assignment : m_assignments )
168 {
169 COMPONENT_CLASS_ASSIGNMENT_DATA assignmentData = assignment->GenerateAssignmentData();
170 m_componentClassSettings->AddComponentClassAssignment( assignmentData );
171 }
172
173 return true;
174}
175
176
178{
179 GetFrame()->GetCanvas()->Refresh();
180
182 {
183 const COMPONENT_CLASS_ASSIGNMENT_DATA assignmentData = assignment->GenerateAssignmentData();
184 const std::shared_ptr<COMPONENT_CLASS_ASSIGNMENT_RULE> rule =
186
187 if( !rule )
188 {
189 const wxString msg = wxString::Format( _( "Error with conditions for component class assignment %s" ),
190 assignment->GetComponentClass() );
191 PAGED_DIALOG::GetDialog( this )->SetError( msg, this, assignment );
192 scrollToAssignment( assignment );
193 assignment->SetFocus();
194 return false;
195 }
196 }
197
198 return true;
199}
200
201
203{
205 scrollToAssignment( assignment );
206}
207
208
210{
211 PANEL_COMPONENT_CLASS_ASSIGNMENT* assignmentPanel =
213
214#if __OSX__
215 m_assignmentsList->Add( assignmentPanel, 0, wxEXPAND, 5 );
216#else
217 m_assignmentsList->Add( assignmentPanel, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
218#endif
219
220 Layout();
221
222 m_assignments.push_back( assignmentPanel );
223
224 return assignmentPanel;
225}
226
227
229 const PANEL_COMPONENT_CLASS_ASSIGNMENT* aAssignment ) const
230{
231 const wxPoint viewStart = m_assignmentsScrollWindow->GetViewStart();
232 const wxPoint panelPosition = aAssignment->GetPosition();
233 const wxSize panelSize = aAssignment->GetClientSize();
234
235 m_assignmentsScrollWindow->Scroll( viewStart.x, panelPosition.y + panelSize.y );
236}
237
238
240{
241 m_assignments.erase( std::ranges::find( m_assignments, aPanel ) );
242 m_assignmentsList->Detach( aPanel );
243 aPanel->Destroy();
244 Layout();
245}
246
247
249 const std::shared_ptr<COMPONENT_CLASS_SETTINGS>& aOtherSettings )
250{
251 std::shared_ptr<COMPONENT_CLASS_SETTINGS> savedSettings = m_componentClassSettings;
252
253 m_componentClassSettings = aOtherSettings;
255
256 m_componentClassSettings = std::move( savedSettings );
257}
258
259
260/**************************************************************************************************
261 *
262 * CONDITION_DATA implementation
263 * Provides a common interface for all condition panel types
264 *
265 *************************************************************************************************/
266
268{
269 wxString data = m_primaryCtrl->GetValue();
270 data.Trim( true );
271 data.Trim( false );
272
274 {
275 data.Replace( wxT( "\"" ), wxT( "" ) );
276 data.Replace( wxT( "'" ), wxT( "" ) );
277 }
278
279 return data;
280}
281
282
283void CONDITION_DATA::SetPrimaryField( const wxString& aVal )
284{
285 m_primaryCtrl->SetValue( aVal );
286}
287
288
290{
291 if( !m_secondaryCtrl )
292 return wxEmptyString;
293
294 wxString data = m_secondaryCtrl->GetValue();
295 data.Trim( true );
296 data.Trim( false );
297
299 {
300 data.Replace( wxT( "\"" ), wxT( "" ) );
301 data.Replace( wxT( "'" ), wxT( "" ) );
302 }
303
304 return data;
305}
306
307
308void CONDITION_DATA::SetSecondaryField( const wxString& aVal )
309{
310 if( m_secondaryCtrl )
311 m_secondaryCtrl->SetValue( aVal );
312};
313
314/**************************************************************************************************
315 *
316 * PANEL_COMPONENT_CLASS_ASSIGNMENT implementation
317 * This is the dynamically-added panel for each component class assignment rule set
318 *
319 *************************************************************************************************/
320
322 PANEL_ASSIGN_COMPONENT_CLASSES* aPanelParent,
323 DIALOG_SHIM* aDlg ) :
325 m_parentPanel( aPanelParent ),
326 m_matchesList( static_cast<wxStaticBoxSizer*>( GetSizer() ) ),
327 m_dlg( aDlg )
328{
332
333 Connect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_ASSIGNMENT::onMenu ), nullptr, this );
334}
335
336
338{
339 Disconnect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_ASSIGNMENT::onMenu ), nullptr, this );
340}
341
342
344{
345 COMPONENT_CLASS_ASSIGNMENT_DATA assignmentData;
346 assignmentData.SetComponentClass( GetComponentClass() );
348
349 for( const auto& condition : GetConditions() )
350 {
351 assignmentData.AddCondition( condition->GetConditionType(), condition->GetPrimaryField(),
352 condition->GetSecondaryField() );
353 }
354
355 return assignmentData;
356}
357
358
360{
361 wxMenu menu;
362 menu.Append( ID_REFERENCE, _( "Add Reference Condition" ) );
363 menu.Append( ID_FOOTPRINT, _( "Add Footprint Condition" ) );
364 menu.Append( ID_SIDE, _( "Add Side Condition" ) );
365 menu.Append( ID_ROTATION, _( "Add Rotation Condition" ) );
366 menu.Append( ID_FOOTPRINT_FIELD, _( "Add Footprint Field Value Condition" ) );
367 menu.Append( ID_SHEET_NAME, _( "Add Sheet Condition" ) );
368 menu.Append( ID_CUSTOM, _( "Add Custom Expression Condition" ) );
369 PopupMenu( &menu );
370}
371
372
374{
375 m_parentPanel->RemoveAssignment( this );
376}
377
378
379void PANEL_COMPONENT_CLASS_ASSIGNMENT::SetComponentClass( const wxString& aComponentClass ) const
380{
381 m_componentClass->SetValue( aComponentClass );
382}
383
384
386{
387 return m_componentClass->GetValue();
388}
389
390
421
422
425{
426 wxPanel* panelToAdd = nullptr;
427
428 switch( aCondition )
429 {
431 {
433 refsPanel->SetSelectionRefs( m_parentPanel->GetSelectionRefs() );
434 panelToAdd = refsPanel;
435 break;
436 }
438 {
439 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT( this, m_dlg );
440 break;
441 }
443 {
444 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_SIDE( this );
445 break;
446 }
448 {
449 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_ROTATION( this );
450 break;
451 }
453 {
455 fieldPanel->SetFieldsList( m_parentPanel->GetFieldNames() );
456 panelToAdd = fieldPanel;
457 break;
458 }
460 {
461 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_CUSTOM( this );
462 break;
463 }
465 {
467 sheetPanel->SetSheetsList( m_parentPanel->GetSheetNames() );
468 panelToAdd = sheetPanel;
469 break;
470 }
471 }
472
473 const size_t numItems = m_matchesList->GetItemCount();
474 m_matchesList->Insert( numItems - 1, panelToAdd, 0, wxEXPAND | wxALL, 5 );
475 Layout();
476 GetParent()->Layout();
477 m_parentPanel->Layout();
478
479 CONDITION_DATA* conditionIface = dynamic_cast<CONDITION_DATA*>( panelToAdd );
480 m_matches.push_back( conditionIface );
481
482 return conditionIface;
483}
484
485
487{
488 if( CONDITION_DATA* matchData = dynamic_cast<CONDITION_DATA*>( aMatch ) )
489 m_matches.erase( std::ranges::find( m_matches, matchData ) );
490
491 m_matchesList->Detach( aMatch );
492 aMatch->Destroy();
493 Layout();
494 m_parentPanel->Layout();
495}
496
497
500{
502 {
503 m_radioAll->SetValue( true );
504 m_radioAny->SetValue( false );
505 }
506 else
507 {
508 m_radioAll->SetValue( false );
509 m_radioAny->SetValue( true );
510 }
511}
512
513
522
523
525{
526 PCB_EDIT_FRAME* frame = m_parentPanel->GetFrame();
527 BOARD* board = dynamic_cast<BOARD*>( frame->GetModel() );
529
531 const std::shared_ptr<COMPONENT_CLASS_ASSIGNMENT_RULE> rule =
532 board->GetComponentClassManager().CompileAssignmentRule( assignment );
533
534 if( !rule )
535 return;
536
537 for( FOOTPRINT* fp : board->Footprints() )
538 {
539 if( rule->Matches( fp ) )
540 selTool->BrightenItem( fp );
541 else
542 selTool->UnbrightenItem( fp );
543 }
544
545 frame->GetCanvas()->Refresh();
546}
547
548
549/**************************************************************************************************
550 *
551 * PANEL_COMPONENT_CLASS_CONDITION_* implementations
552 * These are the dynamically-added panels for each condition / match type
553 *
554 *************************************************************************************************/
555
559 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
560{
561 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
562
565
566 Connect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_CONDITION_REFERENCE::onMenu ), nullptr, this );
567}
568
569
571{
572 Disconnect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_CONDITION_REFERENCE::onMenu ), nullptr,
573 this );
574 m_panelParent->RemoveCondition( this );
575}
576
577
579{
580 wxMenu menu;
581 menu.Append( ID_IMPORT_REFS, _( "Import references from selection" ) );
582 menu.Enable( ID_IMPORT_REFS, !m_selectionRefs.empty() );
583 PopupMenu( &menu );
584}
585
586
588{
589 if( aEvent.GetId() != ID_IMPORT_REFS )
590 wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
591
592 if( m_selectionRefs.empty() )
593 return;
594
595 wxString refs = m_selectionRefs[0];
596
597 for( size_t i = 1; i < m_selectionRefs.size(); i++ )
598 {
599 refs += wxT( "," );
600 refs += m_selectionRefs[i];
601 }
602
603 m_refs->SetValue( refs );
604}
605
606
608 DIALOG_SHIM* aDlg ) :
611 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) ),
612 m_dlg( aDlg )
613{
614 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
615
618}
619
620
622{
623 m_panelParent->RemoveCondition( this );
624}
625
626
628{
629 wxString fpId = m_footprint->GetValue();
630
631 if( KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, m_dlg ) )
632 {
633 if( frame->ShowModal( &fpId, this ) )
634 {
635 m_footprint->SetValue( fpId );
636 }
637
638 frame->Destroy();
639 }
640}
641
642
646 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
647{
648 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
649
651 m_side->Append( wxT( "Any" ) );
652 m_side->Append( wxT( "Front" ) );
653 m_side->Append( wxT( "Back" ) );
654 m_side->SetValue( wxT( "Any" ) );
655}
656
657
659{
660 m_panelParent->RemoveCondition( this );
661}
662
663
666 CONDITION_DATA( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::ROTATION, m_rotation ),
667 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
668{
669 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
670 m_rotUnit->SetLabel( wxT( "°" ) );
671
673 m_rotation->Append( wxT( "Any" ) );
674 m_rotation->Append( wxT( "0" ) );
675 m_rotation->Append( wxT( "90" ) );
676 m_rotation->Append( wxT( "180" ) );
677 m_rotation->Append( wxT( "-90" ) );
678 m_rotation->SetValue( wxT( "Any" ) );
679}
680
681
683{
684 m_panelParent->RemoveCondition( this );
685}
686
687
690 CONDITION_DATA( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::FOOTPRINT_FIELD, m_fieldName, m_fieldValue ),
691 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
692{
693 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
694
696}
697
698
700{
701 m_panelParent->RemoveCondition( this );
702}
703
704
705void PANEL_COMPONENT_CLASS_CONDITION_FIELD::SetFieldsList( const std::vector<wxString>& aFields )
706{
707 m_fieldName->Append( aFields );
708}
709
710
714 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
715{
716 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
717
719}
720
721
723{
724 m_panelParent->RemoveCondition( this );
725}
726
727
731 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
732{
733 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
734
736}
737
738
740{
741 m_panelParent->RemoveCondition( this );
742}
743
744
745void PANEL_COMPONENT_CLASS_CONDITION_SHEET::SetSheetsList( const std::vector<wxString>& aSheets )
746{
747 m_sheetName->Append( aSheets );
748}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
const FOOTPRINTS & Footprints() const
Definition board.h:420
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
Definition board.h:1521
void AddCondition(const CONDITION_TYPE aCondition, const wxString &aPrimaryData, const wxString &aSecondaryData)
Sets the given condition type with the assocated match data.
void SetConditionsOperation(const CONDITIONS_OPERATOR aOperator)
Sets the boolean operation in use for all conditions.
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.
CONDITION_DATA(const COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE aCondition, wxTextEntry *aPrimary, wxTextEntry *aSecondary=nullptr)
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:65
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:96
wxString GetReferenceAsString() const
Definition footprint.h:850
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
PANEL_ASSIGN_COMPONENT_CLASSES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxPoint(-1000,-1000), const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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< 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.
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)
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.
PANEL_COMPONENT_CLASS_ASSIGNMENT_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxPoint(-1000,-1000), const wxSize &size=wxSize(-1,-1), long style=wxBORDER_RAISED|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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.
PANEL_COMPONENT_CLASS_CONDITION_CUSTOM_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxPoint(-1000,-1000), const wxSize &size=wxSize(-1,-1), long style=wxBORDER_RAISED|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
Configures matching based on a custom DRC expression.
void OnDeleteConditionClick(wxCommandEvent &event) override
PANEL_COMPONENT_CLASS_CONDITION_FIELD_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxPoint(-1000,-1000), const wxSize &size=wxSize(-1,-1), long style=wxBORDER_RAISED|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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)
PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxPoint(-1000,-1000), const wxSize &size=wxSize(-1,-1), long style=wxBORDER_RAISED|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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)
PANEL_COMPONENT_CLASS_CONDITION_REFERENCE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxPoint(-1000,-1000), const wxSize &size=wxSize(-1,-1), long style=wxBORDER_RAISED|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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)
PANEL_COMPONENT_CLASS_CONDITION_ROTATION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxPoint(-1000,-1000), const wxSize &size=wxSize(-1,-1), long style=wxBORDER_RAISED|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
Configures matching based on footprint rotation.
void OnDeleteConditionClick(wxCommandEvent &event) override
PANEL_COMPONENT_CLASS_CONDITION_SHEET_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxPoint(-1000,-1000), const wxSize &size=wxSize(-1,-1), long style=wxBORDER_RAISED|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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
PANEL_COMPONENT_CLASS_CONDITION_SIDE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxPoint(-1000,-1000), const wxSize &size=wxSize(-1,-1), long style=wxBORDER_RAISED|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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
The selection tool: currently supports:
void BrightenItem(EDA_ITEM *aItem)
void UnbrightenItem(EDA_ITEM *aItem)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
#define _(s)
@ FRAME_FOOTPRINT_CHOOSER
Definition frame_type.h:40
STL namespace.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:79