KiCad PCB EDA Suite
|
#include <api_handler_pcb.h>
Public Member Functions | |
API_HANDLER_PCB (PCB_EDIT_FRAME *aFrame) | |
API_RESULT | Handle (ApiRequest &aMsg) |
Attempt to handle the given API request, if a handler exists in this class for the message. | |
Protected Types | |
typedef std::function< HANDLER_RESULT< ApiResponse >(ApiRequest &)> | REQUEST_HANDLER |
A handler for outer messages (envelopes) that will unpack to inner messages and call a specific handler function. | |
Protected Member Functions | |
std::unique_ptr< COMMIT > | createCommit () override |
Override this to create an appropriate COMMIT subclass for the frame in question. | |
kiapi::common::types::DocumentType | thisDocumentType () const override |
Override this to specify which document type this editor handles. | |
bool | validateDocumentInternal (const DocumentSpecifier &aDocument) const override |
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< std::optional< KIID > > | validateItemHeaderDocument (const kiapi::common::types::ItemHeader &aHeader) |
If the header is valid, returns the item container. | |
HANDLER_RESULT< bool > | validateDocument (const DocumentSpecifier &aDocument) |
virtual std::optional< ApiResponseStatus > | checkForBusy () |
Checks if the editor can accept commands. | |
HANDLER_RESULT< commands::BeginCommitResponse > | handleBeginCommit (commands::BeginCommit &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< commands::EndCommitResponse > | handleEndCommit (commands::EndCommit &aMsg, const HANDLER_CONTEXT &aCtx) |
COMMIT * | getCurrentCommit (const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< commands::CreateItemsResponse > | handleCreateItems (commands::CreateItems &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< commands::UpdateItemsResponse > | handleUpdateItems (commands::UpdateItems &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< commands::DeleteItemsResponse > | handleDeleteItems (commands::DeleteItems &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< commands::HitTestResponse > | handleHitTest (commands::HitTest &aMsg, const HANDLER_CONTEXT &aCtx) |
template<class RequestType , class ResponseType , class HandlerType > | |
void | registerHandler (HANDLER_RESULT< ResponseType >(HandlerType::*aHandler)(RequestType &, const HANDLER_CONTEXT &)) |
Registers an API command handler for the given message types. | |
Protected Attributes | |
std::map< std::string, std::pair< KIID, std::unique_ptr< COMMIT > > > | m_commits |
std::set< std::string > | m_activeClients |
EDA_BASE_FRAME * | m_frame |
std::map< std::string, REQUEST_HANDLER > | m_handlers |
Maps type name (without the URL prefix) to a handler method. | |
Static Protected Attributes | |
static const wxString | m_defaultCommitMessage = _( "Modification from API" ) |
Private Types | |
typedef std::map< std::string, PROPERTY_BASE * > | PROTO_PROPERTY_MAP |
Private Member Functions | |
HANDLER_RESULT< commands::RunActionResponse > | handleRunAction (commands::RunAction &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< commands::GetOpenDocumentsResponse > | handleGetOpenDocuments (commands::GetOpenDocuments &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< commands::GetItemsResponse > | handleGetItems (commands::GetItems &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< BoardStackupResponse > | handleGetStackup (GetBoardStackup &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< GraphicsDefaultsResponse > | handleGetGraphicsDefaults (GetGraphicsDefaults &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< commands::GetBoundingBoxResponse > | handleGetBoundingBox (commands::GetBoundingBox &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< types::Box2 > | handleGetTextExtents (GetTextExtents &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< PadShapeAsPolygonResponse > | handleGetPadShapeAsPolygon (GetPadShapeAsPolygon &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< types::TitleBlockInfo > | handleGetTitleBlockInfo (commands::GetTitleBlockInfo &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< Empty > | handleInteractiveMoveItems (InteractiveMoveItems &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< NetsResponse > | handleGetNets (GetNets &aMsg, const HANDLER_CONTEXT &aCtx) |
HANDLER_RESULT< Empty > | handleRefillZones (RefillZones &aMsg, const HANDLER_CONTEXT &aCtx) |
PCB_EDIT_FRAME * | frame () const |
void | pushCurrentCommit (const HANDLER_CONTEXT &aCtx, const wxString &aMessage) override |
std::optional< BOARD_ITEM * > | getItemById (const KIID &aId) const |
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 |
template<typename MessageType > | |
bool | tryUnpack (ApiRequest &aRequest, ApiResponse &aReply, MessageType &aDest) |
Static Private Member Functions | |
static HANDLER_RESULT< std::unique_ptr< BOARD_ITEM > > | createItemForType (KICAD_T aType, BOARD_ITEM_CONTAINER *aContainer) |
Definition at line 49 of file api_handler_pcb.h.
|
private |
Definition at line 55 of file api_handler_pcb.h.
|
protectedinherited |
A handler for outer messages (envelopes) that will unpack to inner messages and call a specific handler function.
Definition at line 74 of file api_handler.h.
API_HANDLER_PCB::API_HANDLER_PCB | ( | PCB_EDIT_FRAME * | aFrame | ) |
Definition at line 53 of file api_handler_pcb.cpp.
References handleGetBoundingBox(), handleGetGraphicsDefaults(), handleGetItems(), handleGetNets(), handleGetOpenDocuments(), handleGetPadShapeAsPolygon(), handleGetStackup(), handleGetTextExtents(), handleGetTitleBlockInfo(), handleInteractiveMoveItems(), handleRefillZones(), and handleRunAction().
|
protectedvirtualinherited |
Checks if the editor can accept commands.
Definition at line 205 of file api_handler_editor.cpp.
References EDA_BASE_FRAME::CanAcceptApiCommands(), and API_HANDLER_EDITOR::m_frame.
Referenced by API_HANDLER_EDITOR::handleBeginCommit(), API_HANDLER_EDITOR::handleCreateItems(), API_HANDLER_EDITOR::handleDeleteItems(), API_HANDLER_EDITOR::handleEndCommit(), handleGetBoundingBox(), handleGetGraphicsDefaults(), handleGetItems(), handleGetNets(), handleGetStackup(), API_HANDLER_EDITOR::handleHitTest(), handleInteractiveMoveItems(), handleRefillZones(), handleRunAction(), and API_HANDLER_EDITOR::handleUpdateItems().
|
overrideprotectedvirtual |
Override this to create an appropriate COMMIT subclass for the frame in question.
Implements API_HANDLER_EDITOR.
Definition at line 138 of file api_handler_pcb.cpp.
References frame().
|
staticprivate |
Definition at line 165 of file api_handler_pcb.cpp.
References CreateItemForType(), EDA_ITEM::GetFriendlyName(), PCB_FOOTPRINT_T, and PCB_PAD_T.
Referenced by handleCreateUpdateItemsInternal().
|
overrideprotectedvirtual |
Implements API_HANDLER_EDITOR.
Definition at line 474 of file api_handler_pcb.cpp.
References _, HANDLER_CONTEXT::ClientName, frame(), PCB_BASE_FRAME::GetBoard(), API_HANDLER_EDITOR::getCurrentCommit(), BOARD::GetItem(), API_HANDLER_EDITOR::m_activeClients, pushCurrentCommit(), and COMMIT::Remove().
|
private |
Definition at line 81 of file api_handler_pcb.cpp.
References API_HANDLER_EDITOR::m_frame.
Referenced by createCommit(), deleteItemsInternal(), getItemById(), handleCreateUpdateItemsInternal(), handleGetGraphicsDefaults(), handleGetItems(), handleGetNets(), handleGetOpenDocuments(), handleGetStackup(), handleGetTextExtents(), handleGetTitleBlockInfo(), handleInteractiveMoveItems(), handleRefillZones(), handleRunAction(), pushCurrentCommit(), and validateDocumentInternal().
|
protectedinherited |
Definition at line 129 of file api_handler_editor.cpp.
References HANDLER_CONTEXT::ClientName, API_HANDLER_EDITOR::createCommit(), and API_HANDLER_EDITOR::m_commits.
Referenced by deleteItemsInternal(), API_HANDLER_SCH::handleCreateUpdateItemsInternal(), handleCreateUpdateItemsInternal(), and handleInteractiveMoveItems().
|
private |
Definition at line 144 of file api_handler_pcb.cpp.
References frame(), PCB_BASE_FRAME::GetBoard(), DELETED_BOARD_ITEM::GetInstance(), and BOARD::GetItem().
Referenced by getItemFromDocument(), handleCreateUpdateItemsInternal(), handleGetBoundingBox(), handleGetPadShapeAsPolygon(), and handleInteractiveMoveItems().
|
overrideprotectedvirtual |
Implements API_HANDLER_EDITOR.
Definition at line 502 of file api_handler_pcb.cpp.
References getItemById(), and API_HANDLER_EDITOR::validateDocument().
|
inherited |
Attempt to handle the given API request, if a handler exists in this class for the message.
aMsg | is a request to attempt to handle |
Definition at line 30 of file api_handler.cpp.
References API_HANDLER::m_handlers.
|
protectedinherited |
Definition at line 43 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), HANDLER_CONTEXT::ClientName, API_HANDLER_EDITOR::createCommit(), API_HANDLER_EDITOR::m_activeClients, and API_HANDLER_EDITOR::m_commits.
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
protectedinherited |
Definition at line 219 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), and API_HANDLER_EDITOR::handleCreateUpdateItemsInternal().
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
overrideprivatevirtual |
Implements API_HANDLER_EDITOR.
Definition at line 208 of file api_handler_pcb.cpp.
References _, COMMIT::Add(), KIID::AsStdString(), HANDLER_CONTEXT::ClientName, LSET::Contains(), createItemForType(), frame(), PCB_BASE_FRAME::GetBoard(), API_HANDLER_EDITOR::getCurrentCommit(), BOARD::GetEnabledLayers(), getItemById(), LayerName(), API_HANDLER_EDITOR::m_activeClients, COMMIT::Modify(), pushCurrentCommit(), SERIALIZABLE::Serialize(), BOARD_ITEM::SwapItemData(), kiapi::common::TypeNameFromAny(), and API_HANDLER_EDITOR::validateItemHeaderDocument().
|
protectedinherited |
Definition at line 271 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), API_HANDLER_EDITOR::deleteItemsInternal(), and API_HANDLER_EDITOR::validateItemHeaderDocument().
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
protectedinherited |
Definition at line 72 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), HANDLER_CONTEXT::ClientName, API_HANDLER_EDITOR::m_activeClients, API_HANDLER_EDITOR::m_commits, and API_HANDLER_EDITOR::pushCurrentCommit().
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
private |
Definition at line 578 of file api_handler_pcb.cpp.
References API_HANDLER_EDITOR::checkForBusy(), EDA_ITEM::GetBoundingBox(), getItemById(), kiapi::common::PackBox2(), PCB_FOOTPRINT_T, EDA_ITEM::Type(), and API_HANDLER_EDITOR::validateItemHeaderDocument().
Referenced by API_HANDLER_PCB().
|
private |
Definition at line 534 of file api_handler_pcb.cpp.
References API_HANDLER_EDITOR::checkForBusy(), frame(), PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), LAYER_CLASS_COUNT, BOARD_DESIGN_SETTINGS::m_LineThickness, BOARD_DESIGN_SETTINGS::m_TextItalic, BOARD_DESIGN_SETTINGS::m_TextSize, BOARD_DESIGN_SETTINGS::m_TextThickness, BOARD_DESIGN_SETTINGS::m_TextUpright, text, API_HANDLER_EDITOR::validateDocument(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by API_HANDLER_PCB().
|
private |
Definition at line 356 of file api_handler_pcb.cpp.
References API_HANDLER_EDITOR::checkForBusy(), BOARD::Drawings(), BOARD::Footprints(), frame(), PCB_BASE_FRAME::GetBoard(), PCB_ARC_T, PCB_FOOTPRINT_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TRACE_T, PCB_VIA_T, BOARD::Tracks(), TYPE_NOT_INIT, and API_HANDLER_EDITOR::validateItemHeaderDocument().
Referenced by API_HANDLER_PCB().
|
private |
Definition at line 762 of file api_handler_pcb.cpp.
References API_HANDLER_EDITOR::checkForBusy(), frame(), PCB_BASE_FRAME::GetBoard(), NETCLASS::GetName(), BOARD::GetNetInfo(), and API_HANDLER_EDITOR::validateDocument().
Referenced by API_HANDLER_PCB().
|
private |
Definition at line 104 of file api_handler_pcb.cpp.
References frame(), and Prj().
Referenced by API_HANDLER_PCB().
|
private |
Definition at line 653 of file api_handler_pcb.cpp.
References ARC_HIGH_DEF, SHAPE_POLY_SET::COutline(), ERROR_INSIDE, getItemById(), kiapi::common::PackPolyLine(), pad, PCB_PAD_T, and API_HANDLER_EDITOR::validateDocument().
Referenced by API_HANDLER_PCB().
|
private |
Definition at line 512 of file api_handler_pcb.cpp.
References API_HANDLER_EDITOR::checkForBusy(), frame(), PCB_BASE_FRAME::GetBoard(), BOARD::GetStackupOrDefault(), BOARD_STACKUP::Serialize(), and API_HANDLER_EDITOR::validateDocument().
Referenced by API_HANDLER_PCB().
|
private |
Definition at line 619 of file api_handler_pcb.cpp.
References frame(), GetBoard(), BOX2< Vec >::GetBoundingBoxRotated(), BOX2< Vec >::GetPosition(), BOX2< Vec >::GetSize(), EDA_ANGLE::IsZero(), text, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by API_HANDLER_PCB().
|
private |
Definition at line 688 of file api_handler_pcb.cpp.
References frame(), PCB_BASE_FRAME::GetBoard(), TITLE_BLOCK::GetComment(), TITLE_BLOCK::GetCompany(), TITLE_BLOCK::GetDate(), TITLE_BLOCK::GetRevision(), TITLE_BLOCK::GetTitle(), BOARD::GetTitleBlock(), and API_HANDLER_EDITOR::validateDocument().
Referenced by API_HANDLER_PCB().
|
protectedinherited |
Definition at line 320 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), API_HANDLER_EDITOR::getItemFromDocument(), kiapi::common::UnpackVector2(), and API_HANDLER_EDITOR::validateItemHeaderDocument().
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
private |
Definition at line 720 of file api_handler_pcb.cpp.
References API_HANDLER_EDITOR::checkForBusy(), frame(), API_HANDLER_EDITOR::getCurrentCommit(), getItemById(), PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::GetToolManager(), PCB_ACTIONS::move, TOOL_MANAGER::PostAction(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItems, SELECTION::SetReferencePoint(), and API_HANDLER_EDITOR::validateDocument().
Referenced by API_HANDLER_PCB().
|
private |
Definition at line 797 of file api_handler_pcb.cpp.
References API_HANDLER_EDITOR::checkForBusy(), frame(), TOOLS_HOLDER::GetToolManager(), TOOL_MANAGER::RunAction(), API_HANDLER_EDITOR::validateDocument(), and PCB_ACTIONS::zoneFillAll.
Referenced by API_HANDLER_PCB().
|
private |
Definition at line 87 of file api_handler_pcb.cpp.
References API_HANDLER_EDITOR::checkForBusy(), and frame().
Referenced by API_HANDLER_PCB().
|
protectedinherited |
Definition at line 245 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::checkForBusy(), and API_HANDLER_EDITOR::handleCreateUpdateItemsInternal().
Referenced by API_HANDLER_EDITOR::API_HANDLER_EDITOR().
|
overrideprivatevirtual |
Reimplemented from API_HANDLER_EDITOR.
Definition at line 131 of file api_handler_pcb.cpp.
References frame(), and API_HANDLER_EDITOR::pushCurrentCommit().
Referenced by deleteItemsInternal(), and handleCreateUpdateItemsInternal().
|
inlineprotectedinherited |
Registers an API command handler for the given message types.
When an API request matching the given type comes in, the handler will be called and its response will be packed into an envelope for sending back to the API client.
If the given message does not unpack into the request type, an envelope is returned with status AS_BAD_REQUEST, which probably indicates corruption in the message.
RequestType | is a protobuf message type containing a command |
ResponseType | is a protobuf message type containing a command response |
HandlerType | is the implied type of the API_HANDLER subclass |
aHandler | is the handler function for the given request and response types |
Definition at line 91 of file api_handler.h.
References HANDLER_CONTEXT::ClientName.
|
inlineoverrideprotectedvirtual |
Override this to specify which document type this editor handles.
Implements API_HANDLER_EDITOR.
Definition at line 98 of file api_handler_pcb.h.
|
inlineprivateinherited |
Definition at line 136 of file api_handler.h.
|
protectedinherited |
Definition at line 154 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::validateDocumentInternal().
Referenced by API_HANDLER_SCH::getItemFromDocument(), getItemFromDocument(), handleGetGraphicsDefaults(), handleGetNets(), handleGetPadShapeAsPolygon(), handleGetStackup(), handleGetTitleBlockInfo(), handleInteractiveMoveItems(), handleRefillZones(), and API_HANDLER_EDITOR::validateItemHeaderDocument().
|
overrideprotectedvirtual |
Implements API_HANDLER_EDITOR.
Definition at line 155 of file api_handler_pcb.cpp.
References frame().
|
protectedinherited |
If the header is valid, returns the item container.
Definition at line 170 of file api_handler_editor.cpp.
References API_HANDLER_EDITOR::thisDocumentType(), API_HANDLER_EDITOR::validateDocument(), and API_HANDLER_EDITOR::validateDocumentInternal().
Referenced by API_HANDLER_SCH::handleCreateUpdateItemsInternal(), handleCreateUpdateItemsInternal(), API_HANDLER_EDITOR::handleDeleteItems(), handleGetBoundingBox(), handleGetItems(), and API_HANDLER_EDITOR::handleHitTest().
|
protectedinherited |
Definition at line 110 of file api_handler_editor.h.
Referenced by deleteItemsInternal(), API_HANDLER_EDITOR::handleBeginCommit(), API_HANDLER_SCH::handleCreateUpdateItemsInternal(), handleCreateUpdateItemsInternal(), API_HANDLER_EDITOR::handleEndCommit(), and API_HANDLER_EDITOR::pushCurrentCommit().
|
protectedinherited |
Definition at line 108 of file api_handler_editor.h.
Referenced by API_HANDLER_EDITOR::getCurrentCommit(), API_HANDLER_EDITOR::handleBeginCommit(), API_HANDLER_EDITOR::handleEndCommit(), and API_HANDLER_EDITOR::pushCurrentCommit().
|
staticprotectedinherited |
Definition at line 131 of file api_handler.h.
Referenced by API_HANDLER_EDITOR::pushCurrentCommit().
|
protectedinherited |
Definition at line 112 of file api_handler_editor.h.
Referenced by API_HANDLER_EDITOR::checkForBusy(), and frame().
|
protectedinherited |
Maps type name (without the URL prefix) to a handler method.
Definition at line 129 of file api_handler.h.
Referenced by API_HANDLER::Handle().