51 std::shared_ptr<COMPONENT_CLASS_SETTINGS> aSettings,
DIALOG_SHIM* aDlg ) :
53 m_componentClassSettings(
std::
move( aSettings ) ),
54 m_assignmentsList( static_cast<wxBoxSizer*>( m_assignmentsScrollWindow->GetSizer() ) )
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;
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;
97 std::set<wxString> refsSet;
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;
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(
"" ) );
329 m_matchesList( static_cast<wxStaticBoxSizer*>( GetSizer() ) ), m_dlg( aDlg )
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 } );
609 Disconnect( wxEVT_MENU,
618 menu.Append(
ID_IMPORT_REFS,
_(
"Import references from selection" ) );
627 wxFAIL_MSG( wxT(
"Unknown ID in context menu event" ) );
650 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
669 if( frame->ShowModal( &fpId,
this ) )
684 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
687 m_side->Append( wxT(
"Any" ) );
688 m_side->Append( wxT(
"Front" ) );
689 m_side->Append( wxT(
"Back" ) );
690 m_side->SetValue( wxT(
"Any" ) );
701 wxWindow* aParent ) :
706 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
728 m_fieldName, m_fieldValue ),
731 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
750 wxWindow* aParent ) :
756 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) ).x, -1 } );
773 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.
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.
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...
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
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.
wxScrolledWindow * m_assignmentsScrollWindow
wxCheckBox * m_assignSheetClasses
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)
~PANEL_ASSIGN_COMPONENT_CLASSES() override
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.
wxRadioButton * m_radioAll
wxTextCtrl * m_componentClass
wxRadioButton * m_radioAny
STD_BITMAP_BUTTON * m_buttonDeleteAssignment
STD_BITMAP_BUTTON * m_buttonAddCondition
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.
Class PANEL_COMPONENT_CLASS_CONDITION_CUSTOM_BASE.
STD_BITMAP_BUTTON * m_buttonDeleteMatch
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)
Class PANEL_COMPONENT_CLASS_CONDITION_FIELD_BASE.
STD_BITMAP_BUTTON * m_buttonDeleteMatch
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)
Class PANEL_COMPONENT_CLASS_CONDITION_REFERENCE_BASE.
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
Class PANEL_COMPONENT_CLASS_CONDITION_ROTATION_BASE.
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)
Class PANEL_COMPONENT_CLASS_CONDITION_SHEET_BASE.
STD_BITMAP_BUTTON * m_buttonDeleteMatch
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
Class PANEL_COMPONENT_CLASS_CONDITION_SIDE_BASE.
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
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
@ FRAME_FOOTPRINT_CHOOSER
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint