51 std::shared_ptr<COMPONENT_CLASS_SETTINGS> aSettings,
DIALOG_SHIM* aDlg ) :
58 std::set<wxString> fieldsSet;
59 std::set<wxString> sheetsSet;
63 wxString sheetName = fp->GetSheetname();
65 if( !sheetName.empty() )
67 sheetName.Replace( wxT(
"\"" ), wxT(
"" ) );
68 sheetName.Replace( wxT(
"'" ), wxT(
"" ) );
69 sheetsSet.insert( fp->GetSheetname() );
72 for(
const PCB_FIELD* field : fp->GetFields() )
73 fieldsSet.insert( field->GetName() );
77 std::vector<wxString> fieldNames( fieldsSet.begin(), fieldsSet.end() );
78 std::ranges::sort( fieldNames,
79 [](
const wxString& a,
const wxString& b )
81 return a.Cmp( b ) < 0;
84 m_fieldNames = std::move( fieldNames );
87 std::vector<wxString> sheetNames( sheetsSet.begin(), sheetsSet.end() );
88 std::ranges::sort( sheetNames,
89 [](
const wxString& a,
const wxString& b )
91 return a.Cmp( b ) < 0;
94 m_sheetNames = std::move( sheetNames );
97 std::set<wxString> refsSet;
99 for(
const EDA_ITEM* item : m_frame->GetCurrentSelection() )
106 refsSet.insert( ref );
109 std::vector<wxString> refs( refsSet.begin(), refsSet.end() );
110 std::ranges::sort( refs,
111 [](
const wxString& a,
const wxString& b )
113 return a.Cmp( b ) < 0;
116 m_selectionRefs = std::move( refs );
128 m_frame->GetCanvas()->Refresh();
145 for(
const auto& [conditionType, conditionData] : assignmentData.GetConditions() )
188 const std::shared_ptr<COMPONENT_CLASS_ASSIGNMENT_RULE> rule =
193 const wxString msg = wxString::Format(
194 _(
"Error with conditions for component class assignment %s" ),
195 assignment->GetComponentClass() );
198 assignment->SetFocus();
222 m_assignmentsList->Add( assignmentPanel, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
229 return assignmentPanel;
237 const wxPoint panelPosition = aAssignment->GetPosition();
238 const wxSize panelSize = aAssignment->GetClientSize();
254 const std::shared_ptr<COMPONENT_CLASS_SETTINGS>& aOtherSettings )
280 data.Replace( wxT(
"\"" ), wxT(
"" ) );
281 data.Replace( wxT(
"'" ), wxT(
"" ) );
297 return wxEmptyString;
305 data.Replace( wxT(
"\"" ), wxT(
"" ) );
306 data.Replace( wxT(
"'" ), wxT(
"" ) );
355 assignmentData.
SetCondition( condition->GetConditionType(), condition->GetPrimaryField(),
356 condition->GetSecondaryField() );
359 return assignmentData;
373 menu.Append(
ID_SIDE,
_(
"Side..." ) );
416 switch( aEvent.GetId() )
436 default: wxFAIL_MSG( wxT(
"Unknown ID in context menu event" ) );
444 wxASSERT_MSG( !
m_conditionTypes.contains( aCondition ),
"Condition type already exists" );
446 wxPanel* panelToAdd =
nullptr;
455 panelToAdd = refsPanel;
482 panelToAdd = fieldPanel;
497 panelToAdd = sheetPanel;
504 m_matchesList->Insert( numItems - 1, panelToAdd, 0, wxEXPAND | wxTOP, 5 );
506 GetParent()->Layout();
512 return conditionIface;
564 const std::shared_ptr<COMPONENT_CLASS_ASSIGNMENT_RULE> rule =
572 if( rule->Matches( fp ) )
590 wxWindow* aParent ) :
595 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
607 Disconnect( wxEVT_MENU,
617 menu.Append(
ID_IMPORT_REFS,
_(
"Import references from selection" ) );
626 wxFAIL_MSG( wxT(
"Unknown ID in context menu event" ) );
649 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
668 if( frame->ShowModal( &fpId,
this ) )
683 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
686 m_side->Append( wxT(
"Any" ) );
687 m_side->Append( wxT(
"Front" ) );
688 m_side->Append( wxT(
"Back" ) );
689 m_side->SetValue( wxT(
"Any" ) );
700 wxWindow* aParent ) :
705 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
730 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
749 wxWindow* aParent ) :
755 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
772 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Information pertinent to a Pcbnew printed circuit board.
const FOOTPRINTS & Footprints() const
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
void SetConditionsOperation(const CONDITIONS_OPERATOR aOperator)
Sets the boolean operation in use for all conditions.
CONDITION_TYPE
A condition match type.
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.
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...
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.
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)
wxScrolledWindow * m_assignmentsScrollWindow
wxCheckBox * m_assignSheetClasses
PANEL_ASSIGN_COMPONENT_CLASSES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, 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)
~PANEL_ASSIGN_COMPONENT_CLASSES() override
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.
wxRadioButton * m_radioAll
wxTextCtrl * m_componentClass
wxRadioButton * m_radioAny
STD_BITMAP_BUTTON * m_buttonDeleteAssignment
STD_BITMAP_BUTTON * m_buttonAddCondition
PANEL_COMPONENT_CLASS_ASSIGNMENT_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxBORDER_SUNKEN|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
STD_BITMAP_BUTTON * m_buttonHighlightItems
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_ASSIGNMENT()
std::unordered_set< COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE > m_conditionTypes
Set containing all currently configured match condition types.
STD_BITMAP_BUTTON * m_buttonDeleteMatch
wxTextCtrl * m_customCondition
PANEL_COMPONENT_CLASS_CONDITION_CUSTOM_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxBORDER_SUNKEN|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
Configures matching based on a custom DRC expression.
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
void OnDeleteConditionClick(wxCommandEvent &event) override
PANEL_COMPONENT_CLASS_CONDITION_CUSTOM(wxWindow *aParent)
PANEL_COMPONENT_CLASS_CONDITION_FIELD_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxBORDER_SUNKEN|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
STD_BITMAP_BUTTON * m_buttonDeleteMatch
wxTextCtrl * m_fieldValue
Configures matching based on footprint field contents.
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
PANEL_COMPONENT_CLASS_CONDITION_FIELD(wxWindow *aParent)
void OnDeleteConditionClick(wxCommandEvent &event) override
void SetFieldsList(const std::vector< wxString > &aFields)
PANEL_COMPONENT_CLASS_CONDITION_REFERENCE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxBORDER_SUNKEN|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
STD_BITMAP_BUTTON * m_buttonDeleteMatch
STD_BITMAP_BUTTON * m_buttonImportRefs
Configures matching based on footprint reference.
std::vector< wxString > m_selectionRefs
void OnDeleteConditionClick(wxCommandEvent &event) override
PANEL_COMPONENT_CLASS_CONDITION_REFERENCE(wxWindow *aParent)
void onMenu(wxCommandEvent &aEvent)
Handles import references popup menu selections.
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
void SetSelectionRefs(const std::vector< wxString > &aRefs)
void OnImportRefsClick(wxCommandEvent &event) override
PANEL_COMPONENT_CLASS_CONDITION_ROTATION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(303, 65), long style=wxBORDER_SUNKEN|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
STD_BITMAP_BUTTON * m_buttonDeleteMatch
Configures matching based on footprint rotation.
void OnDeleteConditionClick(wxCommandEvent &event) override
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
PANEL_COMPONENT_CLASS_CONDITION_ROTATION(wxWindow *aParent)
STD_BITMAP_BUTTON * m_buttonDeleteMatch
PANEL_COMPONENT_CLASS_CONDITION_SHEET_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxBORDER_SUNKEN|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_CONDITION_SHEET(wxWindow *aParent)
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
PANEL_COMPONENT_CLASS_CONDITION_SIDE_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxBORDER_SUNKEN|wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
STD_BITMAP_BUTTON * m_buttonDeleteMatch
Configures matching based on which side of the board a footprint is on.
PANEL_COMPONENT_CLASS_CONDITION_SIDE(wxWindow *aParent)
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
@ FRAME_FOOTPRINT_CHOOSER
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint