KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_utils.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) 2023 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
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <magic_enum.hpp>
22#include <api/api_utils.h>
23#include <api/api_enums.h>
24#include <api/schematic/schematic_types.pb.h>
25#include <line_ending.h>
27#include <eda_item.h>
28#include <kiid.h>
29#include <project.h>
30#include <stroke_params.h>
31#include <wx/log.h>
32
33const wxChar* const traceApi = wxT( "KICAD_API" );
34
35
36namespace kiapi::common
37{
38
39KICOMMON_API ApiResponseStatus MakeResponseStatus( ApiStatusCode aCode, const std::string& aMessage )
40{
41 ApiResponseStatus s;
42 s.set_status( aCode );
43
44 if( !aMessage.empty() )
45 s.set_error_message( aMessage );
46
47 return s;
48}
49
50KICOMMON_API std::optional<KICAD_T> TypeNameFromAny( const google::protobuf::Any& aMessage )
51{
52 if( aMessage.type_url() == "type.googleapis.com/kiapi.schematic.types.BusEntry" )
53 {
54 kiapi::schematic::types::BusEntry entry;
55
56 if( !aMessage.UnpackTo( &entry ) )
57 return std::nullopt;
58
59 switch( entry.type() )
60 {
61 case kiapi::schematic::types::BET_WIRE_TO_BUS:
63
64 case kiapi::schematic::types::BET_BUS_TO_BUS:
66
67 default:
68 return std::nullopt;
69 }
70 }
71
72 static const std::map<std::string, KICAD_T> s_types = {
73 { "type.googleapis.com/kiapi.board.types.Track", PCB_TRACE_T },
74 { "type.googleapis.com/kiapi.board.types.Arc", PCB_ARC_T },
75 { "type.googleapis.com/kiapi.board.types.Via", PCB_VIA_T },
76 { "type.googleapis.com/kiapi.board.types.BoardText", PCB_TEXT_T },
77 { "type.googleapis.com/kiapi.board.types.BoardTextBox", PCB_TEXTBOX_T },
78 { "type.googleapis.com/kiapi.board.types.Table", PCB_TABLE_T },
79 { "type.googleapis.com/kiapi.board.types.DrillChart", PCB_DRILL_CHART_T },
80 { "type.googleapis.com/kiapi.board.types.DrillMap", PCB_DRILL_MAP_T },
81 { "type.googleapis.com/kiapi.board.types.StackupTable", PCB_STACKUP_TABLE_T },
82 { "type.googleapis.com/kiapi.board.types.TableCell", PCB_TABLECELL_T },
83 { "type.googleapis.com/kiapi.board.types.BoardGraphicShape", PCB_SHAPE_T },
84 { "type.googleapis.com/kiapi.board.types.Barcode", PCB_BARCODE_T },
85 { "type.googleapis.com/kiapi.board.types.Pad", PCB_PAD_T },
86 { "type.googleapis.com/kiapi.board.types.Zone", PCB_ZONE_T },
87 { "type.googleapis.com/kiapi.board.types.Dimension", PCB_DIMENSION_T },
88 { "type.googleapis.com/kiapi.board.types.ReferenceImage", PCB_REFERENCE_IMAGE_T },
89 { "type.googleapis.com/kiapi.board.types.ReferencePoint", PCB_POINT_T },
90 { "type.googleapis.com/kiapi.board.types.GridItem", PCB_GRID_ITEM_T },
91 { "type.googleapis.com/kiapi.board.types.Group", PCB_GROUP_T },
92 { "type.googleapis.com/kiapi.board.types.TuningPattern", PCB_GENERATOR_T },
93 { "type.googleapis.com/kiapi.board.types.ViaStitchArea", PCB_GENERATOR_T },
94 { "type.googleapis.com/kiapi.board.types.ViaStack", PCB_GENERATOR_T },
95 { "type.googleapis.com/kiapi.board.types.Constraint", PCB_CONSTRAINT_T },
96 { "type.googleapis.com/kiapi.board.types.Body3D", PCB_3D_BODY_T },
97 { "type.googleapis.com/kiapi.board.types.Field", PCB_FIELD_T },
98 { "type.googleapis.com/kiapi.board.types.FootprintInstance", PCB_FOOTPRINT_T },
99 { "type.googleapis.com/kiapi.schematic.types.Junction", SCH_JUNCTION_T },
100 { "type.googleapis.com/kiapi.schematic.types.NoConnectMarker", SCH_NO_CONNECT_T },
101 { "type.googleapis.com/kiapi.schematic.types.BusEntry", SCH_BUS_WIRE_ENTRY_T },
102 { "type.googleapis.com/kiapi.schematic.types.SchematicLine", SCH_LINE_T },
103 { "type.googleapis.com/kiapi.schematic.types.SchematicGraphicShape", SCH_SHAPE_T },
104 { "type.googleapis.com/kiapi.schematic.types.SchematicImage", SCH_BITMAP_T },
105 { "type.googleapis.com/kiapi.schematic.types.SchematicTextBox", SCH_TEXTBOX_T },
106 { "type.googleapis.com/kiapi.schematic.types.SchematicText", SCH_TEXT_T },
107 { "type.googleapis.com/kiapi.schematic.types.SchematicField", SCH_FIELD_T },
108 { "type.googleapis.com/kiapi.schematic.types.SchematicTableCell", SCH_TABLECELL_T },
109 { "type.googleapis.com/kiapi.schematic.types.SchematicTable", SCH_TABLE_T },
110 { "type.googleapis.com/kiapi.schematic.types.LocalLabel", SCH_LABEL_T },
111 { "type.googleapis.com/kiapi.schematic.types.GlobalLabel", SCH_GLOBAL_LABEL_T },
112 { "type.googleapis.com/kiapi.schematic.types.HierarchicalLabel", SCH_HIER_LABEL_T },
113 { "type.googleapis.com/kiapi.schematic.types.DirectiveLabel", SCH_DIRECTIVE_LABEL_T },
114 { "type.googleapis.com/kiapi.schematic.types.Group", SCH_GROUP_T },
115 { "type.googleapis.com/kiapi.schematic.types.SheetSymbol", SCH_SHEET_T },
116 { "type.googleapis.com/kiapi.schematic.types.SchematicSymbolInstance", SCH_SYMBOL_T },
117 { "type.googleapis.com/kiapi.schematic.types.SchematicPin", SCH_PIN_T },
118 { "type.googleapis.com/kiapi.schematic.types.SchematicSymbol", LIB_SYMBOL_T },
119 { "type.googleapis.com/kiapi.schematic.types.SchematicRuleArea", SCH_RULE_AREA_T },
120 };
121
122 auto it = s_types.find( aMessage.type_url() );
123
124 if( it != s_types.end() )
125 return it->second;
126
127 wxLogTrace( traceApi, wxString::Format( wxS( "Any message type %s is not known" ),
128 aMessage.type_url() ) );
129
130 return std::nullopt;
131}
132
133
134KICOMMON_API std::optional<wxString> GeneratorTypeFromAny( const google::protobuf::Any& aMessage )
135{
136 static const std::map<std::string, wxString> s_generatorTypes = {
137 { "type.googleapis.com/kiapi.board.types.TuningPattern", wxS( "tuning_pattern" ) },
138 { "type.googleapis.com/kiapi.board.types.ViaStitchArea", wxS( "via_stitch" ) },
139 { "type.googleapis.com/kiapi.board.types.ViaStack", wxS( "via_stack" ) },
140 };
141
142 auto it = s_generatorTypes.find( aMessage.type_url() );
143
144 if( it != s_generatorTypes.end() )
145 return it->second;
146
147 return std::nullopt;
148}
149
150
151KICOMMON_API LIB_ID UnpackLibId( const types::LibraryIdentifier& aId )
152{
153 return LIB_ID( aId.library_nickname(), aId.entry_name() );
154}
155
156
157KICOMMON_API void PackLibId( types::LibraryIdentifier* aOutput, const LIB_ID& aId )
158{
159 aOutput->set_library_nickname( aId.GetLibNickname() );
160 aOutput->set_entry_name( aId.GetLibItemName() );
161}
162
163
164KICOMMON_API void PackVector2( types::Vector2& aOutput, const VECTOR2I& aInput, const EDA_IU_SCALE& aScale )
165{
166 aOutput.set_x_nm( aScale.IUToNm( aInput.x ) );
167 aOutput.set_y_nm( aScale.IUToNm( aInput.y ) );
168}
169
170
171KICOMMON_API VECTOR2I UnpackVector2( const types::Vector2& aInput, const EDA_IU_SCALE& aScale )
172{
173 return VECTOR2I( KiROUND( aScale.NmToIUD( aInput.x_nm() ) ),
174 KiROUND( aScale.NmToIUD( aInput.y_nm() ) ) );
175}
176
177
178KICOMMON_API void PackVector3D( types::Vector3D& aOutput, const VECTOR3D& aInput )
179{
180 aOutput.set_x_nm( aInput.x );
181 aOutput.set_y_nm( aInput.y );
182 aOutput.set_z_nm( aInput.z );
183}
184
185
186KICOMMON_API VECTOR3D UnpackVector3D( const types::Vector3D& aInput )
187{
188 return VECTOR3D( aInput.x_nm(), aInput.y_nm(), aInput.z_nm() );
189}
190
191
192KICOMMON_API void PackBox2( types::Box2& aOutput, const BOX2I& aInput, const EDA_IU_SCALE& aScale )
193{
194 PackVector2( *aOutput.mutable_position(), aInput.GetOrigin(), aScale );
195 PackVector2( *aOutput.mutable_size(), aInput.GetSize(), aScale );
196}
197
198
199KICOMMON_API BOX2I UnpackBox2( const types::Box2& aInput, const EDA_IU_SCALE& aScale )
200{
201 return BOX2I( UnpackVector2( aInput.position(), aScale ), UnpackVector2( aInput.size(), aScale ) );
202}
203
204
205KICOMMON_API void PackDistance( types::Distance& aOutput, int aInput, const EDA_IU_SCALE& aScale )
206{
207 aOutput.set_value_nm( aScale.IUToNm( aInput ) );
208}
209
210
211KICOMMON_API int UnpackDistance( const types::Distance& aInput, const EDA_IU_SCALE& aScale )
212{
213 return KiROUND( aScale.NmToIUD( aInput.value_nm() ) );
214}
215
216
217KICOMMON_API void PackPolyLine( types::PolyLine& aOutput, const SHAPE_LINE_CHAIN& aSlc, const EDA_IU_SCALE& aScale )
218{
219 for( int vertex = 0; vertex < aSlc.PointCount(); ++vertex )
220 {
221 if( aSlc.IsArcStart( vertex ) )
222 {
223 types::PolyLineNode* node = aOutput.mutable_nodes()->Add();
224 const SHAPE_ARC& arc = aSlc.Arc( aSlc.ArcIndex( vertex ) );
225 PackVector2( *node->mutable_arc()->mutable_start(), arc.GetP0(), aScale );
226 PackVector2( *node->mutable_arc()->mutable_mid(), arc.GetArcMid(), aScale );
227 PackVector2( *node->mutable_arc()->mutable_end(), arc.GetP1(), aScale );
228 }
229 else if( !aSlc.IsPtOnArc( vertex ) )
230 {
231 types::PolyLineNode* node = aOutput.mutable_nodes()->Add();
232 PackVector2( *node->mutable_point(), aSlc.CPoint( vertex ), aScale );
233 }
234 }
235
236 aOutput.set_closed( aSlc.IsClosed() );
237}
238
239
240KICOMMON_API SHAPE_LINE_CHAIN UnpackPolyLine( const types::PolyLine& aInput, const EDA_IU_SCALE& aScale )
241{
243
244 for( const types::PolyLineNode& node : aInput.nodes() )
245 {
246 if( node.has_point() )
247 {
248 slc.Append( UnpackVector2( node.point(), aScale ) );
249 }
250 else if( node.has_arc() )
251 {
252 slc.Append( SHAPE_ARC( UnpackVector2( node.arc().start(), aScale ),
253 UnpackVector2( node.arc().mid(), aScale ),
254 UnpackVector2( node.arc().end(), aScale ),
255 0 ) );
256 }
257 }
258
259 slc.SetClosed( aInput.closed() );
260
261 return slc;
262}
263
264
265KICOMMON_API void PackPolySet( types::PolySet& aOutput, const SHAPE_POLY_SET& aInput, const EDA_IU_SCALE& aScale )
266{
267 for( int idx = 0; idx < aInput.OutlineCount(); ++idx )
268 {
269 const SHAPE_POLY_SET::POLYGON& poly = aInput.Polygon( idx );
270
271 if( poly.empty() )
272 continue;
273
274 types::PolygonWithHoles* polyMsg = aOutput.mutable_polygons()->Add();
275 PackPolyLine( *polyMsg->mutable_outline(), poly.front(), aScale );
276
277 if( poly.size() > 1 )
278 {
279 for( size_t hole = 1; hole < poly.size(); ++hole )
280 {
281 types::PolyLine* pl = polyMsg->mutable_holes()->Add();
282 PackPolyLine( *pl, poly[hole], aScale );
283 }
284 }
285 }
286}
287
288
289KICOMMON_API SHAPE_POLY_SET UnpackPolySet( const types::PolySet& aInput, const EDA_IU_SCALE& aScale )
290{
291 SHAPE_POLY_SET sps;
292
293 for( const types::PolygonWithHoles& polygonWithHoles : aInput.polygons() )
294 {
296
297 polygon.emplace_back( UnpackPolyLine( polygonWithHoles.outline(), aScale ) );
298
299 for( const types::PolyLine& holeMsg : polygonWithHoles.holes() )
300 polygon.emplace_back( UnpackPolyLine( holeMsg, aScale ) );
301
302 sps.AddPolygon( polygon );
303 }
304
305 return sps;
306}
307
308
309KICOMMON_API void PackColor( types::Color& aOutput, const KIGFX::COLOR4D& aInput )
310{
311 aOutput.set_r( aInput.r );
312 aOutput.set_g( aInput.g );
313 aOutput.set_b( aInput.b );
314 aOutput.set_a( aInput.a );
315}
316
317
318KICOMMON_API KIGFX::COLOR4D UnpackColor( const types::Color& aInput )
319{
320 double r = std::clamp( aInput.r(), 0.0, 1.0 );
321 double g = std::clamp( aInput.g(), 0.0, 1.0 );
322 double b = std::clamp( aInput.b(), 0.0, 1.0 );
323 double a = std::clamp( aInput.a(), 0.0, 1.0 );
324
325 return KIGFX::COLOR4D( r, g, b, a );
326}
327
328KICOMMON_API void PackSheetPath( types::SheetPath& aOutput, const KIID_PATH& aInput )
329{
330 aOutput.clear_path();
331
332 for( const KIID& entry : aInput )
333 aOutput.add_path()->set_value( entry.AsStdString() );
334}
335
336KICOMMON_API KIID_PATH UnpackSheetPath( const types::SheetPath& aInput )
337{
338 KIID_PATH output;
339
340 for( const types::KIID& sheet : aInput.path() )
341 output.push_back( KIID( sheet.value() ) );
342
343 return output;
344}
345
346
347KICOMMON_API void PackStroke( types::StrokeAttributes& aOutput, const STROKE_PARAMS& aInput,
348 const EDA_IU_SCALE& aScale )
349{
350 PackDistance( *aOutput.mutable_width(), aInput.GetWidth(), aScale );
351 aOutput.set_style( ToProtoEnum<LINE_STYLE, types::StrokeLineStyle>( aInput.GetLineStyle() ) );
352
353 if( aInput.GetColor() != KIGFX::COLOR4D::UNSPECIFIED )
354 PackColor( *aOutput.mutable_color(), aInput.GetColor() );
355}
356
357
358KICOMMON_API void UnpackStroke( STROKE_PARAMS& aOutput, const types::StrokeAttributes& aInput,
359 const EDA_IU_SCALE& aScale )
360{
361 aOutput.SetWidth( UnpackDistance( aInput.width(), aScale ) );
363
364 if( aInput.has_color() )
365 aOutput.SetColor( UnpackColor( aInput.color() ) );
366 else
368}
369
370
371KICOMMON_API void PackLineEnding( types::LineEnding& aOutput, const LINE_ENDING& aInput, const EDA_IU_SCALE& aScale )
372{
374
375 if( aInput.GetLength() > 0 )
376 PackDistance( *aOutput.mutable_length(), aInput.GetLength(), aScale );
377
378 if( aInput.GetWidth() > 0 )
379 PackDistance( *aOutput.mutable_width(), aInput.GetWidth(), aScale );
380
381 if( aInput.GetStrokeWidth() > 0 )
382 PackStroke( *aOutput.mutable_stroke(), aInput.GetStroke(), aScale );
383}
384
385
386KICOMMON_API LINE_ENDING UnpackLineEnding( const types::LineEnding& aInput, const EDA_IU_SCALE& aScale )
387{
388 LINE_ENDING ending;
389
391
392 if( aInput.has_length() )
393 ending.SetLength( UnpackDistance( aInput.length(), aScale ) );
394
395 if( aInput.has_width() )
396 ending.SetWidth( UnpackDistance( aInput.width(), aScale ) );
397
398 if( aInput.has_stroke() )
399 {
400 STROKE_PARAMS stroke;
401 UnpackStroke( stroke, aInput.stroke(), aScale );
402 ending.SetStroke( stroke );
403 }
404
405 return ending;
406}
407
408
409KICOMMON_API void PackProject( types::ProjectSpecifier& aOutput, const PROJECT& aInput )
410{
411 aOutput.set_name( aInput.GetProjectName().ToUTF8() );
412 aOutput.set_path( aInput.GetProjectPath().ToUTF8() );
413}
414
415#if defined( __MINGW32__ )
416const std::string KiwayClientName = "org.kicad.internal.kiway";
417const std::string StandaloneCrossProbeClientName = "org.kicad.internal.crossprobe";
418#else
419const KICOMMON_API std::string KiwayClientName = "org.kicad.internal.kiway";
420const KICOMMON_API std::string StandaloneCrossProbeClientName = "org.kicad.internal.crossprobe";
421#endif
422
423
424KICOMMON_API bool PackKiwayApiMessage( const google::protobuf::Message& aMessage, std::string& aBytes )
425{
426 ApiRequest request;
427 request.mutable_header()->set_client_name( KiwayClientName );
428
429 if( !request.mutable_message()->PackFrom( aMessage ) )
430 {
431 wxFAIL_MSG( "Failed to pack Kiway message" );
432 return false;
433 }
434
435 aBytes = request.SerializeAsString();
436 return true;
437}
438
439
440KICOMMON_API void PackCustomProperties( google::protobuf::RepeatedPtrField<types::CustomProperty>* aOutput,
441 const EDA_ITEM& aItem )
442{
443 for( const auto& [key, value] : aItem.GetCustomProperties() )
444 {
445 types::CustomProperty* entry = aOutput->Add();
446 entry->set_key( key.ToUTF8() );
447 entry->set_value( value.ToUTF8() );
448 }
449}
450
451
452KICOMMON_API void UnpackCustomProperties( const google::protobuf::RepeatedPtrField<types::CustomProperty>& aInput,
453 EDA_ITEM& aItem )
454{
455 std::map<wxString, wxString> props;
456
457 for( const types::CustomProperty& prop : aInput )
458 props[wxString::FromUTF8( prop.key() )] = wxString::FromUTF8( prop.value() );
459
460 aItem.SetCustomProperties( props );
461}
462
463} // namespace kiapi::common
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:56
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:985
constexpr const Vec & GetOrigin() const
Definition box2.h:213
constexpr const SizeVec & GetSize() const
Definition box2.h:209
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
void SetCustomProperties(const std::map< wxString, wxString > &aProps)
Definition eda_item.h:247
const std::map< wxString, wxString > & GetCustomProperties() const
Custom user-defined string key/value properties attached to this item.
Definition eda_item.h:242
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
double r
Red component.
Definition color4d.h:391
double g
Green component.
Definition color4d.h:392
double a
Alpha component.
Definition color4d.h:394
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
double b
Blue component.
Definition color4d.h:393
Definition kiid.h:46
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
const UTF8 & GetLibItemName() const
Definition lib_id.h:98
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition lib_id.h:83
Decorative shape (arrowhead, circle, square) at the start or end of a graphic line,...
Definition line_ending.h:62
int GetLength() const
Along-line size. 0 = auto.
Definition line_ending.h:84
const STROKE_PARAMS & GetStroke() const
int GetWidth() const
Perpendicular size. 0 = auto.
Definition line_ending.h:87
void SetStroke(const STROKE_PARAMS &aStroke)
void SetLength(int aLength)
Definition line_ending.h:85
void SetStyle(LINE_ENDING_STYLE aStyle)
Definition line_ending.h:82
void SetWidth(int aWidth)
Definition line_ending.h:88
LINE_ENDING_STYLE GetStyle() const
Definition line_ending.h:81
int GetStrokeWidth() const
Outline stroke width.
Container for project specific data.
Definition project.h:63
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition project.cpp:277
virtual const wxString GetProjectName() const
Return the short name of the project.
Definition project.cpp:289
const VECTOR2I & GetArcMid() const
Definition shape_arc.h:116
const VECTOR2I & GetP1() const
Definition shape_arc.h:115
const VECTOR2I & GetP0() const
Definition shape_arc.h:114
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsPtOnArc(size_t aPtIndex) const
const SHAPE_ARC & Arc(size_t aArc) const
bool IsClosed() const override
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
bool IsArcStart(size_t aIndex) const
Represent a set of closed polygons.
POLYGON & Polygon(int aIndex)
Return the aIndex-th subpolygon in the set.
int AddPolygon(const POLYGON &apolygon)
Adds a polygon to the set.
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
int OutlineCount() const
Return the number of outlines in the set.
Simple container to manage line stroke parameters.
int GetWidth() const
void SetLineStyle(LINE_STYLE aLineStyle)
void SetWidth(int aWidth)
void SetColor(const KIGFX::COLOR4D &aColor)
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
const wxChar *const traceApi
Flag to enable debug output related to the IPC API and its plugin system.
Definition api_utils.cpp:33
#define KICOMMON_API
Definition kicommon.h:27
KICOMMON_API void PackLineEnding(types::LineEnding &aOutput, const LINE_ENDING &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackProject(types::ProjectSpecifier &aOutput, const PROJECT &aInput)
KICOMMON_API void PackColor(types::Color &aOutput, const KIGFX::COLOR4D &aInput)
KICOMMON_API void UnpackStroke(STROKE_PARAMS &aOutput, const types::StrokeAttributes &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API KIID_PATH UnpackSheetPath(const types::SheetPath &aInput)
KICOMMON_API std::optional< KICAD_T > TypeNameFromAny(const google::protobuf::Any &aMessage)
Definition api_utils.cpp:50
KICOMMON_API void PackPolySet(types::PolySet &aOutput, const SHAPE_POLY_SET &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API VECTOR3D UnpackVector3D(const types::Vector3D &aInput)
KICOMMON_API LINE_ENDING UnpackLineEnding(const types::LineEnding &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API KIGFX::COLOR4D UnpackColor(const types::Color &aInput)
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API ApiResponseStatus MakeResponseStatus(ApiStatusCode aCode, const std::string &aMessage)
Definition api_utils.cpp:39
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackBox2(types::Box2 &aOutput, const BOX2I &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API std::optional< wxString > GeneratorTypeFromAny(const google::protobuf::Any &aMessage)
KICOMMON_API void PackDistance(types::Distance &aOutput, int aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API BOX2I UnpackBox2(const types::Box2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API SHAPE_LINE_CHAIN UnpackPolyLine(const types::PolyLine &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackStroke(types::StrokeAttributes &aOutput, const STROKE_PARAMS &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackSheetPath(types::SheetPath &aOutput, const KIID_PATH &aInput)
KICOMMON_API void PackLibId(types::LibraryIdentifier *aOutput, const LIB_ID &aId)
KICOMMON_API LIB_ID UnpackLibId(const types::LibraryIdentifier &aId)
KICOMMON_API bool PackKiwayApiMessage(const google::protobuf::Message &aMessage, std::string &aBytes)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
const KICOMMON_API std::string KiwayClientName
KICOMMON_API void PackPolyLine(types::PolyLine &aOutput, const SHAPE_LINE_CHAIN &aSlc, const EDA_IU_SCALE &aScale)
KICOMMON_API SHAPE_POLY_SET UnpackPolySet(const types::PolySet &aInput, const EDA_IU_SCALE &aScale)
const KICOMMON_API std::string StandaloneCrossProbeClientName
KICOMMON_API void PackVector3D(types::Vector3D &aOutput, const VECTOR3D &aInput)
constexpr double NmToIUD(int64_t nm) const
Definition base_units.h:121
constexpr int64_t IUToNm(int iu) const
Definition base_units.h:110
@ SCH_GROUP_T
Definition typeinfo.h:169
@ SCH_TABLE_T
Definition typeinfo.h:161
@ PCB_CONSTRAINT_T
a geometric constraint between board items
Definition typeinfo.h:237
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:80
@ SCH_LINE_T
Definition typeinfo.h:159
@ LIB_SYMBOL_T
Definition typeinfo.h:144
@ SCH_NO_CONNECT_T
Definition typeinfo.h:156
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:83
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ PCB_DRILL_MAP_T
class PCB_DRILL_MAP, drill symbols drawn at the holes
Definition typeinfo.h:240
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:103
@ SCH_TABLECELL_T
Definition typeinfo.h:162
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:85
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:100
@ SCH_FIELD_T
Definition typeinfo.h:146
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:84
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:167
@ SCH_LABEL_T
Definition typeinfo.h:163
@ SCH_SHEET_T
Definition typeinfo.h:171
@ PCB_3D_BODY_T
class PCB_3D_BODY, a 3D body (extruded or model) on a footprint
Definition typeinfo.h:241
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:81
@ SCH_SHAPE_T
Definition typeinfo.h:145
@ SCH_RULE_AREA_T
Definition typeinfo.h:166
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:82
@ SCH_HIER_LABEL_T
Definition typeinfo.h:165
@ SCH_BUS_BUS_ENTRY_T
Definition typeinfo.h:158
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:93
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
Definition typeinfo.h:87
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:78
@ PCB_GRID_ITEM_T
a subgrid placed on a board
Definition typeinfo.h:238
@ SCH_TEXT_T
Definition typeinfo.h:147
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:157
@ SCH_BITMAP_T
Definition typeinfo.h:160
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:90
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
Definition typeinfo.h:92
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:86
@ SCH_TEXTBOX_T
Definition typeinfo.h:148
@ PCB_STACKUP_TABLE_T
class PCB_STACKUP_TABLE, a live stackup table derived from PCB_TABLE
Definition typeinfo.h:242
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
Definition typeinfo.h:105
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:88
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
Definition typeinfo.h:239
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:164
@ SCH_JUNCTION_T
Definition typeinfo.h:155
@ SCH_PIN_T
Definition typeinfo.h:149
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR3< double > VECTOR3D
Definition vector3.h:230
static PIECE polygon(std::vector< VIA_CROSS_SECTION_GEOMETRY::POINT > aPoints, bool aMixed=false)