KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_assign_component_classes.h
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
21#ifndef PANEL_ASSIGN_COMPONENT_CLASSES_H
22#define PANEL_ASSIGN_COMPONENT_CLASSES_H
23
24
26
27#include <unordered_set>
28#include <vector>
29
30#include <dialog_shim.h>
31#include <pcb_edit_frame.h>
33
34
35/**************************************************************************************************
36 *
37 * PANEL_ASSIGN_COMPONENT_CLASSES
38 *
39 *************************************************************************************************/
40
46
48{
49public:
50 PANEL_ASSIGN_COMPONENT_CLASSES( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame,
51 std::shared_ptr<COMPONENT_CLASS_SETTINGS> aSettings,
52 DIALOG_SHIM* aDlg );
53
55
57 bool TransferDataToWindow() override;
58
60 bool TransferDataFromWindow() override;
61
63 void ImportSettingsFrom( const std::shared_ptr<COMPONENT_CLASS_SETTINGS>& aOtherSettings );
64
66 void OnAddAssignmentClick( wxCommandEvent& event ) override;
67
70
72 const std::vector<wxString>& GetSelectionRefs() const { return m_selectionRefs; }
73
75 const std::vector<wxString>& GetFieldNames() const { return m_fieldNames; }
76
78 const std::vector<wxString>& GetSheetNames() const { return m_sheetNames; }
79
81 PCB_EDIT_FRAME* GetFrame() const { return m_frame; }
82
84 bool Validate() override;
85
86private:
89
91 void scrollToAssignment( const PANEL_COMPONENT_CLASS_ASSIGNMENT* aAssignment ) const;
92
95
98
100 std::vector<PANEL_COMPONENT_CLASS_ASSIGNMENT*> m_assignments;
101
103 std::shared_ptr<COMPONENT_CLASS_SETTINGS> m_componentClassSettings;
104
106 std::vector<wxString> m_selectionRefs;
107
109 std::vector<wxString> m_fieldNames;
110
112 std::vector<wxString> m_sheetNames;
113
115 wxBoxSizer* m_assignmentsList;
116};
117
118
119/**************************************************************************************************
120 *
121 * CONDITION_DATA
122 *
123 *************************************************************************************************/
124
130{
131public:
133 wxTextEntry* aPrimary, wxTextEntry* aSecondary = nullptr ) :
134 m_conditionType( aCondition ), m_primaryCtrl( aPrimary ), m_secondaryCtrl( aSecondary )
135 {
136 }
137
138 virtual ~CONDITION_DATA() {};
139
145
147 virtual wxString GetPrimaryField() const;
148
150 virtual void SetPrimaryField( const wxString& aVal );
151
153 virtual wxString GetSecondaryField() const;
154
157 virtual void SetSecondaryField( const wxString& aVal );
158
159private:
162
164 wxTextEntry* m_primaryCtrl;
165
167 wxTextEntry* m_secondaryCtrl;
168};
169
170
171/**************************************************************************************************
172 *
173 * PANEL_COMPONENT_CLASS_ASSIGNMENT
174 *
175 *************************************************************************************************/
176
181{
182public:
194
195 PANEL_COMPONENT_CLASS_ASSIGNMENT( wxWindow* aParent,
196 PANEL_ASSIGN_COMPONENT_CLASSES* aPanelParent,
197 DIALOG_SHIM* aDlg );
199
201 void OnDeleteAssignmentClick( wxCommandEvent& event ) override;
202
204 void OnAddConditionClick( wxCommandEvent& event ) override;
205
207 void OnHighlightItemsClick( wxCommandEvent& event ) override;
208
211
214 void RemoveCondition( wxPanel* aMatch );
215
216 const std::vector<CONDITION_DATA*>& GetConditions() const { return m_matches; }
217
219 void SetComponentClass( const wxString& aComponentClass ) const;
220
222 const wxString GetComponentClass() const;
223
225 void
227
230
233
234protected:
236 void onMenu( wxCommandEvent& aEvent );
237
240
242 wxStaticBoxSizer* m_matchesList;
243
246
248 std::vector<CONDITION_DATA*> m_matches;
249};
250
251
252/**************************************************************************************************
253 *
254 * PANEL_COMPONENT_CLASS_CONDITION_REFERENCE
255 *
256 *************************************************************************************************/
257
263 public CONDITION_DATA
264{
265public:
268 {
269 ID_IMPORT_REFS = wxID_HIGHEST + 1
270 };
271
272 explicit PANEL_COMPONENT_CLASS_CONDITION_REFERENCE( wxWindow* aParent );
273
274 void OnDeleteConditionClick( wxCommandEvent& event ) override;
275
276 void OnImportRefsClick( wxCommandEvent& event ) override;
277 void SetSelectionRefs( const std::vector<wxString>& aRefs ) { m_selectionRefs = aRefs; }
278
279protected:
281 void onMenu( wxCommandEvent& aEvent );
282
284 std::vector<wxString> m_selectionRefs;
285};
286
287
288/**************************************************************************************************
289 *
290 * PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT
291 *
292 *************************************************************************************************/
293
299 public CONDITION_DATA
300{
301public:
302 explicit PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT( wxWindow* aParent, DIALOG_SHIM* aDlg );
303
304 void OnDeleteConditionClick( wxCommandEvent& event ) override;
305 void OnShowLibraryClick( wxCommandEvent& event ) override;
306
307protected:
310};
311
312
313/**************************************************************************************************
314 *
315 * PANEL_COMPONENT_CLASS_CONDITION_SIDE
316 *
317 *************************************************************************************************/
318
323 public CONDITION_DATA
324{
325public:
326 explicit PANEL_COMPONENT_CLASS_CONDITION_SIDE( wxWindow* aParent );
327
328 void OnDeleteConditionClick( wxCommandEvent& event ) override;
329
330protected:
332};
333
334
335/**************************************************************************************************
336 *
337 * PANEL_COMPONENT_CLASS_CONDITION_ROTATION
338 *
339 *************************************************************************************************/
340
346 public CONDITION_DATA
347{
348public:
349 explicit PANEL_COMPONENT_CLASS_CONDITION_ROTATION( wxWindow* aParent );
350
351 void OnDeleteConditionClick( wxCommandEvent& event ) override;
352
353protected:
355};
356
357
358/**************************************************************************************************
359 *
360 * PANEL_COMPONENT_CLASS_CONDITION_FIELD
361 *
362 *************************************************************************************************/
363
368 public CONDITION_DATA
369{
370public:
371 explicit PANEL_COMPONENT_CLASS_CONDITION_FIELD( wxWindow* aParent );
372
373 void OnDeleteConditionClick( wxCommandEvent& event ) override;
374
375 void SetFieldsList( const std::vector<wxString>& aFields );
376
377protected:
379};
380
381
382/**************************************************************************************************
383 *
384 * PANEL_COMPONENT_CLASS_CONDITION_CUSTOM
385 *
386 *************************************************************************************************/
387
392 public CONDITION_DATA
393{
394public:
395 explicit PANEL_COMPONENT_CLASS_CONDITION_CUSTOM( wxWindow* aParent );
396
397 void OnDeleteConditionClick( wxCommandEvent& event ) override;
398
399protected:
401};
402
403
404/**************************************************************************************************
405 *
406 * PANEL_COMPONENT_CLASS_SHEET
407 *
408 *************************************************************************************************/
409
414 public CONDITION_DATA
415{
416public:
417 explicit PANEL_COMPONENT_CLASS_CONDITION_SHEET( wxWindow* aParent );
418
419 void OnDeleteConditionClick( wxCommandEvent& event ) override;
420
421 void SetSheetsList( const std::vector<wxString>& aSheets );
422
423protected:
425};
426
427#endif //PANEL_ASSIGN_COMPONENT_CLASSES_H
CONDITIONS_OPERATOR
Whether conditions are applied with OR or AND logic.
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 COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE GetConditionType() const
Gets the type of condition (e.g. Reference, Side) this data represents.
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
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< 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)
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.
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)
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)
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)
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)
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)
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)
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)
void OnDeleteConditionClick(wxCommandEvent &event) override
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
The main frame for Pcbnew.