22#include <magic_enum.hpp>
44#include <api/common/types/base_types.pb.h>
46using namespace kiapi::common::commands;
47using types::CommandStatus;
48using types::DocumentType;
49using types::ItemRequestStatus;
98 const std::string& aCommandName )
const
104 e.set_status( ApiStatusCode::AS_UNIMPLEMENTED );
105 e.set_error_message( fmt::format(
"{} is not available in headless mode", aCommandName ) );
117 const wxString& aMessage )
131 return std::make_unique<BOARD_COMMIT>(
toolManager(),
true,
false );
152 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
153 e.set_error_message(
"Tried to create an item in a null container" );
154 return tl::unexpected( e );
160 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
161 e.set_error_message( fmt::format(
"Tried to create a pad in {}, which is not a footprint",
163 return tl::unexpected( e );
168 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
169 e.set_error_message( fmt::format(
"Tried to create a footprint in {}, which is not a board",
171 return tl::unexpected( e );
179 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
180 e.set_error_message( fmt::format(
"Tried to create an item of type {}, which is unhandled",
181 magic_enum::enum_name( aType ) ) );
182 return tl::unexpected( e );
190 const std::string& aClientName )
193 std::vector<BOARD_ITEM*> validatedItems;
195 for( std::pair<const KIID, ItemDeletionStatus> pair : aItemsToDelete )
199 validatedItems.push_back( item );
200 aItemsToDelete[pair.first] = ItemDeletionStatus::IDS_OK;
218 const DocumentSpecifier& aDocument,
const KIID& aId )
228 const std::string& aClientName,
229 const types::ItemHeader &aHeader,
230 const google::protobuf::RepeatedPtrField<google::protobuf::Any>& aItems,
231 std::function<
void( ItemStatus, google::protobuf::Any )> aItemHandler )
237 if( !containerResult && containerResult.error().status() == ApiStatusCode::AS_UNHANDLED )
240 e.set_status( ApiStatusCode::AS_UNHANDLED );
241 return tl::unexpected( e );
243 else if( !containerResult )
245 e.CopyFrom( containerResult.error() );
246 return tl::unexpected( e );
252 if( containerResult->has_value() )
254 const KIID& containerId = **containerResult;
255 std::optional<BOARD_ITEM*> optItem =
getItemById( containerId );
263 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
264 e.set_error_message( fmt::format(
265 "The requested container {} is not a valid board item container",
267 return tl::unexpected( e );
272 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
273 e.set_error_message( fmt::format(
274 "The requested container {} does not exist in this document",
276 return tl::unexpected( e );
282 for(
const google::protobuf::Any& anyItem : aItems )
289 status.set_code( ItemStatusCode::ISC_INVALID_TYPE );
290 status.set_error_message( fmt::format(
"Could not decode a valid type from {}",
291 anyItem.type_url() ) );
292 aItemHandler( status, anyItem );
298 board::types::Dimension dimension;
299 anyItem.UnpackTo( &dimension );
301 switch( dimension.dimension_style_case() )
308 case board::types::Dimension::DIMENSION_STYLE_NOT_SET:
break;
315 if( !creationResult )
317 status.set_code( ItemStatusCode::ISC_INVALID_TYPE );
318 status.set_error_message( creationResult.error().error_message() );
319 aItemHandler( status, anyItem );
323 std::unique_ptr<BOARD_ITEM> item( std::move( *creationResult ) );
325 if( !item->Deserialize( anyItem ) )
327 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
328 e.set_error_message( fmt::format(
"could not unpack {} from request",
329 item->GetClass().ToStdString() ) );
330 return tl::unexpected( e );
333 std::optional<BOARD_ITEM*> optItem =
getItemById( item->m_Uuid );
335 if( aCreate && optItem )
337 status.set_code( ItemStatusCode::ISC_EXISTING );
338 status.set_error_message( fmt::format(
"an item with UUID {} already exists",
339 item->m_Uuid.AsStdString() ) );
340 aItemHandler( status, anyItem );
343 else if( !aCreate && !optItem )
345 status.set_code( ItemStatusCode::ISC_NONEXISTENT );
346 status.set_error_message( fmt::format(
"an item with UUID {} does not exist",
347 item->m_Uuid.AsStdString() ) );
348 aItemHandler( status, anyItem );
353 && !item->FitsEnabledLayers(
board->GetEnabledLayers(),
board->GetCopperLayerCount() ) )
355 status.set_code( ItemStatusCode::ISC_INVALID_DATA );
356 status.set_error_message(
357 "attempted to add item with no overlapping layers with the board" );
358 aItemHandler( status, anyItem );
362 status.set_code( ItemStatusCode::ISC_OK );
363 google::protobuf::Any newItem;
379 item->Serialize( newItem );
380 commit->
Add( item.release() );
397 commit->
Remove( boardItem );
398 item->Serialize( newItem );
401 commit->
Add( newBoardItem );
405 parentGroup->
AddItem( newBoardItem );
409 commit->
Modify( boardItem );
415 aItemHandler( status, newItem );
421 :
_(
"Modified items via API" ) );
425 return ItemRequestStatus::IRS_OK;
430 const google::protobuf::RepeatedField<int>& aTypes )
432 std::vector<KICAD_T> types;
434 for(
int typeRaw : aTypes )
436 auto typeMessage =
static_cast<common::types::KiCadObjectType
>( typeRaw );
440 types.emplace_back( type );
450 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"RunAction" ) )
451 return tl::unexpected( *headless );
453 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
454 return tl::unexpected( *busy );
456 RunActionResponse response;
459 response.set_status( RunActionStatus::RAS_OK );
461 response.set_status( RunActionStatus::RAS_INVALID );
470 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
471 return tl::unexpected( *busy );
476 e.set_status( ApiStatusCode::AS_UNHANDLED );
477 return tl::unexpected( e );
480 GetItemsResponse response;
482 std::vector<BOARD_ITEM*> items;
484 for(
const kiapi::common::types::KIID&
id : aCtx.
Request.items() )
486 if( std::optional<BOARD_ITEM*> item =
getItemById(
KIID(
id.value() ) ) )
487 items.emplace_back( *item );
493 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
494 e.set_error_message(
"none of the requested IDs were found or valid" );
495 return tl::unexpected( e );
500 google::protobuf::Any itemBuf;
501 item->Serialize( itemBuf );
502 response.mutable_items()->Add( std::move( itemBuf ) );
505 response.set_status( ItemRequestStatus::IRS_OK );
513 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"GetSelection" ) )
514 return tl::unexpected( *headless );
520 e.set_status( ApiStatusCode::AS_UNHANDLED );
521 return tl::unexpected( e );
532 SelectionResponse response;
537 item->Serialize( *response.add_items() );
547 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"ClearSelection" ) )
548 return tl::unexpected( *headless );
550 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
551 return tl::unexpected( *busy );
557 e.set_status( ApiStatusCode::AS_UNHANDLED );
558 return tl::unexpected( e );
572 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"AddToSelection" ) )
573 return tl::unexpected( *headless );
575 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
576 return tl::unexpected( *busy );
582 e.set_status( ApiStatusCode::AS_UNHANDLED );
583 return tl::unexpected( e );
589 std::vector<EDA_ITEM*> toAdd;
591 for(
const types::KIID&
id : aCtx.
Request.items() )
593 if( std::optional<BOARD_ITEM*> item =
getItemById(
KIID(
id.value() ) ) )
594 toAdd.emplace_back( *item );
600 SelectionResponse response;
603 item->Serialize( *response.add_items() );
612 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"RemoveFromSelection" ) )
613 return tl::unexpected( *headless );
615 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
616 return tl::unexpected( *busy );
622 e.set_status( ApiStatusCode::AS_UNHANDLED );
623 return tl::unexpected( e );
629 std::vector<EDA_ITEM*> toRemove;
631 for(
const types::KIID&
id : aCtx.
Request.items() )
633 if( std::optional<BOARD_ITEM*> item =
getItemById(
KIID(
id.value() ) ) )
634 toRemove.emplace_back( *item );
640 SelectionResponse response;
643 item->Serialize( *response.add_items() );
654 if( !documentValidation )
655 return tl::unexpected( documentValidation.error() );
657 BoardStackupResponse response;
658 google::protobuf::Any
any;
662 any.UnpackTo( response.mutable_stackup() );
665 for( board::BoardStackupLayer& layer : *response.mutable_stackup()->mutable_layers() )
667 if( layer.type() == board::BoardStackupLayerType::BSLT_DIELECTRIC )
673 layer.set_user_name(
board()->GetLayerName(
id ) );
685 if( !documentValidation )
686 return tl::unexpected( documentValidation.error() );
688 BoardEnabledLayersResponse response;
691 int copperLayerCount =
board->GetCopperLayerCount();
693 response.set_copper_layer_count( copperLayerCount );
695 LSET enabled =
board->GetEnabledLayers();
714 if( !documentValidation )
715 return tl::unexpected( documentValidation.error() );
718 GraphicsDefaultsResponse response;
721 constexpr std::array<kiapi::board::BoardLayerClass, LAYER_CLASS_COUNT> classOrder = {
722 kiapi::board::BLC_SILKSCREEN,
723 kiapi::board::BLC_COPPER,
724 kiapi::board::BLC_EDGES,
725 kiapi::board::BLC_COURTYARD,
726 kiapi::board::BLC_FABRICATION,
727 kiapi::board::BLC_OTHER
732 kiapi::board::BoardLayerGraphicsDefaults* l = response.mutable_defaults()->add_layers();
734 l->set_layer( classOrder[i] );
737 kiapi::common::types::TextAttributes*
text = l->mutable_text();
752 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
753 return tl::unexpected( *busy );
759 e.set_status( ApiStatusCode::AS_UNHANDLED );
760 return tl::unexpected( e );
763 GetBoundingBoxResponse response;
764 bool includeText = aCtx.
Request.mode() == BoundingBoxMode::BBM_ITEM_AND_CHILD_TEXT;
766 for(
const types::KIID& idMsg : aCtx.
Request.items() )
768 KIID id( idMsg.value() );
769 std::optional<BOARD_ITEM*> optItem =
getItemById(
id );
778 bbox =
static_cast<FOOTPRINT*
>( item )->GetBoundingBox( includeText );
782 response.add_items()->set_value( idMsg.value() );
783 PackBox2( *response.add_boxes(), bbox );
794 !documentValidation )
796 return tl::unexpected( documentValidation.error() );
799 PadShapeAsPolygonResponse response;
802 for(
const types::KIID& padRequest : aCtx.
Request.pads() )
804 KIID id( padRequest.value() );
805 std::optional<BOARD_ITEM*> optPad =
getItemById(
id );
807 if( !optPad || ( *optPad )->Type() !=
PCB_PAD_T )
810 response.add_pads()->set_value( padRequest.value() );
814 pad->TransformShapeToPolygon( poly,
pad->Padstack().EffectiveLayerFor( layer ), 0,
817 types::PolygonWithHoles* polyMsg = response.mutable_polygons()->Add();
828 using board::types::BoardLayer;
831 !documentValidation )
833 return tl::unexpected( documentValidation.error() );
836 PadstackPresenceResponse response;
840 for(
const int layer : aCtx.
Request.layers() )
843 for(
const types::KIID& padRequest : aCtx.
Request.items() )
845 KIID id( padRequest.value() );
846 std::optional<BOARD_ITEM*> optItem =
getItemById(
id );
851 switch( ( *optItem )->Type() )
855 PAD*
pad =
static_cast<PAD*
>( *optItem );
859 PadstackPresenceEntry* entry = response.add_entries();
860 entry->mutable_item()->set_value(
pad->m_Uuid.AsStdString() );
862 entry->set_presence(
pad->FlashLayer( layer ) ? PSP_PRESENT : PSP_NOT_PRESENT );
874 PadstackPresenceEntry* entry = response.add_entries();
875 entry->mutable_item()->set_value(
via->m_Uuid.AsStdString() );
877 entry->set_presence(
via->FlashLayer( layer ) ? PSP_PRESENT : PSP_NOT_PRESENT );
897 if( !documentValidation )
898 return tl::unexpected( documentValidation.error() );
900 ExpandTextVariablesResponse reply;
903 std::function<bool( wxString* )> textResolver =
904 [&]( wxString* token ) ->
bool
907 return board->ResolveTextVar( token, 0 );
910 for(
const std::string& textMsg : aCtx.
Request.text() )
913 reply.add_text(
text.ToUTF8() );
923 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"InteractiveMoveItems" ) )
924 return tl::unexpected( *headless );
926 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
927 return tl::unexpected( *busy );
931 if( !documentValidation )
932 return tl::unexpected( documentValidation.error() );
935 std::vector<EDA_ITEM*> toSelect;
937 for(
const kiapi::common::types::KIID&
id : aCtx.
Request.items() )
939 if( std::optional<BOARD_ITEM*> item =
getItemById(
KIID(
id.value() ) ) )
940 toSelect.emplace_back(
static_cast<EDA_ITEM*
>( *item ) );
943 if( toSelect.empty() )
946 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
947 e.set_error_message( fmt::format(
"None of the given items exist on the board",
948 aCtx.
Request.board().board_filename() ) );
949 return tl::unexpected( e );
970 if( !documentValidation )
971 return tl::unexpected( documentValidation.error() );
973 SavedDocumentResponse response;
974 response.mutable_document()->CopyFrom( aCtx.
Request.document() );
978 [&](
const wxString& aData )
980 response.set_contents( aData.ToUTF8() );
992 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"SaveSelectionToString" ) )
993 return tl::unexpected( *headless );
995 SavedSelectionResponse response;
1003 [&](
const wxString& aData )
1005 response.set_contents( aData.ToUTF8() );
1018 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
1019 return tl::unexpected( *busy );
1023 if( !documentValidation )
1024 return tl::unexpected( documentValidation.error() );
1026 CreateItemsResponse response;
1034 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"GetVisibleLayers" ) )
1035 return tl::unexpected( *headless );
1039 if( !documentValidation )
1040 return tl::unexpected( documentValidation.error() );
1042 BoardLayers response;
1054 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"SetVisibleLayers" ) )
1055 return tl::unexpected( *headless );
1057 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
1058 return tl::unexpected( *busy );
1062 if( !documentValidation )
1063 return tl::unexpected( documentValidation.error() );
1068 for(
int layerIdx : aCtx.
Request.layers() )
1074 visible.
set( layer );
1082 editFrame->Refresh();
1090 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"GetActiveLayer" ) )
1091 return tl::unexpected( *headless );
1095 if( !documentValidation )
1096 return tl::unexpected( documentValidation.error() );
1100 BoardLayerResponse response;
1111 if( std::optional<ApiResponseStatus> headless =
checkForHeadless(
"SetActiveLayer" ) )
1112 return tl::unexpected( *headless );
1114 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
1115 return tl::unexpected( *busy );
1119 if( !documentValidation )
1120 return tl::unexpected( documentValidation.error() );
1124 if( !
board()->GetEnabledLayers().Contains( layer ) )
1126 ApiResponseStatus err;
1127 err.set_status( ApiStatusCode::AS_BAD_REQUEST );
1128 err.set_error_message( fmt::format(
"Layer {} is not a valid layer for the given board",
1129 magic_enum::enum_name( layer ) ) );
1130 return tl::unexpected( err );
types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
tl::expected< T, ApiResponseStatus > HANDLER_RESULT
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
API_HANDLER_BOARD(std::shared_ptr< BOARD_CONTEXT > aContext, EDA_BASE_FRAME *aFrame=nullptr)
HANDLER_RESULT< commands::ExpandTextVariablesResponse > handleExpandTextVariables(const HANDLER_CONTEXT< commands::ExpandTextVariables > &aCtx)
HANDLER_RESULT< BoardEnabledLayersResponse > handleGetBoardEnabledLayers(const HANDLER_CONTEXT< GetBoardEnabledLayers > &aCtx)
std::unique_ptr< COMMIT > createCommit() override
Override this to create an appropriate COMMIT subclass for the frame in question.
HANDLER_RESULT< commands::SelectionResponse > handleGetSelection(const HANDLER_CONTEXT< commands::GetSelection > &aCtx)
HANDLER_RESULT< commands::SavedSelectionResponse > handleSaveSelectionToString(const HANDLER_CONTEXT< commands::SaveSelectionToString > &aCtx)
HANDLER_RESULT< Empty > handleSetActiveLayer(const HANDLER_CONTEXT< SetActiveLayer > &aCtx)
HANDLER_RESULT< BoardLayers > handleGetVisibleLayers(const HANDLER_CONTEXT< GetVisibleLayers > &aCtx)
TOOL_MANAGER * toolManager() const
HANDLER_RESULT< commands::SelectionResponse > handleAddToSelection(const HANDLER_CONTEXT< commands::AddToSelection > &aCtx)
HANDLER_RESULT< commands::CreateItemsResponse > handleParseAndCreateItemsFromString(const HANDLER_CONTEXT< commands::ParseAndCreateItemsFromString > &aCtx)
HANDLER_RESULT< Empty > handleClearSelection(const HANDLER_CONTEXT< commands::ClearSelection > &aCtx)
std::vector< KICAD_T > parseRequestedItemTypes(const google::protobuf::RepeatedField< int > &aTypes)
HANDLER_RESULT< Empty > handleInteractiveMoveItems(const HANDLER_CONTEXT< InteractiveMoveItems > &aCtx)
HANDLER_RESULT< types::ItemRequestStatus > handleCreateUpdateItemsInternal(bool aCreate, const std::string &aClientName, const types::ItemHeader &aHeader, const google::protobuf::RepeatedPtrField< google::protobuf::Any > &aItems, std::function< void(commands::ItemStatus, google::protobuf::Any)> aItemHandler) override
HANDLER_RESULT< BoardStackupResponse > handleGetStackup(const HANDLER_CONTEXT< GetBoardStackup > &aCtx)
void pushCurrentCommit(const std::string &aClientName, const wxString &aMessage) override
HANDLER_RESULT< commands::GetItemsResponse > handleGetItemsById(const HANDLER_CONTEXT< commands::GetItemsById > &aCtx)
std::optional< EDA_ITEM * > getItemFromDocument(const DocumentSpecifier &aDocument, const KIID &aId) override
void deleteItemsInternal(std::map< KIID, ItemDeletionStatus > &aItemsToDelete, const std::string &aClientName) override
HANDLER_RESULT< commands::SelectionResponse > handleRemoveFromSelection(const HANDLER_CONTEXT< commands::RemoveFromSelection > &aCtx)
HANDLER_RESULT< GraphicsDefaultsResponse > handleGetGraphicsDefaults(const HANDLER_CONTEXT< GetGraphicsDefaults > &aCtx)
HANDLER_RESULT< BoardLayerResponse > handleGetActiveLayer(const HANDLER_CONTEXT< GetActiveLayer > &aCtx)
HANDLER_RESULT< commands::GetBoundingBoxResponse > handleGetBoundingBox(const HANDLER_CONTEXT< commands::GetBoundingBox > &aCtx)
static HANDLER_RESULT< std::unique_ptr< BOARD_ITEM > > createItemForType(KICAD_T aType, BOARD_ITEM_CONTAINER *aContainer)
HANDLER_RESULT< commands::RunActionResponse > handleRunAction(const HANDLER_CONTEXT< commands::RunAction > &aCtx)
std::optional< ApiResponseStatus > checkForHeadless(const std::string &aCommandName) const
HANDLER_RESULT< commands::SavedDocumentResponse > handleSaveDocumentToString(const HANDLER_CONTEXT< commands::SaveDocumentToString > &aCtx)
HANDLER_RESULT< PadShapeAsPolygonResponse > handleGetPadShapeAsPolygon(const HANDLER_CONTEXT< GetPadShapeAsPolygon > &aCtx)
std::shared_ptr< BOARD_CONTEXT > m_context
HANDLER_RESULT< PadstackPresenceResponse > handleCheckPadstackPresenceOnLayers(const HANDLER_CONTEXT< CheckPadstackPresenceOnLayers > &aCtx)
virtual BOARD_ITEM_CONTAINER * getDefaultContainer()
HANDLER_RESULT< Empty > handleSetVisibleLayers(const HANDLER_CONTEXT< SetVisibleLayers > &aCtx)
std::optional< BOARD_ITEM * > getItemById(const KIID &aId) const
HANDLER_RESULT< bool > validateDocument(const DocumentSpecifier &aDocument)
HANDLER_RESULT< std::optional< KIID > > validateItemHeaderDocument(const kiapi::common::types::ItemHeader &aHeader)
If the header is valid, returns the item container.
API_HANDLER_EDITOR(EDA_BASE_FRAME *aFrame=nullptr)
COMMIT * getCurrentCommit(const std::string &aClientName)
virtual void pushCurrentCommit(const std::string &aClientName, const wxString &aMessage)
std::set< std::string > m_activeClients
virtual std::optional< ApiResponseStatus > checkForBusy()
Checks if the editor can accept commands.
void registerHandler(HANDLER_RESULT< ResponseType >(HandlerType::*aHandler)(const HANDLER_CONTEXT< RequestType > &))
Registers an API command handler for the given message types.
BASE_SET & reset(size_t pos)
BASE_SET & set(size_t pos)
Container for design settings for a BOARD object.
bool m_TextUpright[LAYER_CLASS_COUNT]
int m_TextThickness[LAYER_CLASS_COUNT]
int m_LineThickness[LAYER_CLASS_COUNT]
VECTOR2I m_TextSize[LAYER_CLASS_COUNT]
bool m_TextItalic[LAYER_CLASS_COUNT]
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual void CopyFrom(const BOARD_ITEM *aOther)
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Information pertinent to a Pcbnew printed circuit board.
BOARD_STACKUP GetStackupOrDefault() const
void SetVisibleLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
void SaveSelection(const PCB_SELECTION &selected, bool isFootprintEditor)
void SetWriter(std::function< void(const wxString &)> aWriter)
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
void SetBoard(BOARD *aBoard)
Represent a set of changes (additions, deletions or modifications) of a data model (e....
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
The base frame for deriving all KiCad main window classes.
The base class for create windows for drawing purpose.
void AddItem(EDA_ITEM *aItem)
Add item to group.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
virtual wxString GetFriendlyName() const
std::string AsStdString() const
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
static TOOL_ACTION move
move or drag an item
Common, abstract interface for edit frames.
APPEARANCE_CONTROLS * GetAppearancePanel()
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual PCB_LAYER_ID GetActiveLayer() const
void SyncLayersVisibility(const BOARD *aBoard)
Update "visibility" property of each layer of a given BOARD.
A set of BOARD_ITEMs (i.e., without duplicates).
void SetReferencePoint(const VECTOR2I &aP)
virtual void Serialize(google::protobuf::Any &aContainer) const
Serializes this object to the given Any message.
Represent a set of closed polygons.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
A type-safe container of any type.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
PCB_LAYER_ID
A quick note on layer IDs:
void PackLayerSet(google::protobuf::RepeatedField< int > &aOutput, const LSET &aLayerSet)
KICOMMON_API std::optional< KICAD_T > TypeNameFromAny(const google::protobuf::Any &aMessage)
KICOMMON_API void PackBox2(types::Box2 &aOutput, const BOX2I &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackPolyLine(types::PolyLine &aOutput, const SHAPE_LINE_CHAIN &aSlc, const EDA_IU_SCALE &aScale)
Class to handle a set of BOARD_ITEMs.
std::vector< EDA_ITEM * > EDA_ITEMS
RequestMessageType Request
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension