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, 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 {
74 wxCHECK2( field, continue );
75
76 fieldsSet.insert( field->GetName() );
77 }
78 }
79
80 // Sort field names
81 std::vector<wxString> fieldNames( fieldsSet.begin(), fieldsSet.end() );
82 std::ranges::sort( fieldNames,
83 []( const wxString& a, const wxString& b )
84 {
85 return a.Cmp( b ) < 0;
86 } );
87
88 m_fieldNames = std::move( fieldNames );
89
90 // Sort sheet names
91 std::vector<wxString> sheetNames( sheetsSet.begin(), sheetsSet.end() );
92 std::ranges::sort( sheetNames,
93 []( const wxString& a, const wxString& b )
94 {
95 return a.Cmp( b ) < 0;
96 } );
97
98 m_sheetNames = std::move( sheetNames );
99
100 // Get references of currently selected items
101 std::set<wxString> refsSet;
102
103 for( const EDA_ITEM* item : m_frame->GetCurrentSelection() )
104 {
105 if( item->Type() != PCB_FOOTPRINT_T )
106 continue;
107
108 const FOOTPRINT* fp = static_cast<const FOOTPRINT*>( item );
109 wxString ref = fp->GetReferenceAsString();
110 refsSet.insert( ref );
111 }
112
113 std::vector<wxString> refs( refsSet.begin(), refsSet.end() );
114 std::ranges::sort( refs,
115 []( const wxString& a, const wxString& b )
116 {
117 return a.Cmp( b ) < 0;
118 } );
119
120 m_selectionRefs = std::move( refs );
121}
122
123
125{
126 BOARD* board = dynamic_cast<BOARD*>( m_frame->GetModel() );
127 PCB_SELECTION_TOOL* selTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
128
129 for( FOOTPRINT* fp : board->Footprints() )
130 selTool->UnbrightenItem( fp );
131
132 m_frame->GetCanvas()->Refresh();
133}
134
135
137{
138 // Load sheet-level settings
139 m_assignSheetClasses->SetValue( m_componentClassSettings->GetEnableSheetComponentClasses() );
140
141 // Load dynamic component class assignments
142 for( const auto& assignmentData : m_componentClassSettings->GetComponentClassAssignments() )
143 {
145 assignment->SetComponentClass( assignmentData.GetComponentClass() );
146 assignment->SetConditionsOperator( assignmentData.GetConditionsOperator() );
147
148 for( const auto& [conditionType, primaryData, secondaryData] : assignmentData.GetConditions() )
149 {
150 CONDITION_DATA* match = assignment->AddCondition( conditionType );
151 match->SetPrimaryField( primaryData );
152 match->SetSecondaryField( secondaryData );
153 }
154 }
155
156 return true;
157}
158
159
161{
162 if( !Validate() )
163 return false;
164
165 // Save sheet-level settings
166 m_componentClassSettings->SetEnableSheetComponentClasses( m_assignSheetClasses->GetValue() );
167
168 // Save dynamic component class assignments
169 m_componentClassSettings->ClearComponentClassAssignments();
170
171 for( const auto assignment : m_assignments )
172 {
173 COMPONENT_CLASS_ASSIGNMENT_DATA assignmentData = assignment->GenerateAssignmentData();
174 m_componentClassSettings->AddComponentClassAssignment( assignmentData );
175 }
176
177 return true;
178}
179
180
182{
183 GetFrame()->GetCanvas()->Refresh();
184
186 {
187 const COMPONENT_CLASS_ASSIGNMENT_DATA assignmentData = assignment->GenerateAssignmentData();
188 const std::shared_ptr<COMPONENT_CLASS_ASSIGNMENT_RULE> rule =
190
191 if( !rule )
192 {
193 const wxString msg = wxString::Format( _( "Error with conditions for component class assignment %s" ),
194 assignment->GetComponentClass() );
195 PAGED_DIALOG::GetDialog( this )->SetError( msg, this, assignment );
196 scrollToAssignment( assignment );
197 assignment->SetFocus();
198 return false;
199 }
200 }
201
202 return true;
203}
204
205
207{
209 scrollToAssignment( assignment );
210}
211
212
214{
215 PANEL_COMPONENT_CLASS_ASSIGNMENT* assignmentPanel =
217
218#if __OSX__
219 m_assignmentsList->Add( assignmentPanel, 0, wxEXPAND, 5 );
220#else
221 m_assignmentsList->Add( assignmentPanel, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
222#endif
223
224 Layout();
225
226 m_assignments.push_back( assignmentPanel );
227
228 return assignmentPanel;
229}
230
231
233 const PANEL_COMPONENT_CLASS_ASSIGNMENT* aAssignment ) const
234{
235 const wxPoint viewStart = m_assignmentsScrollWindow->GetViewStart();
236 const wxPoint panelPosition = aAssignment->GetPosition();
237 const wxSize panelSize = aAssignment->GetClientSize();
238
239 m_assignmentsScrollWindow->Scroll( viewStart.x, panelPosition.y + panelSize.y );
240}
241
242
244{
245 m_assignments.erase( std::ranges::find( m_assignments, aPanel ) );
246 m_assignmentsList->Detach( aPanel );
247 aPanel->Destroy();
248 Layout();
249}
250
251
253 const std::shared_ptr<COMPONENT_CLASS_SETTINGS>& aOtherSettings )
254{
255 std::shared_ptr<COMPONENT_CLASS_SETTINGS> savedSettings = m_componentClassSettings;
256
257 m_componentClassSettings = aOtherSettings;
259
260 m_componentClassSettings = std::move( savedSettings );
261}
262
263
264/**************************************************************************************************
265 *
266 * CONDITION_DATA implementation
267 * Provides a common interface for all condition panel types
268 *
269 *************************************************************************************************/
270
272{
273 wxString data = m_primaryCtrl->GetValue();
274 data.Trim( true );
275 data.Trim( false );
276
278 {
279 data.Replace( wxT( "\"" ), wxT( "" ) );
280 data.Replace( wxT( "'" ), wxT( "" ) );
281 }
282
283 return data;
284}
285
286
287void CONDITION_DATA::SetPrimaryField( const wxString& aVal )
288{
289 m_primaryCtrl->SetValue( aVal );
290}
291
292
294{
295 if( !m_secondaryCtrl )
296 return wxEmptyString;
297
298 wxString data = m_secondaryCtrl->GetValue();
299 data.Trim( true );
300 data.Trim( false );
301
303 {
304 data.Replace( wxT( "\"" ), wxT( "" ) );
305 data.Replace( wxT( "'" ), wxT( "" ) );
306 }
307
308 return data;
309}
310
311
312void CONDITION_DATA::SetSecondaryField( const wxString& aVal )
313{
314 if( m_secondaryCtrl )
315 m_secondaryCtrl->SetValue( aVal );
316};
317
318/**************************************************************************************************
319 *
320 * PANEL_COMPONENT_CLASS_ASSIGNMENT implementation
321 * This is the dynamically-added panel for each component class assignment rule set
322 *
323 *************************************************************************************************/
324
326 PANEL_ASSIGN_COMPONENT_CLASSES* aPanelParent,
327 DIALOG_SHIM* aDlg ) :
329 m_parentPanel( aPanelParent ),
330 m_matchesList( static_cast<wxStaticBoxSizer*>( GetSizer() ) ),
331 m_dlg( aDlg )
332{
336
337 Connect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_ASSIGNMENT::onMenu ), nullptr, this );
338}
339
340
342{
343 Disconnect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_ASSIGNMENT::onMenu ), 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.AddCondition( condition->GetConditionType(), condition->GetPrimaryField(),
356 condition->GetSecondaryField() );
357 }
358
359 return assignmentData;
360}
361
362
364{
365 wxMenu menu;
366 menu.Append( ID_REFERENCE, _( "Add Reference Condition" ) );
367 menu.Append( ID_FOOTPRINT, _( "Add Footprint Condition" ) );
368 menu.Append( ID_SIDE, _( "Add Side Condition" ) );
369 menu.Append( ID_ROTATION, _( "Add Rotation Condition" ) );
370 menu.Append( ID_FOOTPRINT_FIELD, _( "Add Footprint Field Value Condition" ) );
371 menu.Append( ID_SHEET_NAME, _( "Add Sheet Condition" ) );
372 menu.Append( ID_CUSTOM, _( "Add Custom Expression Condition" ) );
373 PopupMenu( &menu );
374}
375
376
378{
379 m_parentPanel->RemoveAssignment( this );
380}
381
382
383void PANEL_COMPONENT_CLASS_ASSIGNMENT::SetComponentClass( const wxString& aComponentClass ) const
384{
385 m_componentClass->SetValue( aComponentClass );
386}
387
388
390{
391 return m_componentClass->GetValue();
392}
393
394
425
426
429{
430 wxPanel* panelToAdd = nullptr;
431
432 switch( aCondition )
433 {
435 {
437 refsPanel->SetSelectionRefs( m_parentPanel->GetSelectionRefs() );
438 panelToAdd = refsPanel;
439 break;
440 }
442 {
443 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT( this, m_dlg );
444 break;
445 }
447 {
448 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_SIDE( this );
449 break;
450 }
452 {
453 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_ROTATION( this );
454 break;
455 }
457 {
459 fieldPanel->SetFieldsList( m_parentPanel->GetFieldNames() );
460 panelToAdd = fieldPanel;
461 break;
462 }
464 {
465 panelToAdd = new PANEL_COMPONENT_CLASS_CONDITION_CUSTOM( this );
466 break;
467 }
469 {
471 sheetPanel->SetSheetsList( m_parentPanel->GetSheetNames() );
472 panelToAdd = sheetPanel;
473 break;
474 }
475 }
476
477 const size_t numItems = m_matchesList->GetItemCount();
478 m_matchesList->Insert( numItems - 1, panelToAdd, 0, wxEXPAND | wxALL, 5 );
479 Layout();
480 GetParent()->Layout();
481 m_parentPanel->Layout();
482
483 CONDITION_DATA* conditionIface = dynamic_cast<CONDITION_DATA*>( panelToAdd );
484 m_matches.push_back( conditionIface );
485
486 return conditionIface;
487}
488
489
491{
492 if( CONDITION_DATA* matchData = dynamic_cast<CONDITION_DATA*>( aMatch ) )
493 m_matches.erase( std::ranges::find( m_matches, matchData ) );
494
495 m_matchesList->Detach( aMatch );
496 aMatch->Destroy();
497 Layout();
498 m_parentPanel->Layout();
499}
500
501
504{
506 {
507 m_radioAll->SetValue( true );
508 m_radioAny->SetValue( false );
509 }
510 else
511 {
512 m_radioAll->SetValue( false );
513 m_radioAny->SetValue( true );
514 }
515}
516
517
526
527
529{
530 PCB_EDIT_FRAME* frame = m_parentPanel->GetFrame();
531 BOARD* board = dynamic_cast<BOARD*>( frame->GetModel() );
533
535 const std::shared_ptr<COMPONENT_CLASS_ASSIGNMENT_RULE> rule =
536 board->GetComponentClassManager().CompileAssignmentRule( assignment );
537
538 if( !rule )
539 return;
540
541 for( FOOTPRINT* fp : board->Footprints() )
542 {
543 if( rule->Matches( fp ) )
544 selTool->BrightenItem( fp );
545 else
546 selTool->UnbrightenItem( fp );
547 }
548
549 frame->GetCanvas()->Refresh();
550}
551
552
553/**************************************************************************************************
554 *
555 * PANEL_COMPONENT_CLASS_CONDITION_* implementations
556 * These are the dynamically-added panels for each condition / match type
557 *
558 *************************************************************************************************/
559
563 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
564{
565 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
566
569
570 Connect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_CONDITION_REFERENCE::onMenu ), nullptr, this );
571}
572
573
575{
576 Disconnect( wxEVT_MENU, wxCommandEventHandler( PANEL_COMPONENT_CLASS_CONDITION_REFERENCE::onMenu ), nullptr,
577 this );
578 m_panelParent->RemoveCondition( this );
579}
580
581
583{
584 wxMenu menu;
585 menu.Append( ID_IMPORT_REFS, _( "Import references from selection" ) );
586 menu.Enable( ID_IMPORT_REFS, !m_selectionRefs.empty() );
587 PopupMenu( &menu );
588}
589
590
592{
593 if( aEvent.GetId() != ID_IMPORT_REFS )
594 wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
595
596 if( m_selectionRefs.empty() )
597 return;
598
599 wxString refs = m_selectionRefs[0];
600
601 for( size_t i = 1; i < m_selectionRefs.size(); i++ )
602 {
603 refs += wxT( "," );
604 refs += m_selectionRefs[i];
605 }
606
607 m_refs->SetValue( refs );
608}
609
610
612 DIALOG_SHIM* aDlg ) :
615 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) ),
616 m_dlg( aDlg )
617{
618 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
619
622}
623
624
626{
627 m_panelParent->RemoveCondition( this );
628}
629
630
632{
633 wxString fpId = m_footprint->GetValue();
634
635 if( KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_FOOTPRINT_CHOOSER, true, m_dlg ) )
636 {
637 if( frame->ShowModal( &fpId, this ) )
638 {
639 m_footprint->SetValue( fpId );
640 }
641
642 frame->Destroy();
643 }
644}
645
646
650 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
651{
652 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
653
655 m_side->Append( wxT( "Any" ) );
656 m_side->Append( wxT( "Front" ) );
657 m_side->Append( wxT( "Back" ) );
658 m_side->SetValue( wxT( "Any" ) );
659}
660
661
663{
664 m_panelParent->RemoveCondition( this );
665}
666
667
670 CONDITION_DATA( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::ROTATION, m_rotation ),
671 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
672{
673 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
674 m_rotUnit->SetLabel( wxT( "°" ) );
675
677 m_rotation->Append( wxT( "Any" ) );
678 m_rotation->Append( wxT( "0" ) );
679 m_rotation->Append( wxT( "90" ) );
680 m_rotation->Append( wxT( "180" ) );
681 m_rotation->Append( wxT( "-90" ) );
682 m_rotation->SetValue( wxT( "Any" ) );
683}
684
685
687{
688 m_panelParent->RemoveCondition( this );
689}
690
691
694 CONDITION_DATA( COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE::FOOTPRINT_FIELD, m_fieldName, m_fieldValue ),
695 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
696{
697 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
698
700}
701
702
704{
705 m_panelParent->RemoveCondition( this );
706}
707
708
709void PANEL_COMPONENT_CLASS_CONDITION_FIELD::SetFieldsList( const std::vector<wxString>& aFields )
710{
711 m_fieldName->Append( aFields );
712}
713
714
718 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
719{
720 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
721
723}
724
725
727{
728 m_panelParent->RemoveCondition( this );
729}
730
731
735 m_panelParent( static_cast<PANEL_COMPONENT_CLASS_ASSIGNMENT*>( aParent ) )
736{
737 m_title->SetMinSize( { GetTextExtent( _( "Footprint Field:" ) + wxS( "M" ) ).x, -1 } );
738
740}
741
742
744{
745 m_panelParent->RemoveCondition( this );
746}
747
748
749void PANEL_COMPONENT_CLASS_CONDITION_SHEET::SetSheetsList( const std::vector<wxString>& aSheets )
750{
751 m_sheetName->Append( aSheets );
752}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
const FOOTPRINTS & Footprints() const
Definition board.h:363
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
Definition board.h:1407
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:68
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:98
wxString GetReferenceAsString() const
Definition footprint.h:760
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:44
STL namespace.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:86