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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <pcb_edit_frame.h>
27#include <board.h>
28#include <footprint.h>
29#include <pcbnew_id.h>
32#include <wx/msgdlg.h>
33#include <tool/tool_manager.h>
35
36
37/* Displays the name of the current opened library in the caption */
39{
40 wxString msg;
41
42 msg = _( "Footprint Wizard" );
43 msg << wxT( " [" );
44
45 wxString wizardName = m_currentWizard ? m_currentWizard->Info().meta.name : _( "no wizard selected" );
46 msg << wizardName;
47
48 msg << wxT( "]" );
49
50 SetTitle( msg );
51}
52
53
55{
56 FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
57
58 if( !footprintWizard )
59 return;
60
62
63 // Delete the current footprint
65
66 // Creates the footprint
67 tl::expected<FOOTPRINT*, wxString> result = Manager()->Generate( footprintWizard );
68
69 if( result )
70 {
71 m_buildMessageBox->SetValue( footprintWizard->Info().meta.description );
72 // Add the object to board
74 ( *result )->SetPosition( VECTOR2I( 0, 0 ) );
75 }
76 else
77 {
78 m_buildMessageBox->SetValue( result.error() );
79 }
80
81 updateView();
82 GetCanvas()->Refresh();
83}
84
85
90
91
93{
94 // TODO(JE) should this be cached?
95 tl::expected<FOOTPRINT*, wxString> result = Manager()->Generate( m_currentWizard );
96 return result.value_or( nullptr );
97}
98
99
101{
102 DIALOG_FOOTPRINT_WIZARD_LIST wizardSelector( this );
103
104 if( wizardSelector.ShowModal() != wxID_OK )
105 return;
106
107 m_currentWizard = 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
117 Zoom_Automatique( false );
120}
121
122
124{
126 updateView();
127}
128
130{
131 FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
132
133 if ( footprintWizard == nullptr )
134 return;
135
136 footprintWizard->ResetParameters();
137
138 // Reload
142}
143
144
149
150
156
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1237
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
Definition board.cpp:1755
int ShowModal() override
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.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
FOOTPRINT_WIZARD_MANAGER * Manager() const
void ReCreateParameterList()
Create the list of parameters for the current page.
void DisplayWizardInfos()
Show all the details about the current wizard.
void SelectCurrentWizard(wxCommandEvent &aDummy)
void updateView()
Rebuild the GAL view (reint tool manager, colors and drawings) must be run after any footprint change...
FOOTPRINT_WIZARD * m_currentWizard
FOOTPRINT_WIZARD * GetMyWizard()
Reloads the wizard by name.
void RegenerateFootprint()
Regenerate the current footprint.
void SelectFootprintWizard()
Prepare the grid where parameters are displayed.
tl::expected< FOOTPRINT *, wxString > Generate(FOOTPRINT_WIZARD *aWizard)
Generates a footprint using a given wizard.
WIZARD_INFO & Info()
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
BOARD * GetBoard() const
TOOL_MANAGER * m_toolManager
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:80
#define _(s)
WIZARD_META_INFO meta
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
Definition of file extensions used in Kicad.