21#include <magic_enum.hpp>
46#include <api/common/types/base_types.pb.h>
49using namespace kiapi::common::commands;
50using types::CommandStatus;
51using types::DocumentType;
52using types::ItemRequestStatus;
59 registerHandler<GetOpenDocuments, GetOpenDocumentsResponse>(
66 registerHandler<GetGraphicsDefaults, GraphicsDefaultsResponse>(
68 registerHandler<GetBoundingBox, GetBoundingBoxResponse>(
70 registerHandler<GetPadShapeAsPolygon, PadShapeAsPolygonResponse>(
72 registerHandler<GetTitleBlockInfo, types::TitleBlockInfo>(
74 registerHandler<ExpandTextVariables, ExpandTextVariablesResponse>(
81 registerHandler<SaveDocumentToString, SavedDocumentResponse>(
83 registerHandler<SaveSelectionToString, SavedSelectionResponse>(
85 registerHandler<ParseAndCreateItemsFromString, CreateItemsResponse>(
103 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
104 return tl::unexpected( *busy );
106 RunActionResponse response;
108 if(
frame()->GetToolManager()->RunAction( aRequest.action(),
true ) )
109 response.set_status( RunActionStatus::RAS_OK );
111 response.set_status( RunActionStatus::RAS_INVALID );
120 if( aMsg.type() != DocumentType::DOCTYPE_PCB )
124 e.set_status( ApiStatusCode::AS_UNHANDLED );
125 return tl::unexpected( e );
128 GetOpenDocumentsResponse response;
129 common::types::DocumentSpecifier doc;
131 wxFileName fn(
frame()->GetCurrentFileName() );
133 doc.set_type( DocumentType::DOCTYPE_PCB );
134 doc.set_board_filename( fn.GetFullName() );
136 doc.mutable_project()->set_name(
frame()->
Prj().GetProjectName().ToStdString() );
137 doc.mutable_project()->set_path(
frame()->
Prj().GetProjectDirectory().ToStdString() );
139 response.mutable_documents()->Add( std::move( doc ) );
153 return std::make_unique<BOARD_COMMIT>(
frame() );
170 if( aDocument.type() != DocumentType::DOCTYPE_PCB )
173 wxFileName fn(
frame()->GetCurrentFileName() );
174 return 0 == aDocument.board_filename().compare( fn.GetFullName() );
184 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
185 e.set_error_message(
"Tried to create an item in a null container" );
186 return tl::unexpected( e );
192 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
193 e.set_error_message( fmt::format(
"Tried to create a pad in {}, which is not a footprint",
195 return tl::unexpected( e );
200 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
201 e.set_error_message( fmt::format(
"Tried to create a footprint in {}, which is not a board",
203 return tl::unexpected( e );
211 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
212 e.set_error_message( fmt::format(
"Tried to create an item of type {}, which is unhandled",
213 magic_enum::enum_name( aType ) ) );
214 return tl::unexpected( e );
223 const types::ItemHeader &aHeader,
224 const google::protobuf::RepeatedPtrField<google::protobuf::Any>& aItems,
225 std::function<
void( ItemStatus, google::protobuf::Any )> aItemHandler )
231 if( !containerResult && containerResult.error().status() == ApiStatusCode::AS_UNHANDLED )
234 e.set_status( ApiStatusCode::AS_UNHANDLED );
235 return tl::unexpected( e );
237 else if( !containerResult )
239 e.CopyFrom( containerResult.error() );
240 return tl::unexpected( e );
246 if( containerResult->has_value() )
248 const KIID& containerId = **containerResult;
249 std::optional<BOARD_ITEM*> optItem =
getItemById( containerId );
257 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
258 e.set_error_message( fmt::format(
259 "The requested container {} is not a valid board item container",
261 return tl::unexpected( e );
266 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
267 e.set_error_message( fmt::format(
268 "The requested container {} does not exist in this document",
270 return tl::unexpected( e );
276 for(
const google::protobuf::Any& anyItem : aItems )
283 status.set_code( ItemStatusCode::ISC_INVALID_TYPE );
284 status.set_error_message( fmt::format(
"Could not decode a valid type from {}",
285 anyItem.type_url() ) );
286 aItemHandler( status, anyItem );
292 board::types::Dimension dimension;
293 anyItem.UnpackTo( &dimension );
295 switch( dimension.dimension_style_case() )
302 case board::types::Dimension::DIMENSION_STYLE_NOT_SET:
break;
309 if( !creationResult )
311 status.set_code( ItemStatusCode::ISC_INVALID_TYPE );
312 status.set_error_message( creationResult.error().error_message() );
313 aItemHandler( status, anyItem );
317 std::unique_ptr<BOARD_ITEM> item( std::move( *creationResult ) );
319 if( !item->Deserialize( anyItem ) )
321 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
322 e.set_error_message( fmt::format(
"could not unpack {} from request",
323 item->GetClass().ToStdString() ) );
324 return tl::unexpected( e );
327 std::optional<BOARD_ITEM*> optItem =
getItemById( item->m_Uuid );
329 if( aCreate && optItem )
331 status.set_code( ItemStatusCode::ISC_EXISTING );
332 status.set_error_message( fmt::format(
"an item with UUID {} already exists",
333 item->m_Uuid.AsStdString() ) );
334 aItemHandler( status, anyItem );
337 else if( !aCreate && !optItem )
339 status.set_code( ItemStatusCode::ISC_NONEXISTENT );
340 status.set_error_message( fmt::format(
"an item with UUID {} does not exist",
341 item->m_Uuid.AsStdString() ) );
342 aItemHandler( status, anyItem );
348 status.set_code( ItemStatusCode::ISC_INVALID_DATA );
349 status.set_error_message( fmt::format(
"attempted to add item on disabled layer {}",
350 LayerName( item->GetLayer() ).ToStdString() ) );
351 aItemHandler( status, anyItem );
355 status.set_code( ItemStatusCode::ISC_OK );
356 google::protobuf::Any newItem;
360 item->Serialize( newItem );
361 commit->
Add( item.release() );
366 commit->
Modify( boardItem );
371 aItemHandler( status, newItem );
377 :
_(
"Added items via API" ) );
381 return ItemRequestStatus::IRS_OK;
388 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
389 return tl::unexpected( *busy );
395 e.set_status( ApiStatusCode::AS_UNHANDLED );
396 return tl::unexpected( e );
399 GetItemsResponse response;
402 std::vector<BOARD_ITEM*> items;
403 std::set<KICAD_T> typesRequested, typesInserted;
404 bool handledAnything =
false;
406 for(
int typeRaw : aMsg.types() )
408 auto typeMessage =
static_cast<common::types::KiCadObjectType
>( typeRaw );
409 KICAD_T type = FromProtoEnum<KICAD_T>( typeMessage );
414 typesRequested.emplace( type );
416 if( typesInserted.count( type ) )
424 handledAnything =
true;
425 std::copy( board->
Tracks().begin(), board->
Tracks().end(),
426 std::back_inserter( items ) );
432 handledAnything =
true;
436 std::copy( fp->Pads().begin(), fp->Pads().end(),
437 std::back_inserter( items ) );
446 handledAnything =
true;
449 std::back_inserter( items ) );
459 handledAnything =
true;
460 bool inserted =
false;
464 if( item->Type() == type )
466 items.emplace_back( item );
479 handledAnything =
true;
481 std::copy( board->
Zones().begin(), board->
Zones().end(),
482 std::back_inserter( items ) );
493 if( !handledAnything )
496 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
497 e.set_error_message(
"none of the requested types are valid for a Board object" );
498 return tl::unexpected( e );
503 if( !typesRequested.count( item->Type() ) )
506 google::protobuf::Any itemBuf;
507 item->Serialize( itemBuf );
508 response.mutable_items()->Add( std::move( itemBuf ) );
511 response.set_status( ItemRequestStatus::IRS_OK );
520 std::vector<BOARD_ITEM*> validatedItems;
522 for( std::pair<const KIID, ItemDeletionStatus> pair : aItemsToDelete )
526 validatedItems.push_back( item );
527 aItemsToDelete[pair.first] = ItemDeletionStatus::IDS_OK;
557 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
558 return tl::unexpected( *busy );
562 if( !documentValidation )
563 return tl::unexpected( documentValidation.error() );
565 BoardStackupResponse response;
566 google::protobuf::Any any;
570 any.UnpackTo( response.mutable_stackup() );
577 GetGraphicsDefaults& aMsg,
580 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
581 return tl::unexpected( *busy );
585 if( !documentValidation )
586 return tl::unexpected( documentValidation.error() );
589 GraphicsDefaultsResponse response;
592 constexpr std::array<kiapi::board::BoardLayerClass, LAYER_CLASS_COUNT> classOrder = {
593 kiapi::board::BLC_SILKSCREEN,
594 kiapi::board::BLC_COPPER,
595 kiapi::board::BLC_EDGES,
596 kiapi::board::BLC_COURTYARD,
597 kiapi::board::BLC_FABRICATION,
598 kiapi::board::BLC_OTHER
603 kiapi::board::BoardLayerGraphicsDefaults* l = response.mutable_defaults()->add_layers();
605 l->set_layer( classOrder[i] );
608 kiapi::common::types::TextAttributes*
text = l->mutable_text();
623 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
624 return tl::unexpected( *busy );
630 e.set_status( ApiStatusCode::AS_UNHANDLED );
631 return tl::unexpected( e );
634 GetBoundingBoxResponse response;
635 bool includeText = aMsg.mode() == BoundingBoxMode::BBM_ITEM_AND_CHILD_TEXT;
637 for(
const types::KIID& idMsg : aMsg.items() )
639 KIID id( idMsg.value() );
640 std::optional<BOARD_ITEM*> optItem =
getItemById(
id );
649 bbox =
static_cast<FOOTPRINT*
>( item )->GetBoundingBox( includeText );
653 response.add_items()->set_value( idMsg.value() );
654 PackBox2( *response.add_boxes(), bbox );
662 GetPadShapeAsPolygon& aMsg,
667 if( !documentValidation )
668 return tl::unexpected( documentValidation.error() );
671 PadShapeAsPolygonResponse response;
672 PCB_LAYER_ID layer = FromProtoEnum<PCB_LAYER_ID, board::types::BoardLayer>( aMsg.layer() );
674 for(
const types::KIID& padRequest : aMsg.pads() )
676 KIID id( padRequest.value() );
677 std::optional<BOARD_ITEM*> optPad =
getItemById(
id );
679 if( !optPad || ( *optPad )->Type() !=
PCB_PAD_T )
682 response.add_pads()->set_value( padRequest.value() );
685 pad->TransformShapeToPolygon( poly,
pad->Padstack().EffectiveLayerFor( layer ), 0,
688 types::PolygonWithHoles* polyMsg = response.mutable_polygons()->Add();
697 GetTitleBlockInfo& aMsg,
702 if( !documentValidation )
703 return tl::unexpected( documentValidation.error() );
708 types::TitleBlockInfo response;
710 response.set_title( block.
GetTitle().ToUTF8() );
711 response.set_date( block.
GetDate().ToUTF8() );
712 response.set_revision( block.
GetRevision().ToUTF8() );
713 response.set_company( block.
GetCompany().ToUTF8() );
714 response.set_comment1( block.
GetComment( 0 ).ToUTF8() );
715 response.set_comment2( block.
GetComment( 1 ).ToUTF8() );
716 response.set_comment3( block.
GetComment( 2 ).ToUTF8() );
717 response.set_comment4( block.
GetComment( 3 ).ToUTF8() );
718 response.set_comment5( block.
GetComment( 4 ).ToUTF8() );
719 response.set_comment6( block.
GetComment( 5 ).ToUTF8() );
720 response.set_comment7( block.
GetComment( 6 ).ToUTF8() );
721 response.set_comment8( block.
GetComment( 7 ).ToUTF8() );
722 response.set_comment9( block.
GetComment( 8 ).ToUTF8() );
733 if( !documentValidation )
734 return tl::unexpected( documentValidation.error() );
736 ExpandTextVariablesResponse reply;
739 std::function<bool( wxString* )> textResolver =
740 [&]( wxString* token ) ->
bool
746 for(
const std::string& textMsg : aMsg.text() )
749 reply.add_text(
text.ToUTF8() );
759 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
760 return tl::unexpected( *busy );
764 if( !documentValidation )
765 return tl::unexpected( documentValidation.error() );
768 std::vector<EDA_ITEM*> toSelect;
770 for(
const kiapi::common::types::KIID&
id : aMsg.items() )
772 if( std::optional<BOARD_ITEM*> item =
getItemById(
KIID(
id.value() ) ) )
773 toSelect.emplace_back(
static_cast<EDA_ITEM*
>( *item ) );
776 if( toSelect.empty() )
779 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
780 e.set_error_message( fmt::format(
"None of the given items exist on the board",
781 aMsg.board().board_filename() ) );
782 return tl::unexpected( e );
801 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
802 return tl::unexpected( *busy );
806 if( !documentValidation )
807 return tl::unexpected( documentValidation.error() );
809 NetsResponse response;
812 std::set<wxString> netclassFilter;
814 for(
const std::string& nc : aMsg.netclass_filter() )
815 netclassFilter.insert( wxString( nc.c_str(), wxConvUTF8 ) );
821 if( !netclassFilter.empty() && nc && !netclassFilter.count( nc->
GetName() ) )
824 board::types::Net* netProto = response.add_nets();
825 netProto->set_name( net->GetNetname() );
826 netProto->mutable_code()->set_value( net->GetNetCode() );
836 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
837 return tl::unexpected( *busy );
841 if( !documentValidation )
842 return tl::unexpected( documentValidation.error() );
844 if( aMsg.zones().empty() )
847 frame()->CallAfter( [mgr]()
856 e.set_status( ApiStatusCode::AS_UNIMPLEMENTED );
857 return tl::unexpected( e );
869 if( !documentValidation )
870 return tl::unexpected( documentValidation.error() );
872 SavedDocumentResponse response;
873 response.mutable_document()->CopyFrom( aMsg.document() );
877 [&](
const wxString& aData )
879 response.set_contents( aData.ToUTF8() );
891 SavedSelectionResponse response;
899 [&](
const wxString& aData )
901 response.set_contents( aData.ToUTF8() );
914 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
915 return tl::unexpected( *busy );
919 if( !documentValidation )
920 return tl::unexpected( documentValidation.error() );
922 CreateItemsResponse response;
932 if( !documentValidation )
933 return tl::unexpected( documentValidation.error() );
935 BoardLayers response;
938 response.add_layers( ToProtoEnum<PCB_LAYER_ID, board::types::BoardLayer>( layer ) );
947 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
948 return tl::unexpected( *busy );
952 if( !documentValidation )
953 return tl::unexpected( documentValidation.error() );
958 for(
int layerIdx : aMsg.layers() )
961 FromProtoEnum<PCB_LAYER_ID>(
static_cast<board::types::BoardLayer
>( layerIdx ) );
964 visible.
set( layer );
980 if( !documentValidation )
981 return tl::unexpected( documentValidation.error() );
983 BoardLayerResponse response;
985 ToProtoEnum<PCB_LAYER_ID, board::types::BoardLayer>(
frame()->GetActiveLayer() ) );
994 if( std::optional<ApiResponseStatus> busy =
checkForBusy() )
995 return tl::unexpected( *busy );
999 if( !documentValidation )
1000 return tl::unexpected( documentValidation.error() );
1002 PCB_LAYER_ID layer = FromProtoEnum<PCB_LAYER_ID>( aMsg.layer() );
1004 if( !
frame()->
GetBoard()->GetEnabledLayers().Contains( layer ) )
1006 ApiResponseStatus err;
1007 err.set_status( ApiStatusCode::AS_BAD_REQUEST );
1008 err.set_error_message( fmt::format(
"Layer {} is not a valid layer for the given board",
1009 magic_enum::enum_name( layer ) ) );
1010 return tl::unexpected( err );
tl::expected< T, ApiResponseStatus > HANDLER_RESULT
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
constexpr int ARC_HIGH_DEF
Base class for API handlers related to editor frames.
virtual void pushCurrentCommit(const HANDLER_CONTEXT &aCtx, const wxString &aMessage)
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.
COMMIT * getCurrentCommit(const HANDLER_CONTEXT &aCtx)
std::set< std::string > m_activeClients
virtual std::optional< ApiResponseStatus > checkForBusy()
Checks if the editor can accept commands.
HANDLER_RESULT< commands::GetItemsResponse > handleGetItems(commands::GetItems &aMsg, const HANDLER_CONTEXT &aCtx)
bool validateDocumentInternal(const DocumentSpecifier &aDocument) const override
HANDLER_RESULT< BoardLayerResponse > handleGetActiveLayer(GetActiveLayer &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< types::TitleBlockInfo > handleGetTitleBlockInfo(commands::GetTitleBlockInfo &aMsg, const HANDLER_CONTEXT &aCtx)
API_HANDLER_PCB(PCB_EDIT_FRAME *aFrame)
static HANDLER_RESULT< std::unique_ptr< BOARD_ITEM > > createItemForType(KICAD_T aType, BOARD_ITEM_CONTAINER *aContainer)
std::optional< BOARD_ITEM * > getItemById(const KIID &aId) const
std::unique_ptr< COMMIT > createCommit() override
Override this to create an appropriate COMMIT subclass for the frame in question.
HANDLER_RESULT< Empty > handleInteractiveMoveItems(InteractiveMoveItems &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< BoardStackupResponse > handleGetStackup(GetBoardStackup &aMsg, const HANDLER_CONTEXT &aCtx)
void deleteItemsInternal(std::map< KIID, ItemDeletionStatus > &aItemsToDelete, const HANDLER_CONTEXT &aCtx) override
std::optional< EDA_ITEM * > getItemFromDocument(const DocumentSpecifier &aDocument, const KIID &aId) override
HANDLER_RESULT< commands::CreateItemsResponse > handleParseAndCreateItemsFromString(commands::ParseAndCreateItemsFromString &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< commands::RunActionResponse > handleRunAction(commands::RunAction &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< BoardLayers > handleGetVisibleLayers(GetVisibleLayers &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< commands::SavedSelectionResponse > handleSaveSelectionToString(commands::SaveSelectionToString &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< Empty > handleSetActiveLayer(SetActiveLayer &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< commands::GetBoundingBoxResponse > handleGetBoundingBox(commands::GetBoundingBox &aMsg, const HANDLER_CONTEXT &aCtx)
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
HANDLER_RESULT< Empty > handleRefillZones(RefillZones &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< GraphicsDefaultsResponse > handleGetGraphicsDefaults(GetGraphicsDefaults &aMsg, const HANDLER_CONTEXT &aCtx)
void pushCurrentCommit(const HANDLER_CONTEXT &aCtx, const wxString &aMessage) override
HANDLER_RESULT< commands::GetOpenDocumentsResponse > handleGetOpenDocuments(commands::GetOpenDocuments &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< Empty > handleSetVisibleLayers(SetVisibleLayers &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< commands::ExpandTextVariablesResponse > handleExpandTextVariables(commands::ExpandTextVariables &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< PadShapeAsPolygonResponse > handleGetPadShapeAsPolygon(GetPadShapeAsPolygon &aMsg, const HANDLER_CONTEXT &aCtx)
PCB_EDIT_FRAME * frame() const
HANDLER_RESULT< commands::SavedDocumentResponse > handleSaveDocumentToString(commands::SaveDocumentToString &aMsg, const HANDLER_CONTEXT &aCtx)
HANDLER_RESULT< NetsResponse > handleGetNets(GetNets &aMsg, const HANDLER_CONTEXT &aCtx)
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...
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
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
const NETINFO_LIST & GetNetInfo() const
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
BOARD_ITEM * GetItem(const KIID &aID) const
const ZONES & Zones() const
bool ResolveTextVar(wxString *token, int aDepth) const
TITLE_BLOCK & GetTitleBlock()
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
void SetVisibleLayers(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 DRAWINGS & Drawings() 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)
Notify observers that aItem has been removed.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
static DELETED_BOARD_ITEM * GetInstance()
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.
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.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
A collection of nets and the parameters used to route or test these nets.
const wxString GetName() const
Gets the consolidated name of this netclass (which may be an aggregate)
Handle the data for a net.
static TOOL_ACTION zoneFillAll
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION move
move or drag an item
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
APPEARANCE_CONTROLS * GetAppearancePanel()
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SyncLayersVisibility(const BOARD *aBoard)
Update "visibility" property of each layer of a given BOARD.
The main frame for Pcbnew.
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
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
Hold the information shown in the lower right corner of a plot, printout, or editing view.
const wxString & GetCompany() const
const wxString & GetRevision() const
const wxString & GetDate() const
const wxString & GetComment(int aIdx) const
const wxString & GetTitle() const
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
PCB_LAYER_ID
A quick note on layer IDs:
KICOMMON_API void PackBox2(types::Box2 &aOutput, const BOX2I &aInput)
KICOMMON_API std::optional< KICAD_T > TypeNameFromAny(const google::protobuf::Any &aMessage)
KICOMMON_API void PackPolyLine(types::PolyLine &aOutput, const SHAPE_LINE_CHAIN &aSlc)
Class to handle a set of BOARD_ITEMs.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ 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_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ 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_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension