KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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, 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
25#ifndef PANEL_ASSIGN_COMPONENT_CLASSES_H
26#define PANEL_ASSIGN_COMPONENT_CLASSES_H
27
28
30
31#include <unordered_set>
32#include <vector>
33
34#include <dialog_shim.h>
35#include <pcb_edit_frame.h>
37
38
39/**************************************************************************************************
40 *
41 * PANEL_ASSIGN_COMPONENT_CLASSES
42 *
43 *************************************************************************************************/
44
50
52{
53public:
54 PANEL_ASSIGN_COMPONENT_CLASSES( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame,
55 std::shared_ptr<COMPONENT_CLASS_SETTINGS> aSettings,
56 DIALOG_SHIM* aDlg );
57
59
61 bool TransferDataToWindow() override;
62
64 bool TransferDataFromWindow() override;
65
67 void ImportSettingsFrom( const std::shared_ptr<COMPONENT_CLASS_SETTINGS>& aOtherSettings );
68
70 void OnAddAssignmentClick( wxCommandEvent& event ) override;
71
74
76 const std::vector<wxString>& GetSelectionRefs() const { return m_selectionRefs; }
77
79 const std::vector<wxString>& GetFieldNames() const { return m_fieldNames; }
80
82 const std::vector<wxString>& GetSheetNames() const { return m_sheetNames; }
83
85 PCB_EDIT_FRAME* GetFrame() const { return m_frame; }
86
88 bool Validate() override;
89
90private:
93
95 void scrollToAssignment( const PANEL_COMPONENT_CLASS_ASSIGNMENT* aAssignment ) const;
96
99
102
104 std::vector<PANEL_COMPONENT_CLASS_ASSIGNMENT*> m_assignments;
105
107 std::shared_ptr<COMPONENT_CLASS_SETTINGS> m_componentClassSettings;
108
110 std::vector<wxString> m_selectionRefs;
111
113 std::vector<wxString> m_fieldNames;
114
116 std::vector<wxString> m_sheetNames;
117
119 wxBoxSizer* m_assignmentsList;
120};
121
122
123/**************************************************************************************************
124 *
125 * CONDITION_DATA
126 *
127 *************************************************************************************************/
128
134{
135public:
137 wxTextEntry* aPrimary, wxTextEntry* aSecondary = nullptr ) :
138 m_conditionType( aCondition ), m_primaryCtrl( aPrimary ), m_secondaryCtrl( aSecondary )
139 {
140 }
141
142 virtual ~CONDITION_DATA() {};
143
146 {
147 return m_conditionType;
148 }
149
151 virtual wxString GetPrimaryField() const;
152
154 virtual void SetPrimaryField( const wxString& aVal );
155
157 virtual wxString GetSecondaryField() const;
158
161 virtual void SetSecondaryField( const wxString& aVal );
162
163private:
166
168 wxTextEntry* m_primaryCtrl;
169
171 wxTextEntry* m_secondaryCtrl;
172};
173
174
175/**************************************************************************************************
176 *
177 * PANEL_COMPONENT_CLASS_ASSIGNMENT
178 *
179 *************************************************************************************************/
180
185{
186public:
189 {
190 ID_REFERENCE = wxID_HIGHEST + 1,
197 };
198
199 PANEL_COMPONENT_CLASS_ASSIGNMENT( wxWindow* aParent,
200 PANEL_ASSIGN_COMPONENT_CLASSES* aPanelParent,
201 DIALOG_SHIM* aDlg );
203
205 void OnDeleteAssignmentClick( wxCommandEvent& event ) override;
206
208 void OnAddConditionClick( wxCommandEvent& event ) override;
209
211 void OnHighlightItemsClick( wxCommandEvent& event ) override;
212
215
218 void RemoveCondition( wxPanel* aMatch );
219
220 const std::vector<CONDITION_DATA*>& GetConditions() const { return m_matches; }
221
223 void SetComponentClass( const wxString& aComponentClass ) const;
224
226 const wxString GetComponentClass() const;
227
229 void
231
234
237
238protected:
240 void onMenu( wxCommandEvent& aEvent );
241
244
246 wxStaticBoxSizer* m_matchesList;
247
249 std::unordered_set<COMPONENT_CLASS_ASSIGNMENT_DATA::CONDITION_TYPE> m_conditionTypes;
250
253
255 std::vector<CONDITION_DATA*> m_matches;
256};
257
258
259/**************************************************************************************************
260 *
261 * PANEL_COMPONENT_CLASS_CONDITION_REFERENCE
262 *
263 *************************************************************************************************/
264
270 public CONDITION_DATA
271{
272public:
275 {
276 ID_IMPORT_REFS = wxID_HIGHEST + 1
277 };
278
279 explicit PANEL_COMPONENT_CLASS_CONDITION_REFERENCE( wxWindow* aParent );
280
281 void OnDeleteConditionClick( wxCommandEvent& event ) override;
282
283 void OnImportRefsClick( wxCommandEvent& event ) override;
284 void SetSelectionRefs( const std::vector<wxString>& aRefs ) { m_selectionRefs = aRefs; }
285
286protected:
288 void onMenu( wxCommandEvent& aEvent );
289
291 std::vector<wxString> m_selectionRefs;
292};
293
294
295/**************************************************************************************************
296 *
297 * PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT
298 *
299 *************************************************************************************************/
300
306 public CONDITION_DATA
307{
308public:
309 explicit PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT( wxWindow* aParent, DIALOG_SHIM* aDlg );
310
311 void OnDeleteConditionClick( wxCommandEvent& event ) override;
312 void OnShowLibraryClick( wxCommandEvent& event ) override;
313
314protected:
317};
318
319
320/**************************************************************************************************
321 *
322 * PANEL_COMPONENT_CLASS_CONDITION_SIDE
323 *
324 *************************************************************************************************/
325
330 public CONDITION_DATA
331{
332public:
333 explicit PANEL_COMPONENT_CLASS_CONDITION_SIDE( wxWindow* aParent );
334
335 void OnDeleteConditionClick( wxCommandEvent& event ) override;
336
337protected:
339};
340
341
342/**************************************************************************************************
343 *
344 * PANEL_COMPONENT_CLASS_CONDITION_ROTATION
345 *
346 *************************************************************************************************/
347
353 public CONDITION_DATA
354{
355public:
356 explicit PANEL_COMPONENT_CLASS_CONDITION_ROTATION( wxWindow* aParent );
357
358 void OnDeleteConditionClick( wxCommandEvent& event ) override;
359
360protected:
362};
363
364
365/**************************************************************************************************
366 *
367 * PANEL_COMPONENT_CLASS_CONDITION_FIELD
368 *
369 *************************************************************************************************/
370
375 public CONDITION_DATA
376{
377public:
378 explicit PANEL_COMPONENT_CLASS_CONDITION_FIELD( wxWindow* aParent );
379
380 void OnDeleteConditionClick( wxCommandEvent& event ) override;
381
382 void SetFieldsList( const std::vector<wxString>& aFields );
383
384protected:
386};
387
388
389/**************************************************************************************************
390 *
391 * PANEL_COMPONENT_CLASS_CONDITION_CUSTOM
392 *
393 *************************************************************************************************/
394
399 public CONDITION_DATA
400{
401public:
402 explicit PANEL_COMPONENT_CLASS_CONDITION_CUSTOM( wxWindow* aParent );
403
404 void OnDeleteConditionClick( wxCommandEvent& event ) override;
405
406protected:
408};
409
410
411/**************************************************************************************************
412 *
413 * PANEL_COMPONENT_CLASS_SHEET
414 *
415 *************************************************************************************************/
416
421 public CONDITION_DATA
422{
423public:
424 explicit PANEL_COMPONENT_CLASS_CONDITION_SHEET( wxWindow* aParent );
425
426 void OnDeleteConditionClick( wxCommandEvent& event ) override;
427
428 void SetSheetsList( const std::vector<wxString>& aSheets );
429
430protected:
432};
433
434#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:52
Class PANEL_ASSIGN_COMPONENT_CLASSES_BASE.
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.
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.
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.
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.
ADD_MATCH_POPUP
IDs for match type popup menu.
DIALOG_SHIM * m_dlg
The parent configuration dialog.
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.
Configures matching based on a custom DRC expression.
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
void OnDeleteConditionClick(wxCommandEvent &event) override
Class PANEL_COMPONENT_CLASS_CONDITION_FIELD_BASE.
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)
Class PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT_BASE.
Configures matching based on footprint library identifier.
void OnShowLibraryClick(wxCommandEvent &event) override
void OnDeleteConditionClick(wxCommandEvent &event) override
Class PANEL_COMPONENT_CLASS_CONDITION_REFERENCE_BASE.
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)
void OnImportRefsClick(wxCommandEvent &event) override
Class PANEL_COMPONENT_CLASS_CONDITION_ROTATION_BASE.
Configures matching based on footprint rotation.
void OnDeleteConditionClick(wxCommandEvent &event) override
Class PANEL_COMPONENT_CLASS_CONDITION_SHEET_BASE.
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
Class PANEL_COMPONENT_CLASS_CONDITION_SIDE_BASE.
Configures matching based on which side of the board a footprint is on.
void OnDeleteConditionClick(wxCommandEvent &event) override
PANEL_COMPONENT_CLASS_ASSIGNMENT * m_panelParent
The main frame for Pcbnew.