/* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2023 Jon Evans * Copyright The 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 #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( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetOpenDocuments( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleSaveDocument( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleSaveCopyOfDocument( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleRevertDocument( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetItems( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetItemsById( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetSelection( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleClearSelection( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleAddToSelection( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleRemoveFromSelection( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetStackup( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetGraphicsDefaults( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetBoardOrigin( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleSetBoardOrigin( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetBoundingBox( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetPadShapeAsPolygon( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleCheckPadstackPresenceOnLayers( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetTitleBlockInfo( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleExpandTextVariables( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleInteractiveMoveItems( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetNets( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetNetClassForNets( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleRefillZones( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleSaveDocumentToString( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleSaveSelectionToString( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleParseAndCreateItemsFromString( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetVisibleLayers( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleSetVisibleLayers( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetActiveLayer( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleSetActiveLayer( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleGetBoardEditorAppearanceSettings( const HANDLER_CONTEXT& aCtx ); HANDLER_RESULT handleSetBoardEditorAppearanceSettings( 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 std::string& aClientName ) override; std::optional getItemFromDocument( const DocumentSpecifier& aDocument, const KIID& aId ) override; private: PCB_EDIT_FRAME* frame() const; void pushCurrentCommit( const std::string& aClientName, const wxString& aMessage ) override; std::optional getItemById( const KIID& aId ) const; HANDLER_RESULT handleCreateUpdateItemsInternal( bool aCreate, const std::string& aClientName, const types::ItemHeader &aHeader, const google::protobuf::RepeatedPtrField& aItems, std::function aItemHandler ) override; }; #endif //KICAD_API_HANDLER_PCB_H