2023-01-29 13:06:05 -05:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023 Jon Evans <jon@craftyjon.com>
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2023-01-29 13:06:05 -05:00
|
|
|
*
|
|
|
|
* 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 18:35:29 -05:00
|
|
|
#include <api/api_handler_editor.h>
|
|
|
|
#include <api/board/board_commands.pb.h>
|
|
|
|
#include <api/board/board_types.pb.h>
|
2023-01-29 13:06:05 -05:00
|
|
|
#include <api/common/commands/editor_commands.pb.h>
|
2024-11-28 19:21:18 -05:00
|
|
|
#include <api/common/commands/project_commands.pb.h>
|
2024-01-20 18:35:29 -05:00
|
|
|
#include <kiid.h>
|
2023-01-29 13:06:05 -05:00
|
|
|
#include <properties/property_mgr.h>
|
|
|
|
|
|
|
|
using namespace kiapi;
|
|
|
|
using namespace kiapi::common;
|
2024-01-20 18:35:29 -05:00
|
|
|
using namespace kiapi::board::commands;
|
2023-01-29 13:06:05 -05: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 18:35:29 -05:00
|
|
|
class API_HANDLER_PCB : public API_HANDLER_EDITOR
|
2023-01-29 13:06:05 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
API_HANDLER_PCB( PCB_EDIT_FRAME* aFrame );
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef std::map<std::string, PROPERTY_BASE*> PROTO_PROPERTY_MAP;
|
|
|
|
|
2024-01-20 18:35:29 -05:00
|
|
|
static HANDLER_RESULT<std::unique_ptr<BOARD_ITEM>> createItemForType( KICAD_T aType,
|
2023-01-29 13:06:05 -05:00
|
|
|
BOARD_ITEM_CONTAINER* aContainer );
|
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<commands::RunActionResponse> handleRunAction( const HANDLER_CONTEXT<commands::RunAction>& aCtx );
|
2023-01-29 13:06:05 -05:00
|
|
|
|
|
|
|
HANDLER_RESULT<commands::GetOpenDocumentsResponse> handleGetOpenDocuments(
|
2024-12-08 20:13:18 -05:00
|
|
|
const HANDLER_CONTEXT<commands::GetOpenDocuments>& aCtx );
|
2023-01-29 13:06:05 -05:00
|
|
|
|
2025-01-04 09:47:26 -05:00
|
|
|
HANDLER_RESULT<Empty> handleSaveDocument( const HANDLER_CONTEXT<commands::SaveDocument>& aCtx );
|
|
|
|
|
|
|
|
HANDLER_RESULT<Empty> handleSaveCopyOfDocument(
|
|
|
|
const HANDLER_CONTEXT<commands::SaveCopyOfDocument>& aCtx );
|
|
|
|
|
|
|
|
HANDLER_RESULT<Empty> handleRevertDocument(
|
|
|
|
const HANDLER_CONTEXT<commands::RevertDocument>& aCtx );
|
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<commands::GetItemsResponse> handleGetItems(
|
|
|
|
const HANDLER_CONTEXT<commands::GetItems>& aCtx );
|
2023-01-29 13:06:05 -05:00
|
|
|
|
2025-05-27 20:02:00 +00:00
|
|
|
HANDLER_RESULT<commands::GetItemsResponse> handleGetItemsById(
|
|
|
|
const HANDLER_CONTEXT<commands::GetItemsById>& aCtx );
|
|
|
|
|
2025-01-21 19:52:38 -05:00
|
|
|
HANDLER_RESULT<commands::SelectionResponse> handleGetSelection(
|
|
|
|
const HANDLER_CONTEXT<commands::GetSelection>& aCtx );
|
|
|
|
|
|
|
|
HANDLER_RESULT<Empty> handleClearSelection(
|
|
|
|
const HANDLER_CONTEXT<commands::ClearSelection>& aCtx );
|
|
|
|
|
|
|
|
HANDLER_RESULT<commands::SelectionResponse> handleAddToSelection(
|
|
|
|
const HANDLER_CONTEXT<commands::AddToSelection>& aCtx );
|
|
|
|
|
|
|
|
HANDLER_RESULT<commands::SelectionResponse> handleRemoveFromSelection(
|
|
|
|
const HANDLER_CONTEXT<commands::RemoveFromSelection>& aCtx );
|
|
|
|
|
|
|
|
HANDLER_RESULT<BoardStackupResponse> handleGetStackup(
|
|
|
|
const HANDLER_CONTEXT<GetBoardStackup>& aCtx );
|
2023-01-29 13:06:05 -05:00
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<GraphicsDefaultsResponse> handleGetGraphicsDefaults(
|
|
|
|
const HANDLER_CONTEXT<GetGraphicsDefaults>& aCtx );
|
2024-01-20 18:35:29 -05:00
|
|
|
|
2025-02-24 22:43:47 -05:00
|
|
|
HANDLER_RESULT<types::Vector2> handleGetBoardOrigin(
|
|
|
|
const HANDLER_CONTEXT<GetBoardOrigin>& aCtx );
|
|
|
|
|
|
|
|
HANDLER_RESULT<Empty> handleSetBoardOrigin( const HANDLER_CONTEXT<SetBoardOrigin>& aCtx );
|
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<commands::GetBoundingBoxResponse> handleGetBoundingBox(
|
|
|
|
const HANDLER_CONTEXT<commands::GetBoundingBox>& aCtx );
|
2024-11-19 22:09:00 -05:00
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<PadShapeAsPolygonResponse> handleGetPadShapeAsPolygon(
|
|
|
|
const HANDLER_CONTEXT<GetPadShapeAsPolygon>& aCtx );
|
2024-11-19 21:17:22 -05:00
|
|
|
|
2025-05-26 21:47:44 -04:00
|
|
|
HANDLER_RESULT<PadstackPresenceResponse> handleCheckPadstackPresenceOnLayers(
|
|
|
|
const HANDLER_CONTEXT<CheckPadstackPresenceOnLayers>& aCtx );
|
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<types::TitleBlockInfo> handleGetTitleBlockInfo(
|
|
|
|
const HANDLER_CONTEXT<commands::GetTitleBlockInfo>& aCtx );
|
2024-11-19 23:44:29 -05:00
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<commands::ExpandTextVariablesResponse> handleExpandTextVariables(
|
|
|
|
const HANDLER_CONTEXT<commands::ExpandTextVariables>& aCtx );
|
2024-11-28 19:21:18 -05:00
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<Empty> handleInteractiveMoveItems( const HANDLER_CONTEXT<InteractiveMoveItems>& aCtx );
|
2024-01-20 18:35:29 -05:00
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<NetsResponse> handleGetNets( const HANDLER_CONTEXT<GetNets>& aCtx );
|
2023-01-29 13:06:05 -05:00
|
|
|
|
2024-12-31 17:51:07 -05:00
|
|
|
HANDLER_RESULT<NetClassForNetsResponse> handleGetNetClassForNets(
|
|
|
|
const HANDLER_CONTEXT<GetNetClassForNets>& aCtx );
|
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<Empty> handleRefillZones( const HANDLER_CONTEXT<RefillZones>& aCtx );
|
2023-01-29 13:06:05 -05:00
|
|
|
|
2024-12-01 21:37:13 -05:00
|
|
|
HANDLER_RESULT<commands::SavedDocumentResponse> handleSaveDocumentToString(
|
2024-12-08 20:13:18 -05:00
|
|
|
const HANDLER_CONTEXT<commands::SaveDocumentToString>& aCtx );
|
2024-12-01 21:37:13 -05:00
|
|
|
|
|
|
|
HANDLER_RESULT<commands::SavedSelectionResponse> handleSaveSelectionToString(
|
2024-12-08 20:13:18 -05:00
|
|
|
const HANDLER_CONTEXT<commands::SaveSelectionToString>& aCtx );
|
2024-12-01 21:37:13 -05:00
|
|
|
|
|
|
|
HANDLER_RESULT<commands::CreateItemsResponse> handleParseAndCreateItemsFromString(
|
2024-12-08 20:13:18 -05:00
|
|
|
const HANDLER_CONTEXT<commands::ParseAndCreateItemsFromString>& aCtx );
|
2024-12-01 21:37:13 -05:00
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<BoardLayers> handleGetVisibleLayers( const HANDLER_CONTEXT<GetVisibleLayers>& aCtx );
|
|
|
|
HANDLER_RESULT<Empty> handleSetVisibleLayers( const HANDLER_CONTEXT<SetVisibleLayers>& aCtx );
|
2024-12-03 21:17:48 -05:00
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
HANDLER_RESULT<BoardLayerResponse> handleGetActiveLayer( const HANDLER_CONTEXT<GetActiveLayer>& aCtx );
|
|
|
|
HANDLER_RESULT<Empty> handleSetActiveLayer( const HANDLER_CONTEXT<SetActiveLayer>& aCtx );
|
2024-12-03 21:17:48 -05:00
|
|
|
|
2024-12-29 22:02:23 -05:00
|
|
|
HANDLER_RESULT<BoardEditorAppearanceSettings> handleGetBoardEditorAppearanceSettings(
|
|
|
|
const HANDLER_CONTEXT<GetBoardEditorAppearanceSettings>& aCtx );
|
|
|
|
|
|
|
|
HANDLER_RESULT<Empty> handleSetBoardEditorAppearanceSettings(
|
|
|
|
const HANDLER_CONTEXT<SetBoardEditorAppearanceSettings>& aCtx );
|
|
|
|
|
2025-09-12 23:44:03 -07:00
|
|
|
HANDLER_RESULT<InjectDrcErrorResponse> handleInjectDrcError(
|
|
|
|
const HANDLER_CONTEXT<InjectDrcError>& aCtx );
|
|
|
|
|
2024-01-20 18:35:29 -05:00
|
|
|
protected:
|
|
|
|
std::unique_ptr<COMMIT> createCommit() override;
|
2023-01-29 13:06:05 -05:00
|
|
|
|
2024-01-20 18:35:29 -05: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,
|
2024-12-08 20:13:18 -05:00
|
|
|
const std::string& aClientName ) override;
|
2024-01-20 18:35:29 -05:00
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
std::optional<EDA_ITEM*> getItemFromDocument( const DocumentSpecifier& aDocument, const KIID& aId ) override;
|
2024-01-20 18:35:29 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
PCB_EDIT_FRAME* frame() const;
|
2023-01-29 13:06:05 -05:00
|
|
|
|
2024-12-08 20:13:18 -05:00
|
|
|
void pushCurrentCommit( const std::string& aClientName, const wxString& aMessage ) override;
|
2023-01-29 13:06:05 -05:00
|
|
|
|
2024-01-20 18:35:29 -05:00
|
|
|
std::optional<BOARD_ITEM*> getItemById( const KIID& aId ) const;
|
2023-01-29 13:06:05 -05:00
|
|
|
|
2024-01-20 18:35:29 -05:00
|
|
|
HANDLER_RESULT<types::ItemRequestStatus> handleCreateUpdateItemsInternal( bool aCreate,
|
2024-12-08 20:13:18 -05:00
|
|
|
const std::string& aClientName,
|
2024-01-20 18:35:29 -05:00
|
|
|
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 13:06:05 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //KICAD_API_HANDLER_PCB_H
|