Browse Source

API: Add support for retrieving user names for all layers

9.0
Jon Evans 3 months ago
parent
commit
3514d130cb
  1. 14
      api/proto/board/board_commands.proto
  2. 20
      pcbnew/api/api_handler_pcb.cpp
  3. 3
      pcbnew/api/api_handler_pcb.h

14
api/proto/board/board_commands.proto

@ -115,6 +115,20 @@ message SetBoardOrigin
kiapi.common.types.Vector2 origin = 3;
}
message GetBoardLayerName
{
kiapi.common.types.DocumentSpecifier board = 1;
kiapi.board.types.BoardLayer layer = 2;
}
message BoardLayerNameResponse
{
// The name of the layer shown in the KiCad GUI, which may be a default value like "F.Cu" or may
// have been customized by the user.
string name = 1;
}
/*
* Net management
*/

20
pcbnew/api/api_handler_pcb.cpp

@ -90,6 +90,7 @@ API_HANDLER_PCB::API_HANDLER_PCB( PCB_EDIT_FRAME* aFrame ) :
&API_HANDLER_PCB::handleExpandTextVariables );
registerHandler<GetBoardOrigin, types::Vector2>( &API_HANDLER_PCB::handleGetBoardOrigin );
registerHandler<SetBoardOrigin, Empty>( &API_HANDLER_PCB::handleSetBoardOrigin );
registerHandler<GetBoardLayerName, BoardLayerNameResponse>( &API_HANDLER_PCB::handleGetBoardLayerName );
registerHandler<InteractiveMoveItems, Empty>( &API_HANDLER_PCB::handleInteractiveMoveItems );
registerHandler<GetNets, NetsResponse>( &API_HANDLER_PCB::handleGetNets );
@ -1099,6 +1100,25 @@ HANDLER_RESULT<Empty> API_HANDLER_PCB::handleSetBoardOrigin(
}
HANDLER_RESULT<BoardLayerNameResponse> API_HANDLER_PCB::handleGetBoardLayerName(
const HANDLER_CONTEXT<GetBoardLayerName>& aCtx )
{
if( HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
!documentValidation )
{
return tl::unexpected( documentValidation.error() );
}
BoardLayerNameResponse response;
PCB_LAYER_ID id = FromProtoEnum<PCB_LAYER_ID>( aCtx.Request.layer() );
response.set_name( frame()->GetBoard()->GetLayerName( id ) );
return response;
}
HANDLER_RESULT<GetBoundingBoxResponse> API_HANDLER_PCB::handleGetBoundingBox(
const HANDLER_CONTEXT<GetBoundingBox>& aCtx )
{

3
pcbnew/api/api_handler_pcb.h

@ -103,6 +103,9 @@ private:
HANDLER_RESULT<Empty> handleSetBoardOrigin( const HANDLER_CONTEXT<SetBoardOrigin>& aCtx );
HANDLER_RESULT<BoardLayerNameResponse> handleGetBoardLayerName(
const HANDLER_CONTEXT<GetBoardLayerName>& aCtx );
HANDLER_RESULT<commands::GetBoundingBoxResponse> handleGetBoundingBox(
const HANDLER_CONTEXT<commands::GetBoundingBox>& aCtx );

Loading…
Cancel
Save