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
78 HANDLER_RESULT<Empty> handleInteractiveMoveItems( InteractiveMoveItems& aMsg,
79 const HANDLER_CONTEXT& aCtx );
80
82 const HANDLER_CONTEXT& aCtx );
83
84 HANDLER_RESULT<Empty> handleRefillZones( RefillZones& aMsg, const HANDLER_CONTEXT& aCtx );
85
86protected:
87 std::unique_ptr<COMMIT> createCommit() override;
88
89 kiapi::common::types::DocumentType thisDocumentType() const override
90 {
91 return kiapi::common::types::DOCTYPE_PCB;
92 }
93
94 bool validateDocumentInternal( const DocumentSpecifier& aDocument ) const override;
95
96 void deleteItemsInternal( std::map<KIID, ItemDeletionStatus>& aItemsToDelete,
97 const HANDLER_CONTEXT& aCtx ) override;
98
99 std::optional<EDA_ITEM*> getItemFromDocument( const DocumentSpecifier& aDocument,
100 const KIID& aId ) override;
101
102private:
103 PCB_EDIT_FRAME* frame() const;
104
105 void pushCurrentCommit( const HANDLER_CONTEXT& aCtx, const wxString& aMessage ) override;
106
107 std::optional<BOARD_ITEM*> getItemById( const KIID& aId ) const;
108
110 const HANDLER_CONTEXT& aCtx,
111 const types::ItemHeader &aHeader,
112 const google::protobuf::RepeatedPtrField<google::protobuf::Any>& aItems,
113 std::function<void(commands::ItemStatus, google::protobuf::Any)> aItemHandler )
114 override;
115};
116
117#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
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
HANDLER_RESULT< commands::BoundingBoxResponse > handleGetTextExtents(GetTextExtents &aMsg, const HANDLER_CONTEXT &aCtx)
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< 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)
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.
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:77
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
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