KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_wizard.cpp
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 (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <
[email protected]
>
5
* Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors.
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, you may find one here:
19
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20
* or you may search the http://www.gnu.org website for the version 2 license,
21
* or you may write to the Free Software Foundation, Inc.,
22
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23
*/
24
25
31
#include "
footprint_wizard.h
"
32
33
34
FOOTPRINT_WIZARD::~FOOTPRINT_WIZARD
()
35
{
36
}
37
38
39
void
FOOTPRINT_WIZARD::register_wizard
()
40
{
41
FOOTPRINT_WIZARD_LIST::register_wizard
(
this
);
42
}
43
44
45
std::vector<FOOTPRINT_WIZARD*>
FOOTPRINT_WIZARD_LIST::m_FootprintWizards
;
46
47
FOOTPRINT_WIZARD
*
FOOTPRINT_WIZARD_LIST::GetWizard
(
int
aIndex )
48
{
49
return
m_FootprintWizards
[aIndex];
50
}
51
52
53
FOOTPRINT_WIZARD
*
FOOTPRINT_WIZARD_LIST::GetWizard
(
const
wxString& aName )
54
{
55
int
max =
GetWizardsCount
();
56
57
for
(
int
i = 0; i<max; i++ )
58
{
59
FOOTPRINT_WIZARD
* wizard =
GetWizard
( i );
60
61
wxString
name
= wizard->
GetName
();
62
63
if
(
name
.Cmp( aName )==0 )
64
return
wizard;
65
}
66
67
return
nullptr
;
68
}
69
70
71
int
FOOTPRINT_WIZARD_LIST::GetWizardsCount
()
72
{
73
return
m_FootprintWizards
.size();
74
}
75
76
77
void
FOOTPRINT_WIZARD_LIST::register_wizard
(
FOOTPRINT_WIZARD
* aWizard )
78
{
79
// Search for this entry do not register twice this wizard):
80
for
(
int
ii = 0; ii <
GetWizardsCount
(); ii++ )
81
{
82
if
( aWizard ==
GetWizard
( ii ) )
// Already registered
83
return
;
84
}
85
86
// Search for a wizard with the same name, and remove it if found
87
for
(
int
ii = 0; ii <
GetWizardsCount
(); ii++ )
88
{
89
FOOTPRINT_WIZARD
* wizard =
GetWizard
( ii );
90
91
if
( wizard->
GetName
() == aWizard->
GetName
() )
92
{
93
m_FootprintWizards
.erase(
m_FootprintWizards
.begin() + ii );
94
delete
wizard;
95
break
;
96
}
97
}
98
99
m_FootprintWizards
.push_back( aWizard );
100
}
101
102
103
bool
FOOTPRINT_WIZARD_LIST::deregister_object
(
void
* aObject )
104
{
105
int
max =
GetWizardsCount
();
106
107
for
(
int
ii = 0; ii < max; ii++ )
108
{
109
FOOTPRINT_WIZARD
* wizard =
GetWizard
( ii );
110
111
if
( wizard->
GetObject
() == aObject )
112
{
113
m_FootprintWizards
.erase(
m_FootprintWizards
.begin() + ii );
114
delete
wizard;
115
return
true
;
116
}
117
}
118
119
return
false
;
120
}
name
const char * name
Definition:
DXF_plotter.cpp:57
FOOTPRINT_WIZARD_LIST::register_wizard
static void register_wizard(FOOTPRINT_WIZARD *aWizard)
A footprint wizard calls this static method when it wants to register itself into the system wizards.
Definition:
footprint_wizard.cpp:77
FOOTPRINT_WIZARD_LIST::m_FootprintWizards
static std::vector< FOOTPRINT_WIZARD * > m_FootprintWizards
FOOTPRINT_WIZARD system wide static list.
Definition:
footprint_wizard.h:201
FOOTPRINT_WIZARD_LIST::deregister_object
static bool deregister_object(void *aObject)
Unregister an object which builds a wizard.
Definition:
footprint_wizard.cpp:103
FOOTPRINT_WIZARD_LIST::GetWizardsCount
static int GetWizardsCount()
Definition:
footprint_wizard.cpp:71
FOOTPRINT_WIZARD_LIST::GetWizard
static FOOTPRINT_WIZARD * GetWizard(const wxString &aName)
Definition:
footprint_wizard.cpp:53
FOOTPRINT_WIZARD
The parent class from where any footprint wizard class must derive.
Definition:
footprint_wizard.h:52
FOOTPRINT_WIZARD::~FOOTPRINT_WIZARD
virtual ~FOOTPRINT_WIZARD()
Definition:
footprint_wizard.cpp:34
FOOTPRINT_WIZARD::GetObject
virtual void * GetObject()=0
Get the object from where this wizard constructs.
FOOTPRINT_WIZARD::GetName
virtual wxString GetName()=0
FOOTPRINT_WIZARD::register_wizard
void register_wizard()
The standard method of a "FOOTPRINT_WIZARD" to register itself into the FOOTPRINT_WIZARD_LIST singlet...
Definition:
footprint_wizard.cpp:39
footprint_wizard.h
Class FOOTPRINT_WIZARD and FOOTPRINT_WIZARDS.
src
pcbnew
footprint_wizard.cpp
Generated on Thu Dec 5 2024 00:05:03 for KiCad PCB EDA Suite by
1.9.6