KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_handler_pcb.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) 2023 Jon Evans <[email protected]>
5 * Copyright (C) 2023 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_HANDLER_PCB_H
22#define KICAD_API_HANDLER_PCB_H
23
24#include <google/protobuf/empty.pb.h>
25
27#include <api/board/board_commands.pb.h>
28#include <api/board/board_types.pb.h>
29#include <api/common/commands/editor_commands.pb.h>
30#include <kiid.h>
32
33using namespace kiapi;
34using namespace kiapi::common;
35using namespace kiapi::board::commands;
36
37using google::protobuf::Empty;
38
39
40class BOARD_COMMIT;
41class BOARD_ITEM;
43class EDA_ITEM;
44class PCB_EDIT_FRAME;
45class PCB_TRACK;
46class PROPERTY_BASE;
47
48
50{
51public:
53
54private:
55 typedef std::map<std::string, PROPERTY_BASE*> PROTO_PROPERTY_MAP;
56
58 BOARD_ITEM_CONTAINER* aContainer );
59
61 const HANDLER_CONTEXT& aCtx );
62
64 commands::GetOpenDocuments& aMsg, const HANDLER_CONTEXT& aCtx );
65
67 const HANDLER_CONTEXT& aCtx );
68
70 const HANDLER_CONTEXT& aCtx );
71
73 const HANDLER_CONTEXT& aCtx );
74
76 const HANDLER_CONTEXT& aCtx );
77
79 const HANDLER_CONTEXT& aCtx );
80
82 const HANDLER_CONTEXT& aCtx );
83
84 HANDLER_RESULT<types::TitleBlockInfo> handleGetTitleBlockInfo( commands::GetTitleBlockInfo& aMsg,
85 const HANDLER_CONTEXT& aCtx );
86
87 HANDLER_RESULT<Empty> handleInteractiveMoveItems( InteractiveMoveItems& aMsg,
88 const HANDLER_CONTEXT& aCtx );
89
91 const HANDLER_CONTEXT& aCtx );
92
93 HANDLER_RESULT<Empty> handleRefillZones( RefillZones& aMsg, const HANDLER_CONTEXT& aCtx );
94
95protected:
96 std::unique_ptr<COMMIT> createCommit() override;
97
98 kiapi::common::types::DocumentType thisDocumentType() const override
99 {
100 return kiapi::common::types::DOCTYPE_PCB;
101 }
102
103 bool validateDocumentInternal( const DocumentSpecifier& aDocument ) const override;
104
105 void deleteItemsInternal( std::map<KIID, ItemDeletionStatus>& aItemsToDelete,
106 const HANDLER_CONTEXT& aCtx ) override;
107
108 std::optional<EDA_ITEM*> getItemFromDocument( const DocumentSpecifier& aDocument,
109 const KIID& aId ) override;
110
111private:
112 PCB_EDIT_FRAME* frame() const;
113
114 void pushCurrentCommit( const HANDLER_CONTEXT& aCtx, const wxString& aMessage ) override;
115
116 std::optional<BOARD_ITEM*> getItemById( const KIID& aId ) const;
117
119 const HANDLER_CONTEXT& aCtx,
120 const types::ItemHeader &aHeader,
121 const google::protobuf::RepeatedPtrField<google::protobuf::Any>& aItems,
122 std::function<void(commands::ItemStatus, google::protobuf::Any)> aItemHandler )
123 override;
124};
125
126#endif //KICAD_API_HANDLER_PCB_H
tl::expected< T, ApiResponseStatus > HANDLER_RESULT
Definition: api_handler.h:45
Base class for API handlers related to editor frames.
HANDLER_RESULT< commands::GetItemsResponse > handleGetItems(commands::GetItems &aMsg, const HANDLER_CONTEXT &aCtx)
bool validateDocumentInternal(const DocumentSpecifier &aDocument) const override
HANDLER_RESULT< types::TitleBlockInfo > handleGetTitleBlockInfo(commands::GetTitleBlockInfo &aMsg, const HANDLER_CONTEXT &aCtx)
static HANDLER_RESULT< std::unique_ptr< BOARD_ITEM > > createItemForType(KICAD_T aType, BOARD_ITEM_CONTAINER *aContainer)
std::optional< BOARD_ITEM * > getItemById(const KIID &aId) const
std::unique_ptr< COMMIT > createCommit() override
Override this to create an appropriate COMMIT subclass for the frame in question.
HANDLER_RESULT< Empty > handleInteractiveMoveItems(InteractiveMoveItems &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< BoardStackupResponse > handleGetStackup(GetBoardStackup &aMsg, const HANDLER_CONTEXT &aCtx)
void deleteItemsInternal(std::map< KIID, ItemDeletionStatus > &aItemsToDelete, const HANDLER_CONTEXT &aCtx) override
std::optional< EDA_ITEM * > getItemFromDocument(const DocumentSpecifier &aDocument, const KIID &aId) override
HANDLER_RESULT< commands::RunActionResponse > handleRunAction(commands::RunAction &aMsg, const HANDLER_CONTEXT &aCtx)
std::map< std::string, PROPERTY_BASE * > PROTO_PROPERTY_MAP
HANDLER_RESULT< commands::GetBoundingBoxResponse > handleGetBoundingBox(commands::GetBoundingBox &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< types::ItemRequestStatus > handleCreateUpdateItemsInternal(bool aCreate, const HANDLER_CONTEXT &aCtx, const types::ItemHeader &aHeader, const google::protobuf::RepeatedPtrField< google::protobuf::Any > &aItems, std::function< void(commands::ItemStatus, google::protobuf::Any)> aItemHandler) override
HANDLER_RESULT< Empty > handleRefillZones(RefillZones &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< GraphicsDefaultsResponse > handleGetGraphicsDefaults(GetGraphicsDefaults &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< types::Box2 > handleGetTextExtents(GetTextExtents &aMsg, const HANDLER_CONTEXT &aCtx)
void pushCurrentCommit(const HANDLER_CONTEXT &aCtx, const wxString &aMessage) override
HANDLER_RESULT< commands::GetOpenDocumentsResponse > handleGetOpenDocuments(commands::GetOpenDocuments &aMsg, const HANDLER_CONTEXT &aCtx)
kiapi::common::types::DocumentType thisDocumentType() const override
Override this to specify which document type this editor handles.
HANDLER_RESULT< PadShapeAsPolygonResponse > handleGetPadShapeAsPolygon(GetPadShapeAsPolygon &aMsg, const HANDLER_CONTEXT &aCtx)
PCB_EDIT_FRAME * frame() const
HANDLER_RESULT< NetsResponse > handleGetNets(GetNets &aMsg, const HANDLER_CONTEXT &aCtx)
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
Definition: kiid.h:49
The main frame for Pcbnew.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78