2023-01-29 18:06:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023 Jon Evans <jon@craftyjon.com>
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KICAD_API_HANDLER_PCB_H
|
|
|
|
#define KICAD_API_HANDLER_PCB_H
|
|
|
|
|
|
|
|
#include <google/protobuf/empty.pb.h>
|
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
#include <api/api_handler_editor.h>
|
|
|
|
#include <api/board/board_commands.pb.h>
|
|
|
|
#include <api/board/board_types.pb.h>
|
2023-01-29 18:06:05 +00:00
|
|
|
#include <api/common/commands/editor_commands.pb.h>
|
2024-01-20 23:35:29 +00:00
|
|
|
#include <kiid.h>
|
2023-01-29 18:06:05 +00:00
|
|
|
#include <properties/property_mgr.h>
|
|
|
|
|
|
|
|
using namespace kiapi;
|
|
|
|
using namespace kiapi::common;
|
2024-01-20 23:35:29 +00:00
|
|
|
using namespace kiapi::board::commands;
|
2023-01-29 18:06:05 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
class API_HANDLER_PCB : public API_HANDLER_EDITOR
|
2023-01-29 18:06:05 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
API_HANDLER_PCB( PCB_EDIT_FRAME* aFrame );
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef std::map<std::string, PROPERTY_BASE*> PROTO_PROPERTY_MAP;
|
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
static HANDLER_RESULT<std::unique_ptr<BOARD_ITEM>> createItemForType( KICAD_T aType,
|
2023-01-29 18:06:05 +00:00
|
|
|
BOARD_ITEM_CONTAINER* aContainer );
|
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
HANDLER_RESULT<commands::RunActionResponse> handleRunAction( commands::RunAction& aMsg,
|
|
|
|
const HANDLER_CONTEXT& aCtx );
|
2023-01-29 18:06:05 +00:00
|
|
|
|
|
|
|
HANDLER_RESULT<commands::GetOpenDocumentsResponse> handleGetOpenDocuments(
|
2024-01-20 23:35:29 +00:00
|
|
|
commands::GetOpenDocuments& aMsg, const HANDLER_CONTEXT& aCtx );
|
2023-01-29 18:06:05 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
HANDLER_RESULT<commands::GetItemsResponse> handleGetItems( commands::GetItems& aMsg,
|
|
|
|
const HANDLER_CONTEXT& aCtx );
|
2023-01-29 18:06:05 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
HANDLER_RESULT<BoardStackupResponse> handleGetStackup( GetBoardStackup& aMsg,
|
|
|
|
const HANDLER_CONTEXT& aCtx );
|
2023-01-29 18:06:05 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
HANDLER_RESULT<GraphicsDefaultsResponse> handleGetGraphicsDefaults( GetGraphicsDefaults& aMsg,
|
|
|
|
const HANDLER_CONTEXT& aCtx );
|
|
|
|
|
|
|
|
HANDLER_RESULT<commands::BoundingBoxResponse> handleGetTextExtents( GetTextExtents& 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 );
|
2023-01-29 18:06:05 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
HANDLER_RESULT<Empty> handleRefillZones( RefillZones& aMsg, const HANDLER_CONTEXT& aCtx );
|
2023-01-29 18:06:05 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
protected:
|
|
|
|
std::unique_ptr<COMMIT> createCommit() override;
|
2023-01-29 18:06:05 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
kiapi::common::types::DocumentType thisDocumentType() const override
|
|
|
|
{
|
|
|
|
return kiapi::common::types::DOCTYPE_PCB;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
private:
|
|
|
|
PCB_EDIT_FRAME* frame() const;
|
2023-01-29 18:06:05 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
void pushCurrentCommit( const HANDLER_CONTEXT& aCtx, const wxString& aMessage ) override;
|
2023-01-29 18:06:05 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
std::optional<BOARD_ITEM*> getItemById( const KIID& aId ) const;
|
2023-01-29 18:06:05 +00:00
|
|
|
|
2024-01-20 23:35:29 +00:00
|
|
|
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;
|
2023-01-29 18:06:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //KICAD_API_HANDLER_PCB_H
|