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() )
74 wxCHECK2( field, continue );
76 fieldsSet.insert( field->GetName() );
81 std::vector<wxString> fieldNames( fieldsSet.begin(), fieldsSet.end() );
82 std::ranges::sort( fieldNames,
83 [](
const wxString& a,
const wxString& b )
85 return a.Cmp( b ) < 0;
88 m_fieldNames = std::move( fieldNames );
91 std::vector<wxString> sheetNames( sheetsSet.begin(), sheetsSet.end() );
92 std::ranges::sort( sheetNames,
93 [](
const wxString& a,
const wxString& b )
95 return a.Cmp( b ) < 0;
98 m_sheetNames = std::move( sheetNames );
101 std::set<wxString> refsSet;
103 for(
const EDA_ITEM* item : m_frame->GetCurrentSelection() )
110 refsSet.insert( ref );
113 std::vector<wxString> refs( refsSet.begin(), refsSet.end() );
114 std::ranges::sort( refs,
115 [](
const wxString& a,
const wxString& b )
117 return a.Cmp( b ) < 0;
120 m_selectionRefs = std::move( refs );
132 m_frame->GetCanvas()->Refresh();
148 for(
const auto& [conditionType, primaryData, secondaryData] : assignmentData.GetConditions() )
188 const std::shared_ptr<COMPONENT_CLASS_ASSIGNMENT_RULE> rule =
193 const wxString msg = wxString::Format(
_(
"Error with conditions for component class assignment %s" ),
194 assignment->GetComponentClass() );
197 assignment->SetFocus();
221 m_assignmentsList->Add( assignmentPanel, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
228 return assignmentPanel;
236 const wxPoint panelPosition = aAssignment->GetPosition();
237 const wxSize panelSize = aAssignment->GetClientSize();
253 const std::shared_ptr<COMPONENT_CLASS_SETTINGS>& aOtherSettings )
279 data.Replace( wxT(
"\"" ), wxT(
"" ) );
280 data.Replace( wxT(
"'" ), wxT(
"" ) );
296 return wxEmptyString;
304 data.Replace( wxT(
"\"" ), wxT(
"" ) );
305 data.Replace( wxT(
"'" ), wxT(
"" ) );
330 m_matchesList( static_cast<wxStaticBoxSizer*>( GetSizer() ) ),
355 assignmentData.
AddCondition( condition->GetConditionType(), condition->GetPrimaryField(),
356 condition->GetSecondaryField() );
359 return assignmentData;
368 menu.Append(
ID_SIDE,
_(
"Add Side Condition" ) );
369 menu.Append(
ID_ROTATION,
_(
"Add Rotation Condition" ) );
372 menu.Append(
ID_CUSTOM,
_(
"Add Custom Expression Condition" ) );
397 switch( aEvent.GetId() )
422 wxFAIL_MSG( wxT(
"Unknown ID in context menu event" ) );
430 wxPanel* panelToAdd =
nullptr;
438 panelToAdd = refsPanel;
460 panelToAdd = fieldPanel;
472 panelToAdd = sheetPanel;
478 m_matchesList->Insert( numItems - 1, panelToAdd, 0, wxEXPAND | wxALL, 5 );
480 GetParent()->Layout();
486 return conditionIface;
535 const std::shared_ptr<COMPONENT_CLASS_ASSIGNMENT_RULE> rule =
543 if( rule->Matches( fp ) )
565 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) + wxS(
"M" ) ).x, -1 } );
585 menu.Append(
ID_IMPORT_REFS,
_(
"Import references from selection" ) );
594 wxFAIL_MSG( wxT(
"Unknown ID in context menu event" ) );
618 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) + wxS(
"M" ) ).x, -1 } );
637 if( frame->ShowModal( &fpId,
this ) )
652 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) + wxS(
"M" ) ).x, -1 } );
655 m_side->Append( wxT(
"Any" ) );
656 m_side->Append( wxT(
"Front" ) );
657 m_side->Append( wxT(
"Back" ) );
658 m_side->SetValue( wxT(
"Any" ) );
673 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) + wxS(
"M" ) ).x, -1 } );
697 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) + wxS(
"M" ) ).x, -1 } );
720 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) + wxS(
"M" ) ).x, -1 } );
737 m_title->SetMinSize( { GetTextExtent(
_(
"Footprint Field:" ) + wxS(
"M" ) ).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 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.
CONDITION_TYPE
A condition match type.
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)
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)
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< 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
STD_BITMAP_BUTTON * m_buttonHighlightItems
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_ASSIGNMENT()
STD_BITMAP_BUTTON * m_buttonDeleteMatch
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)
wxTextCtrl * m_customCondition
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)
STD_BITMAP_BUTTON * m_buttonDeleteMatch
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)
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)
STD_BITMAP_BUTTON * m_buttonDeleteMatch
STD_BITMAP_BUTTON * m_buttonImportRefs
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.
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
STD_BITMAP_BUTTON * m_buttonDeleteMatch
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_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=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_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=wxPoint(-1000,-1000), const wxSize &size=wxSize(-1,-1), long style=wxBORDER_RAISED|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