/* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2023 Jon Evans * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef KICAD_API_HANDLER_PCB_H #define KICAD_API_HANDLER_PCB_H #include #include #include #include #include #include #include using namespace kiapi; using namespace kiapi::common; using namespace kiapi::board::commands; using google::protobuf::Empty; class BOARD_COMMIT; class BOARD_ITEM; class BOARD_ITEM_CONTAINER; class EDA_ITEM; class PCB_EDIT_FRAME; class PCB_TRACK; class PROPERTY_BASE; class API_HANDLER_PCB : public API_HANDLER_EDITOR { public: API_HANDLER_PCB( PCB_EDIT_FRAME* aFrame ); private: typedef std::map PROTO_PROPERTY_MAP; static HANDLER_RESULT> createItemForType( KICAD_T aType, BOARD_ITEM_CONTAINER* aContainer ); HANDLER_RESULT handleRunAction( commands::RunAction& aMsg, const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetOpenDocuments( commands::GetOpenDocuments& aMsg, const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetItems( commands::GetItems& aMsg, const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetStackup( GetBoardStackup& aMsg, const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetGraphicsDefaults( GetGraphicsDefaults& aMsg, const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetTextExtents( GetTextExtents& aMsg, const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleInteractiveMoveItems( InteractiveMoveItems& aMsg, const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetNets( GetNets& aMsg, const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleRefillZones( RefillZones& aMsg, const HANDLER_CONTEXT& aCtx ); protected: std::unique_ptr createCommit() override; kiapi::common::types::DocumentType thisDocumentType() const override { return kiapi::common::types::DOCTYPE_PCB; } bool validateDocumentInternal( const DocumentSpecifier& aDocument ) const override; void deleteItemsInternal( std::map& aItemsToDelete, const HANDLER_CONTEXT& aCtx ) override; std::optional getItemFromDocument( const DocumentSpecifier& aDocument, const KIID& aId ) override; private: PCB_EDIT_FRAME* frame() const; void pushCurrentCommit( const HANDLER_CONTEXT& aCtx, const wxString& aMessage ) override; std::optional getItemById( const KIID& aId ) const; HANDLER_RESULT handleCreateUpdateItemsInternal( bool aCreate, const HANDLER_CONTEXT& aCtx, const types::ItemHeader &aHeader, const google::protobuf::RepeatedPtrField& aItems, std::function aItemHandler ) override; }; #endif //KICAD_API_HANDLER_PCB_H