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, 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
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:
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
250
252 std::vector<CONDITION_DATA*> m_matches;
253};
254
255
256/**************************************************************************************************
257 *
258 * PANEL_COMPONENT_CLASS_CONDITION_REFERENCE
259 *
260 *************************************************************************************************/
261
267 public CONDITION_DATA
268{
269public:
272 {
273 ID_IMPORT_REFS = wxID_HIGHEST + 1
274 };
275
276 explicit PANEL_COMPONENT_CLASS_CONDITION_REFERENCE( wxWindow* aParent );
277
278 void OnDeleteConditionClick( wxCommandEvent& event ) override;
279
280 void OnImportRefsClick( wxCommandEvent& event ) override;
281 void SetSelectionRefs( const std::vector<wxString>& aRefs ) { m_selectionRefs = aRefs; }
282
283protected:
285 void onMenu( wxCommandEvent& aEvent );
286
288 std::vector<wxString> m_selectionRefs;
289};
290
291
292/**************************************************************************************************
293 *
294 * PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT
295 *
296 *************************************************************************************************/
297
303 public CONDITION_DATA
304{
305public:
306 explicit PANEL_COMPONENT_CLASS_CONDITION_FOOTPRINT( wxWindow* aParent, DIALOG_SHIM* aDlg );
307
308 void OnDeleteConditionClick( wxCommandEvent& event ) override;
309 void OnShowLibraryClick( wxCommandEvent& event ) override;
310
311protected:
314};
315
316
317/**************************************************************************************************
318 *
319 * PANEL_COMPONENT_CLASS_CONDITION_SIDE
320 *
321 *************************************************************************************************/
322
327 public CONDITION_DATA
328{
329public:
330 explicit PANEL_COMPONENT_CLASS_CONDITION_SIDE( wxWindow* aParent );
331
332 void OnDeleteConditionClick( wxCommandEvent& event ) override;
333
334protected:
336};
337
338
339/**************************************************************************************************
340 *
341 * PANEL_COMPONENT_CLASS_CONDITION_ROTATION
342 *
343 *************************************************************************************************/
344
350 public CONDITION_DATA
351{
352public:
353 explicit PANEL_COMPONENT_CLASS_CONDITION_ROTATION( wxWindow* aParent );
354
355 void OnDeleteConditionClick( wxCommandEvent& event ) override;
356
357protected:
359};
360
361
362/**************************************************************************************************
363 *
364 * PANEL_COMPONENT_CLASS_CONDITION_FIELD
365 *
366 *************************************************************************************************/
367
372 public CONDITION_DATA
373{
374public:
375 explicit PANEL_COMPONENT_CLASS_CONDITION_FIELD( wxWindow* aParent );
376
377 void OnDeleteConditionClick( wxCommandEvent& event ) override;
378
379 void SetFieldsList( const std::vector<wxString>& aFields );
380
381protected:
383};
384
385
386/**************************************************************************************************
387 *
388 * PANEL_COMPONENT_CLASS_CONDITION_CUSTOM
389 *
390 *************************************************************************************************/
391
396 public CONDITION_DATA
397{
398public:
399 explicit PANEL_COMPONENT_CLASS_CONDITION_CUSTOM( wxWindow* aParent );
400
401 void OnDeleteConditionClick( wxCommandEvent& event ) override;
402
403protected:
405};
406
407
408/**************************************************************************************************
409 *
410 * PANEL_COMPONENT_CLASS_SHEET
411 *
412 *************************************************************************************************/
413
418 public CONDITION_DATA
419{
420public:
421 explicit PANEL_COMPONENT_CLASS_CONDITION_SHEET( wxWindow* aParent );
422
423 void OnDeleteConditionClick( wxCommandEvent& event ) override;
424
425 void SetSheetsList( const std::vector<wxString>& aSheets );
426
427protected:
429};
430
431#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:68
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.