KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_wizard_frame_functions.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) 2012 Miguel Angel Ajo Pelayo,
[email protected]
5
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
6
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7
*
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public License
10
* as published by the Free Software Foundation; either version 2
11
* of the License, or (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20
*/
21
22
#include <
pcb_edit_frame.h
>
23
#include <
board.h
>
24
#include <
footprint.h
>
25
#include <
pcbnew_id.h
>
26
#include <
wildcards_and_files_ext.h
>
27
#include <
dialogs/dialog_footprint_wizard_list.h
>
28
#include <wx/msgdlg.h>
29
#include <
tool/tool_manager.h
>
30
#include "
footprint_wizard_frame.h
"
31
32
33
/* Displays the name of the current opened library in the caption */
34
void
FOOTPRINT_WIZARD_FRAME::DisplayWizardInfos
()
35
{
36
wxString msg;
37
38
msg =
_
(
"Footprint Wizard"
);
39
msg << wxT(
" ["
);
40
41
wxString wizardName =
m_currentWizard
?
m_currentWizard
->Info().meta.name :
_
(
"no wizard selected"
);
42
msg << wizardName;
43
44
msg << wxT(
"]"
);
45
46
SetTitle( msg );
47
}
48
49
50
void
FOOTPRINT_WIZARD_FRAME::RegenerateFootprint
()
51
{
52
FOOTPRINT_WIZARD
* footprintWizard =
GetMyWizard
();
53
54
if
( !footprintWizard )
55
return
;
56
57
m_toolManager
->ResetTools(
TOOL_BASE::MODEL_RELOAD
);
58
59
// Delete the current footprint
60
GetBoard
()->
DeleteAllFootprints
();
61
62
// Creates the footprint
63
tl::expected<FOOTPRINT*, wxString>
result
=
Manager
()->
Generate
( footprintWizard );
64
65
if
(
result
)
66
{
67
m_builtFootprint
= *
result
;
68
m_buildMessageBox
->SetValue( footprintWizard->
Info
().
meta
.
description
);
69
// Add the object to board
70
GetBoard
()->
Add
(
m_builtFootprint
,
ADD_MODE::APPEND
);
71
m_builtFootprint
->SetPosition(
VECTOR2I
( 0, 0 ) );
72
}
73
else
74
{
75
m_builtFootprint
=
nullptr
;
76
m_buildMessageBox
->SetValue(
result
.error() );
77
}
78
79
updateView
();
80
GetCanvas
()->
Refresh
();
81
}
82
83
84
FOOTPRINT_WIZARD
*
FOOTPRINT_WIZARD_FRAME::GetMyWizard
()
85
{
86
return
m_currentWizard
;
87
}
88
89
90
FOOTPRINT
*
FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint
()
91
{
92
if
( !
m_builtFootprint
)
93
return
nullptr
;
94
95
return
static_cast<
FOOTPRINT
*
>
(
m_builtFootprint
->Duplicate(
IGNORE_PARENT_GROUP
) );
96
}
97
98
99
void
FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard
()
100
{
101
DIALOG_FOOTPRINT_WIZARD_LIST
wizardSelector(
this
);
102
103
if
( wizardSelector.
ShowModal
() != wxID_OK )
104
return
;
105
106
m_currentWizard
=
nullptr
;
107
m_builtFootprint
=
nullptr
;
108
wxString wizardIdentifier = wizardSelector.
GetWizard
();
109
110
if
( !wizardIdentifier.IsEmpty() )
111
{
112
if
( std::optional<FOOTPRINT_WIZARD*> wizard =
Manager
()->GetWizard( wizardIdentifier ) )
113
m_currentWizard
= *wizard;
114
}
115
116
RegenerateFootprint
();
117
Zoom_Automatique
(
false
);
118
DisplayWizardInfos
();
119
ReCreateParameterList
();
120
}
121
122
123
void
FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard
( wxCommandEvent& aDummy )
124
{
125
SelectFootprintWizard
();
126
updateView
();
127
}
128
129
void
FOOTPRINT_WIZARD_FRAME::DefaultParameters
()
130
{
131
FOOTPRINT_WIZARD
* footprintWizard =
GetMyWizard
();
132
133
if
( footprintWizard ==
nullptr
)
134
return
;
135
136
footprintWizard->
ResetParameters
();
137
138
// Reload
139
ReCreateParameterList
();
140
RegenerateFootprint
();
141
DisplayWizardInfos
();
142
}
143
144
145
void
FOOTPRINT_WIZARD_FRAME::RebuildWizardParameters
()
146
{
147
ReCreateParameterList
();
148
}
149
150
151
void
FOOTPRINT_WIZARD_FRAME::OnWizardParametersChanged
()
152
{
153
RegenerateFootprint
();
154
DisplayWizardInfos
();
155
}
156
157
158
void
FOOTPRINT_WIZARD_FRAME::SetBuildMessage
(
const
wxString& aMessage )
159
{
160
m_buildMessageBox
->SetValue( aMessage );
161
}
board.h
ADD_MODE::APPEND
@ APPEND
Definition
board_item_container.h:31
BOARD::Add
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition
board.cpp:1497
BOARD::DeleteAllFootprints
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition
board.cpp:2077
DIALOG_FOOTPRINT_WIZARD_LIST
Definition
dialog_footprint_wizard_list.h:30
DIALOG_FOOTPRINT_WIZARD_LIST::GetWizard
const wxString & GetWizard()
Definition
dialog_footprint_wizard_list.cpp:131
DIALOG_SHIM::ShowModal
int ShowModal() override
Definition
dialog_shim.cpp:1605
EDA_DRAW_FRAME::Zoom_Automatique
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
Definition
eda_draw_frame.cpp:1055
EDA_DRAW_PANEL_GAL::Refresh
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Definition
draw_panel_gal.cpp:520
FOOTPRINT_WIZARD_FRAME::Manager
FOOTPRINT_WIZARD_MANAGER * Manager() const
Definition
footprint_wizard_frame.h:68
FOOTPRINT_WIZARD_FRAME::m_builtFootprint
FOOTPRINT * m_builtFootprint
Definition
footprint_wizard_frame.h:143
FOOTPRINT_WIZARD_FRAME::GetBuiltFootprint
FOOTPRINT * GetBuiltFootprint()
Return a duplicate of the generated footprint. The caller takes ownership.
Definition
footprint_wizard_frame_functions.cpp:90
FOOTPRINT_WIZARD_FRAME::OnWizardParametersChanged
void OnWizardParametersChanged()
Definition
footprint_wizard_frame_functions.cpp:151
FOOTPRINT_WIZARD_FRAME::ReCreateParameterList
void ReCreateParameterList()
Create the list of parameters for the current page.
Definition
footprint_wizard_frame.cpp:293
FOOTPRINT_WIZARD_FRAME::DisplayWizardInfos
void DisplayWizardInfos()
Show all the details about the current wizard.
Definition
footprint_wizard_frame_functions.cpp:34
FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard
void SelectCurrentWizard(wxCommandEvent &aDummy)
Definition
footprint_wizard_frame_functions.cpp:123
FOOTPRINT_WIZARD_FRAME::updateView
void updateView()
Rebuild the GAL view (reint tool manager, colors and drawings) must be run after any footprint change...
Definition
footprint_wizard_frame.cpp:265
FOOTPRINT_WIZARD_FRAME::m_currentWizard
FOOTPRINT_WIZARD * m_currentWizard
Definition
footprint_wizard_frame.h:141
FOOTPRINT_WIZARD_FRAME::GetMyWizard
FOOTPRINT_WIZARD * GetMyWizard()
Reloads the wizard by name.
Definition
footprint_wizard_frame_functions.cpp:84
FOOTPRINT_WIZARD_FRAME::m_buildMessageBox
wxTextCtrl * m_buildMessageBox
Definition
footprint_wizard_frame.h:147
FOOTPRINT_WIZARD_FRAME::SetBuildMessage
void SetBuildMessage(const wxString &aMessage)
Definition
footprint_wizard_frame_functions.cpp:158
FOOTPRINT_WIZARD_FRAME::RegenerateFootprint
void RegenerateFootprint()
Regenerate the current footprint.
Definition
footprint_wizard_frame_functions.cpp:50
FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard
void SelectFootprintWizard()
Prepare the grid where parameters are displayed.
Definition
footprint_wizard_frame_functions.cpp:99
FOOTPRINT_WIZARD_FRAME::RebuildWizardParameters
void RebuildWizardParameters()
Definition
footprint_wizard_frame_functions.cpp:145
FOOTPRINT_WIZARD_FRAME::DefaultParameters
void DefaultParameters()
Definition
footprint_wizard_frame_functions.cpp:129
FOOTPRINT_WIZARD_MANAGER::Generate
tl::expected< FOOTPRINT *, wxString > Generate(FOOTPRINT_WIZARD *aWizard)
Generates a footprint using a given wizard.
Definition
footprint_wizard.cpp:120
FOOTPRINT_WIZARD
Definition
footprint_wizard.h:151
FOOTPRINT_WIZARD::ResetParameters
void ResetParameters()
Definition
footprint_wizard.cpp:32
FOOTPRINT_WIZARD::Info
WIZARD_INFO & Info()
Definition
footprint_wizard.h:156
FOOTPRINT
Definition
footprint.h:314
PCB_BASE_FRAME::GetCanvas
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition
pcb_base_frame.cpp:1009
PCB_BASE_FRAME::GetBoard
BOARD * GetBoard() const
Definition
pcb_base_frame.h:219
TOOLS_HOLDER::m_toolManager
TOOL_MANAGER * m_toolManager
Definition
tools_holder.h:171
TOOL_BASE::MODEL_RELOAD
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition
tool_base.h:76
dialog_footprint_wizard_list.h
_
#define _(s)
Definition
eda_3d_actions.cpp:36
IGNORE_PARENT_GROUP
#define IGNORE_PARENT_GROUP
Definition
eda_item.h:55
footprint.h
footprint_wizard_frame.h
pcb_edit_frame.h
pcbnew_id.h
WIZARD_INFO::meta
WIZARD_META_INFO meta
Definition
footprint_wizard.h:143
WIZARD_META_INFO::description
wxString description
Definition
footprint_wizard.h:39
result
wxString result
Test unit parsing edge cases and error handling.
Definition
test_text_eval_numeric_compat.cpp:598
tool_manager.h
VECTOR2I
VECTOR2< int32_t > VECTOR2I
Definition
vector2d.h:683
wildcards_and_files_ext.h
Definition of file extensions used in Kicad.
src
pcbnew
footprint_wizard_frame_functions.cpp
Generated on Thu Sep 17 2026 00:06:20 for KiCad PCB EDA Suite by
1.13.2