KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_utils.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) 2024 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 KICAD_API_UTILS_H
22#define KICAD_API_UTILS_H
23
24#include <optional>
25#include <google/protobuf/any.pb.h>
26
27#include <base_units.h>
28#include <core/typeinfo.h>
29#include <lib_id.h>
30#include <api/common/types/base_types.pb.h>
31#include <layer_ids.h>
33#include <math/vector2d.h>
34#include <math/vector3.h>
35#include <gal/color4d.h>
36
38class KIID_PATH;
39class PROJECT;
40
48extern const KICOMMON_API wxChar* const traceApi;
49
50namespace kiapi::common
51{
52
53KICOMMON_API std::optional<KICAD_T> TypeNameFromAny( const google::protobuf::Any& aMessage );
54
55KICOMMON_API LIB_ID UnpackLibId( const types::LibraryIdentifier& aId );
56
57KICOMMON_API void PackLibId( types::LibraryIdentifier* aOutput, const LIB_ID& aId );
58
59KICOMMON_API void PackVector2( types::Vector2& aOutput, const VECTOR2I& aInput,
60 const EDA_IU_SCALE& aScale = pcbIUScale );
61
62KICOMMON_API VECTOR2I UnpackVector2( const types::Vector2& aInput, const EDA_IU_SCALE& aScale = pcbIUScale );
63
64KICOMMON_API void PackVector3D( types::Vector3D& aOutput, const VECTOR3D& aInput );
65
66KICOMMON_API VECTOR3D UnpackVector3D( const types::Vector3D& aInput );
67
68KICOMMON_API void PackBox2( types::Box2& aOutput, const BOX2I& aInput, const EDA_IU_SCALE& aScale = pcbIUScale );
69
70KICOMMON_API BOX2I UnpackBox2( const types::Box2& aInput, const EDA_IU_SCALE& aScale = pcbIUScale );
71
72KICOMMON_API void PackPolyLine( types::PolyLine& aOutput, const SHAPE_LINE_CHAIN& aSlc,
73 const EDA_IU_SCALE& aScale = pcbIUScale );
74
75KICOMMON_API SHAPE_LINE_CHAIN UnpackPolyLine( const types::PolyLine& aInput, const EDA_IU_SCALE& aScale = pcbIUScale );
76
77KICOMMON_API void PackPolySet( types::PolySet& aOutput, const SHAPE_POLY_SET& aInput,
78 const EDA_IU_SCALE& aScale = pcbIUScale );
79
80KICOMMON_API SHAPE_POLY_SET UnpackPolySet( const types::PolySet& aInput, const EDA_IU_SCALE& aScale = pcbIUScale );
81
82KICOMMON_API void PackColor( types::Color& aOutput, const KIGFX::COLOR4D& aInput );
83
84KICOMMON_API KIGFX::COLOR4D UnpackColor( const types::Color& aInput );
85
86KICOMMON_API void PackDistance( types::Distance& aOutput, int aInput, const EDA_IU_SCALE& aScale = pcbIUScale );
87
88KICOMMON_API int UnpackDistance( const types::Distance& aInput, const EDA_IU_SCALE& aScale = pcbIUScale );
89
90KICOMMON_API void PackSheetPath( types::SheetPath& aOutput, const KIID_PATH& aInput );
91
92KICOMMON_API KIID_PATH UnpackSheetPath( const types::SheetPath& aInput );
93
94KICOMMON_API void PackProject( types::ProjectSpecifier& aOutput, const PROJECT& aInput );
95
96} // namespace kiapi::common
97
98#endif //KICAD_API_UTILS_H
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:125
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
Container for project specific data.
Definition project.h:66
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const wxChar *const traceApi
Flag to enable debug output related to the IPC API and its plugin system.
Definition api_utils.cpp:29
#define KICOMMON_API
Definition kicommon.h:27
KICOMMON_API void PackProject(types::ProjectSpecifier &aOutput, const PROJECT &aInput)
KICOMMON_API void PackColor(types::Color &aOutput, const KIGFX::COLOR4D &aInput)
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:35
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 KIGFX::COLOR4D UnpackColor(const types::Color &aInput)
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 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 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 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)
KICOMMON_API void PackVector3D(types::Vector3D &aOutput, const VECTOR3D &aInput)
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687
VECTOR3< double > VECTOR3D
Definition vector3.h:230