KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_wizard.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 (C) 2026 Jon Evans <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef FOOTPRINT_WIZARD_H
22#define FOOTPRINT_WIZARD_H
23
24#include <optional>
25#include <tl/expected.hpp>
26
27#include <import_export.h>
28#include <api/common/types/wizards.pb.h>
29
30class FOOTPRINT;
31
32
33
34// Wrapper for WizardMetaInfo protobuf with UTF8-converted strings
36{
37 wxString identifier;
38 wxString name;
39 wxString description;
40 std::set<kiapi::common::types::WizardContentType> types_generated;
41
42 void FromProto( const kiapi::common::types::WizardMetaInfo& aProto );
43};
44
46{
47public:
48 WIZARD_PARAMETER() = default;
49 virtual ~WIZARD_PARAMETER() = default;
50
51 virtual void Reset() = 0;
52
58 virtual kiapi::common::types::WizardParameter Pack( bool aCompact = true );
59
60 wxString identifier;
61 wxString name;
62 wxString description;
63 kiapi::common::types::WizardParameterCategory category = kiapi::common::types::WPC_UNKNOWN;
64 kiapi::common::types::WizardParameterDataType type = kiapi::common::types::WPDT_UNKNOWN;
65
66 static std::unique_ptr<WIZARD_PARAMETER> Create( const kiapi::common::types::WizardParameter& aProto );
67
68 static wxString ParameterCategoryName( kiapi::common::types::WizardParameterCategory aCategory );
69};
70
72{
73public:
74 void Reset() override { value = default_value; }
75 kiapi::common::types::WizardParameter Pack( bool aCompact = true ) override;
76
77 int value = 0;
79 std::optional<int> min;
80 std::optional<int> max;
81 std::optional<int> multiple;
82
83 void FromProto( const kiapi::common::types::WizardIntParameter& aProto );
84};
85
87{
88public:
89 void Reset() override { value = default_value; }
90 kiapi::common::types::WizardParameter Pack( bool aCompact = true ) override;
91
92 double value = 0.0;
93 double default_value = 0.0;
94 std::optional<double> min;
95 std::optional<double> max;
96
97 void FromProto( const kiapi::common::types::WizardRealParameter& aProto );
98};
99
101{
102public:
103 void Reset() override { value = default_value; }
104 kiapi::common::types::WizardParameter Pack( bool aCompact = true ) override;
105
106 bool value = false;
107 bool default_value = false;
108
109 void FromProto( const kiapi::common::types::WizardBoolParameter& aProto );
110};
111
113{
114public:
115 void Reset() override { value = default_value; }
116 kiapi::common::types::WizardParameter Pack( bool aCompact = true ) override;
117
118 wxString value;
120 std::optional<wxString> validation_regex;
121
122 void FromProto( const kiapi::common::types::WizardStringParameter& aProto );
123};
124
125// Wrapper for WizardInfo protobuf
127{
129 std::vector<std::unique_ptr<WIZARD_PARAMETER>> parameters;
130
131 void FromProto( const kiapi::common::types::WizardInfo& aProto );
132};
133
134
136{
137public:
139 ~FOOTPRINT_WIZARD() = default;
140
141 WIZARD_INFO& Info() { return m_info; }
142 const WIZARD_INFO& Info() const { return m_info; }
143
144 const wxString& Identifier() const { return m_identifier; }
145 void SetIdentifier( const wxString& aId ) { m_identifier = aId; }
146
147 void ResetParameters();
148
149private:
151
152 // Identifier of the plugin action
153 wxString m_identifier;
154};
155
163{
164public:
167
174 void ReloadWizards();
175
176 std::optional<FOOTPRINT_WIZARD*> GetWizard( const wxString& aIdentifier );
177
178 std::vector<FOOTPRINT_WIZARD*> Wizards() const;
179
185 static bool RefreshInfo( FOOTPRINT_WIZARD* aWizard );
186
192 tl::expected<FOOTPRINT*, wxString> Generate( FOOTPRINT_WIZARD* aWizard );
193
194private:
195
196 // Loaded wizards, mapped by identifier
197 std::map<wxString, std::unique_ptr<FOOTPRINT_WIZARD>> m_wizards;
198};
199
200
201#endif /* FOOTPRINT_WIZARD_H */
std::map< wxString, std::unique_ptr< FOOTPRINT_WIZARD > > m_wizards
void ReloadWizards()
Goes through the list of IPC API plugins that provide wizard actions and attempts to refresh the info...
std::vector< FOOTPRINT_WIZARD * > Wizards() const
static bool RefreshInfo(FOOTPRINT_WIZARD *aWizard)
Runs a wizard plugin with the –get-info argument, which should result in the plugin dumping a WizardI...
std::optional< FOOTPRINT_WIZARD * > GetWizard(const wxString &aIdentifier)
tl::expected< FOOTPRINT *, wxString > Generate(FOOTPRINT_WIZARD *aWizard)
Generates a footprint using a given wizard.
~FOOTPRINT_WIZARD_MANAGER()=default
const wxString & Identifier() const
const WIZARD_INFO & Info() const
WIZARD_INFO & Info()
void SetIdentifier(const wxString &aId)
~FOOTPRINT_WIZARD()=default
void FromProto(const kiapi::common::types::WizardBoolParameter &aProto)
kiapi::common::types::WizardParameter Pack(bool aCompact=true) override
Packs the current state of this parameter back into a protobuf message.
void FromProto(const kiapi::common::types::WizardIntParameter &aProto)
std::optional< int > min
std::optional< int > multiple
void Reset() override
kiapi::common::types::WizardParameter Pack(bool aCompact=true) override
Packs the current state of this parameter back into a protobuf message.
std::optional< int > max
virtual kiapi::common::types::WizardParameter Pack(bool aCompact=true)
Packs the current state of this parameter back into a protobuf message.
kiapi::common::types::WizardParameterDataType type
static wxString ParameterCategoryName(kiapi::common::types::WizardParameterCategory aCategory)
virtual ~WIZARD_PARAMETER()=default
static std::unique_ptr< WIZARD_PARAMETER > Create(const kiapi::common::types::WizardParameter &aProto)
kiapi::common::types::WizardParameterCategory category
virtual void Reset()=0
WIZARD_PARAMETER()=default
kiapi::common::types::WizardParameter Pack(bool aCompact=true) override
Packs the current state of this parameter back into a protobuf message.
void FromProto(const kiapi::common::types::WizardRealParameter &aProto)
std::optional< double > min
std::optional< double > max
std::optional< wxString > validation_regex
kiapi::common::types::WizardParameter Pack(bool aCompact=true) override
Packs the current state of this parameter back into a protobuf message.
void FromProto(const kiapi::common::types::WizardStringParameter &aProto)
std::vector< std::unique_ptr< WIZARD_PARAMETER > > parameters
WIZARD_META_INFO meta
void FromProto(const kiapi::common::types::WizardInfo &aProto)
void FromProto(const kiapi::common::types::WizardMetaInfo &aProto)
std::set< kiapi::common::types::WizardContentType > types_generated