KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_handler_board.cpp
Go to the documentation of this file.
1
2/*
3 * This program source code file is part of KiCad, a free EDA CAD application.
4 *
5 * Copyright (C) 2023 Jon Evans <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <set>
23#include <fmt/ranges.h>
24#include <magic_enum.hpp>
25
26#include <common.h>
28#include <api/api_pcb_utils.h>
29#include <api/api_enums.h>
30#include <api/api_utils.h>
31#include <board_commit.h>
33#include <footprint.h>
34#include <kicad_clipboard.h>
35#include <pad.h>
36#include <pcb_base_edit_frame.h>
37#include <pcb_field.h>
38#include <pcb_group.h>
40#include <pcb_track.h>
42#include <pcb_generated_table.h>
43#include <pcb_table.h>
44#include <pcb_tablecell.h>
45#include <pcb_3d_body.h>
46
47#include <layer_ids.h>
48#include <project.h>
49#include <tool/common_tools.h>
50#include <tool/tool_manager.h>
51#include <tools/pcb_actions.h>
54
55#include <api/common/types/base_types.pb.h>
56
57using namespace kiapi::common::commands;
58using types::CommandStatus;
59
60using types::DocumentType;
61using types::ItemRequestStatus;
62
63
64API_HANDLER_BOARD::API_HANDLER_BOARD( std::shared_ptr<BOARD_CONTEXT> aContext,
65 EDA_BASE_FRAME* aFrame ) :
66 API_HANDLER_EDITOR( aFrame ),
67 m_context( std::move( aContext ) )
68{
69 wxCHECK( m_context, /* void */ );
70
72
74
81
96
99
110}
111
112
113std::optional<ApiResponseStatus> API_HANDLER_BOARD::checkForHeadless(
114 const std::string& aCommandName ) const
115{
116 if( m_frame )
117 return std::nullopt;
118
119 ApiResponseStatus e;
120 e.set_status( ApiStatusCode::AS_UNIMPLEMENTED );
121 e.set_error_message( fmt::format( "{} is not available in headless mode", aCommandName ) );
122 return e;
123}
124
125
130
131
132void API_HANDLER_BOARD::pushCurrentCommit( const std::string& aClientName,
133 const wxString& aMessage )
134{
135 // A request whose every item was refused leaves an empty commit, which must not dirty the board
136 auto it = m_commits.find( aClientName );
137 const bool changed = it != m_commits.end() && !it->second.second->Empty();
138
139 API_HANDLER_EDITOR::pushCurrentCommit( aClientName, aMessage );
140
141 if( changed )
142 onModified();
143}
144
145
146std::unique_ptr<COMMIT> API_HANDLER_BOARD::createCommit()
147{
148 if( m_frame )
149 return std::make_unique<BOARD_COMMIT>( static_cast<EDA_DRAW_FRAME*>( m_frame ) );
150
151 bool isFootprintEditor = thisDocumentType() == kiapi::common::types::DOCTYPE_FOOTPRINT;
152
153 return std::make_unique<BOARD_COMMIT>( toolManager(), !isFootprintEditor, isFootprintEditor );
154}
155
156
157std::optional<BOARD_ITEM*> API_HANDLER_BOARD::getItemById( const KIID& aId ) const
158{
159 BOARD_ITEM* item = board()->ResolveItem( aId, true );
160
161 if( !item )
162 return std::nullopt;
163
164 return item;
165}
166
167
169 BOARD_ITEM_CONTAINER* aContainer )
170{
171 if( !aContainer )
172 {
173 ApiResponseStatus e;
174 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
175 e.set_error_message( "Tried to create an item in a null container" );
176 return tl::unexpected( e );
177 }
178
179 if( aType == PCB_PAD_T && !dynamic_cast<FOOTPRINT*>( aContainer ) )
180 {
181 ApiResponseStatus e;
182 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
183 e.set_error_message( fmt::format( "Tried to create a pad in {}, which is not a footprint",
184 aContainer->GetFriendlyName().ToStdString() ) );
185 return tl::unexpected( e );
186 }
187 else if( aType == PCB_FOOTPRINT_T && !dynamic_cast<BOARD*>( aContainer ) )
188 {
189 ApiResponseStatus e;
190 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
191 e.set_error_message( fmt::format( "Tried to create a footprint in {}, which is not a board",
192 aContainer->GetFriendlyName().ToStdString() ) );
193 return tl::unexpected( e );
194 }
195
196 if( dynamic_cast<FOOTPRINT*>( aContainer ) )
197 {
198 static const std::set<KICAD_T> s_footprintItemTypes = {
203 };
204
205 if( !s_footprintItemTypes.contains( aType ) )
206 {
207 ApiResponseStatus e;
208 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
209 e.set_error_message( fmt::format( "items of type {} cannot be created in a footprint",
210 magic_enum::enum_name( aType ) ) );
211 return tl::unexpected( e );
212 }
213 }
214
215 std::unique_ptr<BOARD_ITEM> created = CreateItemForType( aType, aContainer );
216
217 if( !created )
218 {
219 ApiResponseStatus e;
220 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
221 e.set_error_message( fmt::format( "Tried to create an item of type {}, which is unhandled",
222 magic_enum::enum_name( aType ) ) );
223 return tl::unexpected( e );
224 }
225
226 return created;
227}
228
229
230void API_HANDLER_BOARD::deleteItemsInternal( std::map<KIID, ItemDeletionStatus>& aItemsToDelete,
231 const std::string& aClientName )
232{
233 BOARD* board = this->board();
234 std::vector<BOARD_ITEM*> validatedItems;
235
236 for( std::pair<const KIID, ItemDeletionStatus> pair : aItemsToDelete )
237 {
238 if( BOARD_ITEM* item = board->ResolveItem( pair.first, true ) )
239 {
240 // A footprint without its mandatory fields is not a state the editor can load or
241 // render; the const field accessors return nullptr and callers dereference them
242 if( item->Type() == PCB_FIELD_T && static_cast<PCB_FIELD*>( item )->IsMandatory() )
243 {
244 aItemsToDelete[pair.first] = ItemDeletionStatus::IDS_IMMUTABLE;
245 continue;
246 }
247
248 // A generated table writes its own cells, so there is nothing a client could clear
249 if( IsGeneratedTableCell( item ) )
250 {
251 aItemsToDelete[pair.first] = ItemDeletionStatus::IDS_IMMUTABLE;
252 continue;
253 }
254
255 validatedItems.push_back( item );
256 aItemsToDelete[pair.first] = ItemDeletionStatus::IDS_OK;
257 }
258
259 // Note: we don't currently support locking items from API modification, but here is where
260 // to add it in the future (and return IDS_IMMUTABLE)
261 }
262
263 COMMIT* commit = getCurrentCommit( aClientName );
264
265 for( BOARD_ITEM* item : validatedItems )
266 {
267 if( item->Type() == PCB_TABLECELL_T )
268 {
269 // Cells are owned by their table; the commit removal path doesn't handle them.
270 // Match the GUI delete: clear the cell contents.
271 commit->Modify( item );
272 static_cast<PCB_TABLECELL*>( item )->SetText( wxEmptyString );
273 }
274 else if( item->Type() == PCB_GENERATOR_T )
275 {
276 TOOL_MANAGER* mgr = toolManager();
277
278 if( ensureGeneratorTool() )
279 {
281 static_cast<PCB_GENERATOR*>( item ) );
282 }
283 else
284 {
285 commit->Remove( item );
286 }
287 }
288 else
289 {
290 commit->Remove( item );
291 }
292 }
293
294 if( !m_activeClients.count( aClientName ) )
295 pushCurrentCommit( aClientName, _( "Deleted items via API" ) );
296}
297
298
300{
301 TOOL_MANAGER* mgr = toolManager();
302
303 if( !mgr->FindTool( GENERATOR_TOOL_NAME ) )
304 {
305 mgr->RegisterTool( new GENERATOR_TOOL );
307 }
308
309 return mgr->GetTool<GENERATOR_TOOL>();
310}
311
312
314 const std::vector<PCB_GENERATOR*>& aGenerators,
315 std::function<void( const KIID&, ItemStatus )> aResultHandler ) const
316{
317 BOARD* board = this->board();
318
319 for( PCB_GENERATOR* generator : aGenerators )
320 {
321 ItemStatus status;
322
323 try
324 {
325 generator->EditStart( aTool, board, aCommit );
326 bool ok = generator->Update( aTool, board, aCommit );
327 generator->EditFinish( aTool, board, aCommit );
328
329 status.set_code( ok ? ItemStatusCode::ISC_OK : ItemStatusCode::ISC_INVALID_DATA );
330
331 if( !ok )
332 status.set_error_message( "the generator reported an update failure" );
333 }
334 catch( const std::exception& exc )
335 {
336 status.set_code( ItemStatusCode::ISC_INVALID_DATA );
337 status.set_error_message( fmt::format( "regeneration exception: {}", exc.what() ) );
338 }
339
340 if( aResultHandler )
341 aResultHandler( generator->m_Uuid, status );
342 }
343}
344
345
347 const DocumentSpecifier& aDocument, const KIID& aId )
348{
349 if( !validateDocument( aDocument ) )
350 return std::nullopt;
351
352 return getItemById( aId );
353}
354
355
357 const std::string& aClientName,
358 const types::ItemHeader &aHeader,
359 const google::protobuf::RepeatedPtrField<google::protobuf::Any>& aItems,
360 std::function<void( ItemStatus, google::protobuf::Any )> aItemHandler )
361{
362 ApiResponseStatus e;
363
364 auto containerResult = validateItemHeaderDocument( aHeader );
365
366 if( !containerResult && containerResult.error().status() == ApiStatusCode::AS_UNHANDLED )
367 {
368 // No message needed for AS_UNHANDLED; this is an internal flag for the API server
369 e.set_status( ApiStatusCode::AS_UNHANDLED );
370 return tl::unexpected( e );
371 }
372 else if( !containerResult )
373 {
374 e.CopyFrom( containerResult.error() );
375 return tl::unexpected( e );
376 }
377
378 BOARD* board = this->board();
380
381 if( containerResult->has_value() )
382 {
383 const KIID& containerId = **containerResult;
384 std::optional<BOARD_ITEM*> optItem = getItemById( containerId );
385
386 if( optItem )
387 {
388 container = dynamic_cast<BOARD_ITEM_CONTAINER*>( *optItem );
389
390 if( !container )
391 {
392 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
393 e.set_error_message( fmt::format( "The requested container {} is not a valid board item container",
394 containerId.AsStdString() ) );
395 return tl::unexpected( e );
396 }
397 }
398 else
399 {
400 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
401 e.set_error_message( fmt::format( "The requested container {} does not exist in this document",
402 containerId.AsStdString() ) );
403 return tl::unexpected( e );
404 }
405 }
406
407 BOARD_COMMIT* commit = static_cast<BOARD_COMMIT*>( getCurrentCommit( aClientName ) );
408 int commitCheckpoint = commit->Checkpoint();
409
410 for( const google::protobuf::Any& anyItem : aItems )
411 {
412 ItemStatus status;
413 std::optional<KICAD_T> type = TypeNameFromAny( anyItem );
414
415 if( !type )
416 {
417 status.set_code( ItemStatusCode::ISC_INVALID_TYPE );
418 status.set_error_message( fmt::format( "Could not decode a valid type from {}", anyItem.type_url() ) );
419 aItemHandler( status, anyItem );
420 continue;
421 }
422
423 if( type == PCB_DIMENSION_T )
424 {
425 board::types::Dimension dimension;
426
427 if( !anyItem.UnpackTo( &dimension ) )
428 {
429 status.set_code( ItemStatusCode::ISC_INVALID_TYPE );
430 status.set_error_message( "Failed to unpack dimension" );
431 aItemHandler( status, anyItem );
432 continue;
433 }
434
435 switch( dimension.dimension_style_case() )
436 {
437 case board::types::Dimension::kAligned: type = PCB_DIM_ALIGNED_T; break;
438 case board::types::Dimension::kOrthogonal: type = PCB_DIM_ORTHOGONAL_T; break;
439 case board::types::Dimension::kRadial: type = PCB_DIM_RADIAL_T; break;
440 case board::types::Dimension::kLeader: type = PCB_DIM_LEADER_T; break;
441 case board::types::Dimension::kCenter: type = PCB_DIM_CENTER_T; break;
442 case board::types::Dimension::DIMENSION_STYLE_NOT_SET: break;
443 }
444 }
445
446 if( *type == PCB_SHAPE_T )
447 {
448 board::types::BoardGraphicShape shape;
449
450 if(! anyItem.UnpackTo( &shape ) )
451 {
452 status.set_code( ItemStatusCode::ISC_INVALID_TYPE );
453 status.set_error_message( "Failed to unpack shape" );
454 aItemHandler( status, anyItem );
455 continue;
456 }
457
458 if( shape.has_pad_custom_shape_options() )
459 {
460 status.set_code( ItemStatusCode::ISC_INVALID_DATA );
461 status.set_error_message( "pad_custom_shape_options are only valid on shapes inside a pad's "
462 "padstack custom shapes" );
463 aItemHandler( status, anyItem );
464 continue;
465 }
466 }
467
469 [&]() -> HANDLER_RESULT<std::unique_ptr<BOARD_ITEM>>
470 {
471 if( *type == PCB_GENERATOR_T )
472 {
473 std::optional<wxString> generatorType = GeneratorTypeFromAny( anyItem );
474
475 if( !generatorType )
476 {
477 ItemStatus genStatus;
478 genStatus.set_code( ItemStatusCode::ISC_INVALID_TYPE );
479 genStatus.set_error_message( fmt::format( "could not decode a generator from {}",
480 anyItem.type_url() ) );
481 aItemHandler( genStatus, anyItem );
482 return HANDLER_RESULT<std::unique_ptr<BOARD_ITEM>>( std::unique_ptr<BOARD_ITEM>() );
483 }
484
485 std::unique_ptr<BOARD_ITEM> genItem = CreateGeneratorForType( *generatorType, container );
486
487 if( !genItem )
488 {
489 ItemStatus genStatus;
490 genStatus.set_code( ItemStatusCode::ISC_INVALID_TYPE );
491 genStatus.set_error_message( fmt::format( "generator type {} is not registered",
492 generatorType->ToStdString() ) );
493 aItemHandler( genStatus, anyItem );
494 return HANDLER_RESULT<std::unique_ptr<BOARD_ITEM>>( std::unique_ptr<BOARD_ITEM>() );
495 }
496
497 return HANDLER_RESULT<std::unique_ptr<BOARD_ITEM>>( std::move( genItem ) );
498 }
499
500 return createItemForType( *type, container );
501 }();
502
503 if( !creationResult || !creationResult.value() )
504 {
505 if( !creationResult )
506 {
507 status.set_code( ItemStatusCode::ISC_INVALID_TYPE );
508 status.set_error_message( creationResult.error().error_message() );
509 aItemHandler( status, anyItem );
510 }
511
512 continue;
513 }
514
515 std::unique_ptr<BOARD_ITEM> item( std::move( *creationResult ) );
516
517 bool unpacked = false;
518
519 if( item->Type() == PCB_GENERATOR_T )
520 unpacked = item->Deserialize( anyItem );
521 else if( PCB_GROUP* group = dynamic_cast<PCB_GROUP*>( item.get() ) )
522 unpacked = group->DeserializeGroup( anyItem, commit );
523 else
524 unpacked = item->Deserialize( anyItem );
525
526 if( !unpacked )
527 {
528 commit->RevertToCheckpoint( commitCheckpoint );
529
530 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
531 e.set_error_message( fmt::format( "could not unpack {} from request",
532 item->GetClass().ToStdString() ) );
533 return tl::unexpected( e );
534 }
535
536 // The message's cells were written under its old metadata, so they must be regenerated to match the new.
537 // An update only carries settings, which are applied to the live table below
538 if( aCreate && IsGeneratedTableType( item->Type() ) )
539 static_cast<PCB_GENERATED_TABLE*>( item.get() )->RebuildCells( *board );
540
541 if( std::vector<wxString> removed = item->RemoveConflictingCustomProperties(); !removed.empty() )
542 {
543 auto as_str =
544 []( const wxString& aIn )
545 {
546 return std::string( aIn.ToUTF8() );
547 };
548
549 status.set_code( ItemStatusCode::ISC_INVALID_DATA );
550 status.set_error_message( fmt::format( "Invalid custom properties for item {}: property name(s) '{}' "
551 "already in use",
552 item->m_Uuid.AsStdString(),
553 fmt::join( std::views::transform( removed, as_str ), ", " ) ) );
554
555 aItemHandler( status, anyItem );
556 continue;
557 }
558
559 std::optional<BOARD_ITEM*> optItem = getItemById( item->m_Uuid );
560
561 if( aCreate && optItem )
562 {
563 status.set_code( ItemStatusCode::ISC_EXISTING );
564 status.set_error_message( fmt::format( "an item with UUID {} already exists",
565 item->m_Uuid.AsStdString() ) );
566 aItemHandler( status, anyItem );
567 continue;
568 }
569 else if( !aCreate && !optItem )
570 {
571 status.set_code( ItemStatusCode::ISC_NONEXISTENT );
572 status.set_error_message( fmt::format( "an item with UUID {} does not exist",
573 item->m_Uuid.AsStdString() ) );
574 aItemHandler( status, anyItem );
575 continue;
576 }
577
578 if( !aCreate && ( *optItem )->Type() != item->Type() )
579 {
580 status.set_code( ItemStatusCode::ISC_INVALID_TYPE );
581 status.set_error_message( fmt::format( "item {} is of type {}, not {}",
582 item->m_Uuid.AsStdString(),
583 magic_enum::enum_name( ( *optItem )->Type() ),
584 magic_enum::enum_name( item->Type() ) ) );
585 aItemHandler( status, anyItem );
586 continue;
587 }
588
589 // A generated table rewrites its cells from the board, and a new cell would be a row with no key
590 if( item->Type() == PCB_TABLECELL_T
591 && ( aCreate ? IsGeneratedTableType( container->Type() ) : IsGeneratedTableCell( *optItem ) ) )
592 {
593 status.set_code( ItemStatusCode::ISC_IMMUTABLE );
594 status.set_error_message( fmt::format( "cells of generated table {} cannot be modified",
595 ( aCreate ? container->m_Uuid : ( *optItem )->GetParent()->m_Uuid )
596 .AsStdString() ) );
597 aItemHandler( status, anyItem );
598 continue;
599 }
600
601 if( aCreate
602 && !item->FitsEnabledLayers( board->GetEnabledLayers(), board->GetCopperLayerCount() ) )
603 {
604 status.set_code( ItemStatusCode::ISC_INVALID_DATA );
605 status.set_error_message( "attempted to add item with no overlapping layers with the board" );
606 aItemHandler( status, anyItem );
607 continue;
608 }
609
610 status.set_code( ItemStatusCode::ISC_OK );
611 google::protobuf::Any newItem;
612
613 if( item->Type() == PCB_GROUP_T )
614 static_cast<PCB_GROUP*>( item.get() )->FinalizeGroupDeserialization();
615
616 if( aCreate )
617 {
618 if( item->Type() == PCB_TABLECELL_T )
619 {
620 PCB_TABLE* table = dynamic_cast<PCB_TABLE*>( container );
621
622 if( !table )
623 {
624 status.set_code( ItemStatusCode::ISC_INVALID_DATA );
625 status.set_error_message( "a table cell must target a table container" );
626 aItemHandler( status, anyItem );
627 continue;
628 }
629
630 PCB_TABLECELL* cell = static_cast<PCB_TABLECELL*>( item.release() );
631 commit->Modify( table );
632 table->AddCell( cell );
633 cell->Serialize( newItem );
634 }
635 else
636 {
637 if( item->Type() == PCB_FOOTPRINT_T || BaseType( item->Type() ) == PCB_TABLE_T )
638 {
639 // Ensure children have unique identifiers; in case the API client created
640 // this new item by cloning an existing one and only changing the parent UUID.
641 item->RunOnChildren(
642 []( BOARD_ITEM* aChild )
643 {
644 aChild->ResetUuid();
645 },
646 RECURSE );
647 }
648
649 BOARD_ITEM* newBoardItem = item.get();
650 item->Serialize( newItem );
651 commit->Add( item.release() );
652
653 if( newBoardItem->Type() == PCB_GENERATOR_T )
654 {
655 if( GENERATOR_TOOL* genTool = ensureGeneratorTool() )
656 regenerateGenerators( genTool, commit, { static_cast<PCB_GENERATOR*>( newBoardItem ) }, {} );
657
658 // The regeneration may have added members
659 newBoardItem->Serialize( newItem );
660 }
661 }
662 }
663 else
664 {
665 BOARD_ITEM* boardItem = *optItem;
666
667 if( boardItem->Type() == PCB_GENERATOR_T )
668 {
669 commit->Modify( boardItem );
670 boardItem->Deserialize( anyItem );
671
672 static_cast<PCB_GROUP*>( boardItem )->FinalizeGroupDeserialization();
673
674 if( GENERATOR_TOOL* genTool = ensureGeneratorTool() )
675 regenerateGenerators( genTool, commit, { static_cast<PCB_GENERATOR*>( boardItem ) }, {} );
676
677 boardItem->Serialize( newItem );
678 }
679
680 // A client cannot format generated cells, so the live cells hold the only formatting and a copy would
681 // drop it. The message's settings are applied to the live table instead
682 else if( IsGeneratedTableType( boardItem->Type() ) )
683 {
684 PCB_GENERATED_TABLE* table = static_cast<PCB_GENERATED_TABLE*>( boardItem );
685
686 commit->Modify( table );
687 table->ApplySettings( *static_cast<PCB_GENERATED_TABLE*>( item.get() ) );
688 table->RebuildCells( *board );
689 table->Serialize( newItem );
690 }
691
692 // Footprints can't be modified by CopyFrom at the moment because the commit system
693 // doesn't currently know what to do with a footprint that has had its children
694 // replaced with other children; which results in things like the view not having its
695 // cached geometry for footprint children updated when you move a footprint around.
696 // And also, groups are special because they can contain any item type, so we
697 // can't use CopyFrom on them either.
698 else if( boardItem->Type() == PCB_FOOTPRINT_T || boardItem->Type() == PCB_GROUP_T )
699 {
700 // Save group membership before removal, since Remove() severs the relationship
701 PCB_GROUP* parentGroup = dynamic_cast<PCB_GROUP*>( boardItem->GetParentGroup() );
702
703 commit->Remove( boardItem );
704 item->Serialize( newItem );
705
706 BOARD_ITEM* newBoardItem = item.release();
707 commit->Add( newBoardItem );
708
709 // Restore group membership for the newly added item
710 if( parentGroup )
711 parentGroup->AddItem( newBoardItem );
712 }
713 else
714 {
715 EDA_GROUP* parentGroup = boardItem->GetParentGroup();
716 BOARD_ITEM* parent = boardItem->GetParent();
717
718 commit->Modify( boardItem );
719 boardItem->CopyFrom( item.get() );
720
721 if( parentGroup )
722 boardItem->SetParentGroup( parentGroup );
723
724 if( parent )
725 boardItem->SetParent( parent );
726
727 boardItem->Serialize( newItem );
728 }
729 }
730
731 aItemHandler( status, newItem );
732 }
733
734 if( !m_activeClients.count( aClientName ) )
735 {
736 pushCurrentCommit( aClientName, aCreate ? _( "Created items via API" )
737 : _( "Modified items via API" ) );
738 }
739
740 return ItemRequestStatus::IRS_OK;
741}
742
743
745 const google::protobuf::RepeatedField<int>& aTypes )
746{
747 std::vector<KICAD_T> types;
748
749 for( int typeRaw : aTypes )
750 {
751 auto typeMessage = static_cast<common::types::KiCadObjectType>( typeRaw );
752 KICAD_T type = FromProtoEnum<KICAD_T>( typeMessage );
753
754 if( type != TYPE_NOT_INIT )
755 types.emplace_back( type );
756 }
757
758 return types;
759}
760
761
763 const HANDLER_CONTEXT<RunAction>& aCtx )
764{
765 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "RunAction" ) )
766 return tl::unexpected( *headless );
767
768 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
769 return tl::unexpected( *busy );
770
771 RunActionResponse response;
772
773 if( toolManager()->RunAction( aCtx.Request.action(), true ) )
774 response.set_status( RunActionStatus::RAS_OK );
775 else
776 response.set_status( RunActionStatus::RAS_INVALID );
777
778 return response;
779}
780
781
784{
785 if( !validateItemHeaderDocument( aCtx.Request.header() ) )
786 {
787 ApiResponseStatus e;
788 e.set_status( ApiStatusCode::AS_UNHANDLED );
789 return tl::unexpected( e );
790 }
791
792 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
793 return tl::unexpected( *busy );
794
795 GetItemsResponse response;
796
797 std::vector<BOARD_ITEM*> items;
798
799 for( const kiapi::common::types::KIID& id : aCtx.Request.items() )
800 {
801 if( std::optional<BOARD_ITEM*> item = getItemById( KIID( id.value() ) ) )
802 items.emplace_back( *item );
803 }
804
805 if( items.empty() )
806 {
807 ApiResponseStatus e;
808 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
809 e.set_error_message( "none of the requested IDs were found or valid" );
810 return tl::unexpected( e );
811 }
812
813 for( const BOARD_ITEM* item : items )
814 {
815 google::protobuf::Any itemBuf;
816 item->Serialize( itemBuf );
817 response.mutable_items()->Add( std::move( itemBuf ) );
818 }
819
820 response.set_status( ItemRequestStatus::IRS_OK );
821 return response;
822}
823
824
827{
828 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "GetSelection" ) )
829 return tl::unexpected( *headless );
830
831 if( !validateItemHeaderDocument( aCtx.Request.header() ) )
832 {
833 ApiResponseStatus e;
834 // No message needed for AS_UNHANDLED; this is an internal flag for the API server
835 e.set_status( ApiStatusCode::AS_UNHANDLED );
836 return tl::unexpected( e );
837 }
838
839 std::set<KICAD_T> filter;
840
841 for( KICAD_T type : parseRequestedItemTypes( aCtx.Request.types() ) )
842 {
843 filter.insert( type );
844
845 if( type == PCB_DIMENSION_T )
846 {
847 filter.insert( PCB_DIM_ALIGNED_T );
849 filter.insert( PCB_DIM_RADIAL_T );
850 filter.insert( PCB_DIM_LEADER_T );
851 filter.insert( PCB_DIM_CENTER_T );
852 }
853 }
854
855 TOOL_MANAGER* mgr = toolManager();
856 PCB_SELECTION_TOOL* selectionTool = mgr->GetTool<PCB_SELECTION_TOOL>();
857
858 SelectionResponse response;
859
860 for( EDA_ITEM* item : selectionTool->GetSelection() )
861 {
862 if( filter.empty() || filter.contains( item->Type() ) )
863 item->Serialize( *response.add_items() );
864 }
865
866 return response;
867}
868
869
872{
873 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "ClearSelection" ) )
874 return tl::unexpected( *headless );
875
876 if( !validateItemHeaderDocument( aCtx.Request.header() ) )
877 {
878 ApiResponseStatus e;
879 // No message needed for AS_UNHANDLED; this is an internal flag for the API server
880 e.set_status( ApiStatusCode::AS_UNHANDLED );
881 return tl::unexpected( e );
882 }
883
884 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
885 return tl::unexpected( *busy );
886
887 TOOL_MANAGER* mgr = toolManager();
889 m_frame->Refresh();
890
891 return Empty();
892}
893
894
897{
898 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "AddToSelection" ) )
899 return tl::unexpected( *headless );
900
901 if( !validateItemHeaderDocument( aCtx.Request.header() ) )
902 {
903 ApiResponseStatus e;
904 // No message needed for AS_UNHANDLED; this is an internal flag for the API server
905 e.set_status( ApiStatusCode::AS_UNHANDLED );
906 return tl::unexpected( e );
907 }
908
909 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
910 return tl::unexpected( *busy );
911
912 TOOL_MANAGER* mgr = toolManager();
913 PCB_SELECTION_TOOL* selectionTool = mgr->GetTool<PCB_SELECTION_TOOL>();
914
915 std::vector<EDA_ITEM*> toAdd;
916
917 for( const types::KIID& id : aCtx.Request.items() )
918 {
919 if( std::optional<BOARD_ITEM*> item = getItemById( KIID( id.value() ) ) )
920 toAdd.emplace_back( *item );
921 }
922
923 selectionTool->AddItemsToSel( &toAdd );
924 m_frame->Refresh();
925
926 SelectionResponse response;
927
928 for( EDA_ITEM* item : selectionTool->GetSelection() )
929 item->Serialize( *response.add_items() );
930
931 return response;
932}
933
934
936{
937 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "FocusOnItems" ) )
938 return tl::unexpected( *headless );
939
940 if( HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.document() ); !documentValidation )
941 return tl::unexpected( documentValidation.error() );
942
943 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
944 return tl::unexpected( *busy );
945
946 if( aCtx.Request.items().empty() )
947 return tl::unexpected( MakeResponseStatus( AS_BAD_REQUEST, "no items were given to focus on" ) );
948
949 std::optional<BOX2I> bbox;
950 std::vector<std::string> missing;
951
952 for( const types::KIID& idMsg : aCtx.Request.items() )
953 {
954 std::optional<BOARD_ITEM*> item = getItemById( KIID( idMsg.value() ) );
955
956 if( !item )
957 {
958 missing.push_back( idMsg.value() );
959 continue;
960 }
961
962 if( bbox )
963 bbox->Merge( ( *item )->GetBoundingBox() );
964 else
965 bbox = ( *item )->GetBoundingBox();
966 }
967
968 if( !missing.empty() )
969 {
970 return tl::unexpected(
971 MakeResponseStatus( AS_BAD_REQUEST, fmt::format( "the items {} are not in the requested document",
972 fmt::join( missing, ", " ) ) ) );
973 }
974
975 if( aCtx.Request.has_margin() )
976 bbox->Inflate( UnpackDistance( aCtx.Request.margin() ) );
977
978 toolManager()->GetTool<COMMON_TOOLS>()->ZoomFitBox( *bbox );
979
980 return Empty();
981}
982
983
986{
987 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "RemoveFromSelection" ) )
988 return tl::unexpected( *headless );
989
990 if( !validateItemHeaderDocument( aCtx.Request.header() ) )
991 {
992 ApiResponseStatus e;
993 // No message needed for AS_UNHANDLED; this is an internal flag for the API server
994 e.set_status( ApiStatusCode::AS_UNHANDLED );
995 return tl::unexpected( e );
996 }
997
998 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
999 return tl::unexpected( *busy );
1000
1001 TOOL_MANAGER* mgr = toolManager();
1002 PCB_SELECTION_TOOL* selectionTool = mgr->GetTool<PCB_SELECTION_TOOL>();
1003
1004 std::vector<EDA_ITEM*> toRemove;
1005
1006 for( const types::KIID& id : aCtx.Request.items() )
1007 {
1008 if( std::optional<BOARD_ITEM*> item = getItemById( KIID( id.value() ) ) )
1009 toRemove.emplace_back( *item );
1010 }
1011
1012 selectionTool->RemoveItemsFromSel( &toRemove );
1013 m_frame->Refresh();
1014
1015 SelectionResponse response;
1016
1017 for( EDA_ITEM* item : selectionTool->GetSelection() )
1018 item->Serialize( *response.add_items() );
1019
1020 return response;
1021}
1022
1023
1026{
1027 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
1028
1029 if( !documentValidation )
1030 return tl::unexpected( documentValidation.error() );
1031
1032 BoardStackupResponse response;
1033
1034 board::PackBoardStackup( *board(), *response.mutable_stackup() );
1035
1036 return response;
1037}
1038
1039
1042{
1043 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
1044
1045 if( !documentValidation )
1046 return tl::unexpected( documentValidation.error() );
1047
1048 BoardEnabledLayersResponse response;
1049
1050 BOARD* board = this->board();
1051 int copperLayerCount = board->GetCopperLayerCount();
1052
1053 response.set_copper_layer_count( copperLayerCount );
1054
1055 LSET enabled = board->GetEnabledLayers();
1056
1057 // The Rescue layer is an internal detail and should be hidden from the API
1058 enabled.reset( Rescue );
1059
1060 // Just in case this is out of sync; the API should always return the expected copper layers
1061 enabled |= LSET::AllCuMask( copperLayerCount );
1062
1063 board::PackLayerSet( *response.mutable_layers(), enabled );
1064
1065 return response;
1066}
1067
1068
1071{
1072 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
1073
1074 if( !documentValidation )
1075 return tl::unexpected( documentValidation.error() );
1076
1078 GraphicsDefaultsResponse response;
1079
1080 // TODO: This should change to be an enum class
1081 constexpr std::array<kiapi::board::BoardLayerClass, LAYER_CLASS_COUNT> classOrder = {
1082 kiapi::board::BLC_SILKSCREEN,
1083 kiapi::board::BLC_COPPER,
1084 kiapi::board::BLC_EDGES,
1085 kiapi::board::BLC_COURTYARD,
1086 kiapi::board::BLC_FABRICATION,
1087 kiapi::board::BLC_OTHER
1088 };
1089
1090 for( int i = 0; i < LAYER_CLASS_COUNT; ++i )
1091 {
1092 kiapi::board::BoardLayerGraphicsDefaults* l = response.mutable_defaults()->add_layers();
1093
1094 l->set_layer( classOrder[i] );
1095 l->mutable_line_thickness()->set_value_nm( bds.m_LineThickness[i] );
1096
1097 kiapi::common::types::TextAttributes* text = l->mutable_text();
1098 text->mutable_size()->set_x_nm( bds.m_TextSize[i].x );
1099 text->mutable_size()->set_y_nm( bds.m_TextSize[i].y );
1100 text->mutable_stroke_width()->set_value_nm( bds.m_TextThickness[i] );
1101 text->set_italic( bds.m_TextItalic[i] );
1102 text->set_keep_upright( bds.m_TextUpright[i] );
1103 }
1104
1105 return response;
1106}
1107
1108
1111{
1112 if( !validateItemHeaderDocument( aCtx.Request.header() ) )
1113 {
1114 ApiResponseStatus e;
1115 // No message needed for AS_UNHANDLED; this is an internal flag for the API server
1116 e.set_status( ApiStatusCode::AS_UNHANDLED );
1117 return tl::unexpected( e );
1118 }
1119
1120 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
1121 return tl::unexpected( *busy );
1122
1123 GetBoundingBoxResponse response;
1124 bool includeText = aCtx.Request.mode() == BoundingBoxMode::BBM_ITEM_AND_CHILD_TEXT;
1125
1126 for( const types::KIID& idMsg : aCtx.Request.items() )
1127 {
1128 KIID id( idMsg.value() );
1129 std::optional<BOARD_ITEM*> optItem = getItemById( id );
1130
1131 if( !optItem )
1132 continue;
1133
1134 BOARD_ITEM* item = *optItem;
1135 BOX2I bbox;
1136
1137 if( item->Type() == PCB_FOOTPRINT_T )
1138 bbox = static_cast<FOOTPRINT*>( item )->GetBoundingBox( includeText );
1139 else
1140 bbox = item->GetBoundingBox();
1141
1142 response.add_items()->set_value( idMsg.value() );
1143 PackBox2( *response.add_boxes(), bbox );
1144 }
1145
1146 return response;
1147}
1148
1149
1152{
1153 if( HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() ); !documentValidation )
1154 return tl::unexpected( documentValidation.error() );
1155
1156 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
1157 return tl::unexpected( *busy );
1158
1159 BoardBoundingBoxResponse response;
1160 BOX2I bbox;
1161
1162 switch( aCtx.Request.mode() )
1163 {
1164 case BoardBoundingBoxMode::BBBM_ALL_ITEMS: bbox = board()->ComputeBoundingBox( false, false ); break;
1165 case BoardBoundingBoxMode::BBBM_PHYSICAL_LAYERS_ONLY: bbox = board()->ComputeBoundingBox( false, true ); break;
1166 case BoardBoundingBoxMode::BBBM_BOARD_EDGES_ONLY: bbox = board()->GetBoardEdgesBoundingBox(); break;
1167 default:
1168 return tl::unexpected( MakeResponseStatus( AS_BAD_REQUEST, "invalid bounding box mode requested" ) );
1169 }
1170
1171 PackBox2( *response.mutable_box(), bbox );
1172
1173 return response;
1174}
1175
1176
1179{
1180 if( HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
1181 !documentValidation )
1182 {
1183 return tl::unexpected( documentValidation.error() );
1184 }
1185
1186 PadShapeAsPolygonResponse response;
1188
1189 for( const types::KIID& padRequest : aCtx.Request.pads() )
1190 {
1191 KIID id( padRequest.value() );
1192 std::optional<BOARD_ITEM*> optPad = getItemById( id );
1193
1194 if( !optPad || ( *optPad )->Type() != PCB_PAD_T )
1195 continue;
1196
1197 response.add_pads()->set_value( padRequest.value() );
1198
1199 PAD* pad = static_cast<PAD*>( *optPad );
1200 SHAPE_POLY_SET poly;
1201 pad->TransformShapeToPolygon( poly, pad->Padstack().EffectiveLayerFor( layer ), 0,
1202 pad->GetMaxError(), ERROR_INSIDE );
1203
1204 types::PolygonWithHoles* polyMsg = response.mutable_polygons()->Add();
1205 PackPolyLine( *polyMsg->mutable_outline(), poly.COutline( 0 ) );
1206 }
1207
1208 return response;
1209}
1210
1211
1214{
1215 using board::types::BoardLayer;
1216
1217 if( HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
1218 !documentValidation )
1219 {
1220 return tl::unexpected( documentValidation.error() );
1221 }
1222
1223 PadstackPresenceResponse response;
1224
1225 LSET layers;
1226
1227 for( const int layer : aCtx.Request.layers() )
1228 {
1229 PCB_LAYER_ID pcbLayer = FromProtoEnum<PCB_LAYER_ID, BoardLayer>( static_cast<BoardLayer>( layer ) );
1230
1231 if( pcbLayer < 0 || pcbLayer >= PCB_LAYER_ID_COUNT )
1232 continue;
1233
1234 layers.set( pcbLayer );
1235 }
1236
1237 for( const types::KIID& padRequest : aCtx.Request.items() )
1238 {
1239 KIID id( padRequest.value() );
1240 std::optional<BOARD_ITEM*> optItem = getItemById( id );
1241
1242 if( !optItem )
1243 continue;
1244
1245 switch( ( *optItem )->Type() )
1246 {
1247 case PCB_PAD_T:
1248 {
1249 PAD* pad = static_cast<PAD*>( *optItem );
1250
1251 for( PCB_LAYER_ID layer : layers )
1252 {
1253 PadstackPresenceEntry* entry = response.add_entries();
1254 entry->mutable_item()->set_value( pad->m_Uuid.AsStdString() );
1255 entry->set_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>( layer ) );
1256 entry->set_presence( pad->FlashLayer( layer ) ? PSP_PRESENT : PSP_NOT_PRESENT );
1257 }
1258
1259 break;
1260 }
1261
1262 case PCB_VIA_T:
1263 {
1264 PCB_VIA* via = static_cast<PCB_VIA*>( *optItem );
1265
1266 for( PCB_LAYER_ID layer : layers )
1267 {
1268 PadstackPresenceEntry* entry = response.add_entries();
1269 entry->mutable_item()->set_value( via->m_Uuid.AsStdString() );
1270 entry->set_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>( layer ) );
1271 entry->set_presence( via->FlashLayer( layer ) ? PSP_PRESENT : PSP_NOT_PRESENT );
1272 }
1273
1274 break;
1275 }
1276
1277 default:
1278 break;
1279 }
1280 }
1281
1282 return response;
1283}
1284
1285
1288{
1289 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.document() );
1290
1291 if( !documentValidation )
1292 return tl::unexpected( documentValidation.error() );
1293
1294 ExpandTextVariablesResponse reply;
1295 BOARD* board = this->board();
1296
1297 std::function<bool( wxString* )> textResolver =
1298 [&]( wxString* token ) -> bool
1299 {
1300 // Handles m_board->GetTitleBlock() *and* m_board->GetProject()
1301 return board->ResolveTextVar( token, 0 );
1302 };
1303
1304 for( const std::string& textMsg : aCtx.Request.text() )
1305 {
1306 wxString text = ExpandTextVars( wxString::FromUTF8( textMsg ), &textResolver, INTERNAL );
1307
1308 if( aCtx.Request.expand_env_vars() )
1309 text = ExpandEnvVarSubstitutions( text, board->GetProject() );
1310
1311 reply.add_text( text.ToUTF8() );
1312 }
1313
1314 return reply;
1315}
1316
1317
1320{
1321 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "InteractiveMoveItems" ) )
1322 return tl::unexpected( *headless );
1323
1324 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
1325
1326 if( !documentValidation )
1327 return tl::unexpected( documentValidation.error() );
1328
1329 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
1330 return tl::unexpected( *busy );
1331
1332 TOOL_MANAGER* mgr = toolManager();
1333 std::vector<EDA_ITEM*> toSelect;
1334
1335 for( const kiapi::common::types::KIID& id : aCtx.Request.items() )
1336 {
1337 if( std::optional<BOARD_ITEM*> item = getItemById( KIID( id.value() ) ) )
1338 toSelect.emplace_back( static_cast<EDA_ITEM*>( *item ) );
1339 }
1340
1341 if( toSelect.empty() )
1342 {
1343 ApiResponseStatus e;
1344 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
1345 e.set_error_message( fmt::format( "None of the given items exist on the board",
1346 aCtx.Request.board().board_filename() ) );
1347 return tl::unexpected( e );
1348 }
1349
1350 PCB_SELECTION_TOOL* selectionTool = mgr->GetTool<PCB_SELECTION_TOOL>();
1351 selectionTool->GetSelection().SetReferencePoint( toSelect[0]->GetPosition() );
1352
1354 mgr->RunAction<EDA_ITEMS*>( ACTIONS::selectItems, &toSelect );
1355
1356 COMMIT* commit = getCurrentCommit( aCtx.ClientName );
1357 mgr->PostAPIAction( PCB_ACTIONS::move, commit );
1358
1359 return Empty();
1360}
1361
1362
1364 const HANDLER_CONTEXT<FlipItems>& aCtx )
1365{
1366 auto containerResult = validateItemHeaderDocument( aCtx.Request.header() );
1367
1368 if( !containerResult && containerResult.error().status() == ApiStatusCode::AS_UNHANDLED )
1369 {
1370 // No message needed for AS_UNHANDLED; this is an internal flag for the API server
1371 ApiResponseStatus e;
1372 e.set_status( ApiStatusCode::AS_UNHANDLED );
1373 return tl::unexpected( e );
1374 }
1375 else if( !containerResult )
1376 {
1377 return tl::unexpected( containerResult.error() );
1378 }
1379
1380 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
1381 return tl::unexpected( *busy );
1382
1384 aCtx.Request.direction() );
1385
1386 FlipItemsResponse response;
1387 response.mutable_header()->CopyFrom( aCtx.Request.header() );
1388
1389 BOARD_COMMIT* commit = static_cast<BOARD_COMMIT*>( getCurrentCommit( aCtx.ClientName ) );
1390
1391 bool anyModified = false;
1392
1393 for( const types::KIID& id : aCtx.Request.items() )
1394 {
1395 ItemFlipResult* result = response.add_flipped_items();
1396
1397 std::optional<BOARD_ITEM*> optItem = getItemById( KIID( id.value() ) );
1398
1399 if( !optItem )
1400 {
1401 result->mutable_status()->set_code( ItemStatusCode::ISC_NONEXISTENT );
1402 result->mutable_status()->set_error_message(
1403 fmt::format( "an item with UUID {} does not exist", id.value() ) );
1404 continue;
1405 }
1406
1407 BOARD_ITEM* boardItem = *optItem;
1408
1409 static const std::set<KICAD_T> flippableTypes = {
1411 PCB_PAD_T,
1416 PCB_TEXT_T,
1423 PCB_VIA_T,
1424 PCB_ARC_T,
1425 PCB_ZONE_T,
1437 };
1438
1439 KICAD_T itemType = boardItem->Type();
1440
1441 if( !flippableTypes.contains( itemType ) )
1442 {
1443 result->mutable_status()->set_code( ItemStatusCode::ISC_INVALID_TYPE );
1444 result->mutable_status()->set_error_message(
1445 fmt::format( "items of type {} cannot be flipped",
1446 magic_enum::enum_name( itemType ) ) );
1447 continue;
1448 }
1449
1450 commit->Modify( boardItem, nullptr, RECURSE_MODE::RECURSE );
1451 boardItem->Flip( boardItem->GetPosition(), flipDirection );
1452 boardItem->Normalize();
1453
1454 // Maybe this should be in FOOTPRINT::Normalize?
1455 if( boardItem->Type() == PCB_FOOTPRINT_T )
1456 static_cast<FOOTPRINT*>( boardItem )->InvalidateComponentClassCache();
1457
1458 anyModified = true;
1459
1460 google::protobuf::Any itemBuf;
1461 boardItem->Serialize( itemBuf );
1462 *result->mutable_item() = std::move( itemBuf );
1463
1464 result->mutable_status()->set_code( ItemStatusCode::ISC_OK );
1465 }
1466
1467 response.set_status( ItemRequestStatus::IRS_OK );
1468
1469 if( anyModified && !m_activeClients.count( aCtx.ClientName ) )
1470 pushCurrentCommit( aCtx.ClientName, _( "Flipped items via API" ) );
1471
1472 return response;
1473}
1474
1475
1478{
1479 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.document() );
1480
1481 if( !documentValidation )
1482 return tl::unexpected( documentValidation.error() );
1483
1484 SavedDocumentResponse response;
1485 response.mutable_document()->CopyFrom( aCtx.Request.document() );
1486
1487 CLIPBOARD_IO io;
1488 io.SetWriter(
1489 [&]( const wxString& aData )
1490 {
1491 response.set_contents( aData.ToUTF8() );
1492 } );
1493
1494 io.SaveBoard( wxEmptyString, *board(), nullptr );
1495
1496 return response;
1497}
1498
1499
1502{
1503 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "SaveSelectionToString" ) )
1504 return tl::unexpected( *headless );
1505
1507
1508 SavedSelectionResponse response;
1509
1510 TOOL_MANAGER* mgr = toolManager();
1511 PCB_SELECTION_TOOL* selectionTool = mgr->GetTool<PCB_SELECTION_TOOL>();
1512 PCB_SELECTION& selection = selectionTool->GetSelection();
1513
1514 CLIPBOARD_IO io;
1515 io.SetWriter(
1516 [&]( const wxString& aData )
1517 {
1518 response.set_contents( aData.ToUTF8() );
1519 } );
1520
1521 io.SetBoard( board() );
1522 io.SaveSelection( selection, thisDocumentType() == kiapi::common::types::DOCTYPE_FOOTPRINT );
1523
1524 return response;
1525}
1526
1527
1530{
1531 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.document() );
1532
1533 if( !documentValidation )
1534 return tl::unexpected( documentValidation.error() );
1535
1536 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
1537 return tl::unexpected( *busy );
1538
1539 CreateItemsResponse response;
1540 return response;
1541}
1542
1543
1545{
1546 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "GetVisibleLayers" ) )
1547 return tl::unexpected( *headless );
1548
1549 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
1550
1551 if( !documentValidation )
1552 return tl::unexpected( documentValidation.error() );
1553
1554 BoardLayers response;
1555
1556 for( PCB_LAYER_ID layer : LSET( board()->GetEnabledLayers() & board()->GetVisibleLayers() ) )
1557 response.add_layers( ToProtoEnum<PCB_LAYER_ID, board::types::BoardLayer>( layer ) );
1558
1559 return response;
1560}
1561
1562
1564{
1565 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "SetVisibleLayers" ) )
1566 return tl::unexpected( *headless );
1567
1568 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
1569
1570 if( !documentValidation )
1571 return tl::unexpected( documentValidation.error() );
1572
1573 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
1574 return tl::unexpected( *busy );
1575
1576 LSET visible;
1577 LSET enabled = board()->GetEnabledLayers();
1578
1579 for( int layerIdx : aCtx.Request.layers() )
1580 {
1581 PCB_LAYER_ID layer =
1582 FromProtoEnum<PCB_LAYER_ID>( static_cast<board::types::BoardLayer>( layerIdx ) );
1583
1584 if( enabled.Contains( layer ) )
1585 visible.set( layer );
1586 }
1587
1588 board()->SetVisibleLayers( visible );
1589
1590 PCB_BASE_EDIT_FRAME* editFrame = static_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1591 editFrame->GetAppearancePanel()->OnBoardChanged();
1592 editFrame->GetCanvas()->SyncLayersVisibility( board() );
1593 editFrame->Refresh();
1594 return Empty();
1595}
1596
1597
1600{
1601 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "GetActiveLayer" ) )
1602 return tl::unexpected( *headless );
1603
1604 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
1605
1606 if( !documentValidation )
1607 return tl::unexpected( documentValidation.error() );
1608
1609 PCB_BASE_EDIT_FRAME* editFrame = static_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1610
1611 BoardLayerResponse response;
1612 response.set_layer(
1614
1615 return response;
1616}
1617
1618
1621{
1622 if( std::optional<ApiResponseStatus> headless = checkForHeadless( "SetActiveLayer" ) )
1623 return tl::unexpected( *headless );
1624
1625 HANDLER_RESULT<bool> documentValidation = validateDocument( aCtx.Request.board() );
1626
1627 if( !documentValidation )
1628 return tl::unexpected( documentValidation.error() );
1629
1630 if( std::optional<ApiResponseStatus> busy = checkForBusy() )
1631 return tl::unexpected( *busy );
1632
1633 PCB_LAYER_ID layer = FromProtoEnum<PCB_LAYER_ID>( aCtx.Request.layer() );
1634
1635 if( !board()->GetEnabledLayers().Contains( layer ) )
1636 {
1637 ApiResponseStatus err;
1638 err.set_status( ApiStatusCode::AS_BAD_REQUEST );
1639 err.set_error_message( fmt::format( "Layer {} is not a valid layer for the given board",
1640 magic_enum::enum_name( layer ) ) );
1641 return tl::unexpected( err );
1642 }
1643
1644 PCB_BASE_EDIT_FRAME* editFrame = static_cast<PCB_BASE_EDIT_FRAME*>( m_frame );
1645 editFrame->SetActiveLayer( layer );
1646 return Empty();
1647}
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:56
tl::expected< T, ApiResponseStatus > HANDLER_RESULT
Definition api_handler.h:47
std::unique_ptr< BOARD_ITEM > CreateGeneratorForType(const wxString &aGeneratorType, BOARD_ITEM_CONTAINER *aContainer)
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
@ ERROR_INSIDE
@ LAYER_CLASS_COUNT
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:221
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition actions.h:229
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
GENERATOR_TOOL * ensureGeneratorTool() const
Creates the generator tool if needed (e.g. in headless mode); returns it if available.
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< BoardBoundingBoxResponse > handleGetBoardBoundingBox(const HANDLER_CONTEXT< GetBoardBoundingBox > &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)
BOARD * board() const
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)
HANDLER_RESULT< Empty > handleFocusOnItems(const HANDLER_CONTEXT< commands::FocusOnItems > &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)
void regenerateGenerators(GENERATOR_TOOL *aTool, BOARD_COMMIT *aCommit, const std::vector< PCB_GENERATOR * > &aGenerators, std::function< void(const KIID &, commands::ItemStatus)> aResultHandler) const
std::optional< BOARD_ITEM * > getItemById(const KIID &aId) const
HANDLER_RESULT< FlipItemsResponse > handleFlipItems(const HANDLER_CONTEXT< FlipItems > &aCtx)
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
std::map< std::string, std::pair< KIID, std::unique_ptr< COMMIT > > > m_commits
virtual std::optional< ApiResponseStatus > checkForBusy()
Checks if the editor can accept commands.
virtual types::DocumentType thisDocumentType() const =0
Override this to specify which document type this editor handles.
virtual void onModified()
EDA_BASE_FRAME * m_frame
void registerHandler(HANDLER_RESULT< ResponseType >(HandlerType::*aHandler)(const HANDLER_CONTEXT< RequestType > &), bool aAllowedDuringTask=false)
Registers an API command handler for the given message types.
void OnBoardChanged()
Update the panel contents from the application and board models.
BASE_SET & reset(size_t pos)
Definition base_set.h:153
BASE_SET & set(size_t pos)
Definition base_set.h:126
void RevertToCheckpoint(int aCheckpoint) override
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...
Definition board_item.h:99
virtual void CopyFrom(const BOARD_ITEM *aOther)
void ResetUuid()
Definition board_item.h:295
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:281
virtual void Normalize()
Perform any normalization required after a user rotate and/or flip.
Definition board_item.h:520
virtual void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Flip this object, i.e.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
void SetVisibleLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
Definition board.cpp:1235
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
Definition board.h:1314
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition board.cpp:1202
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false, bool aPhysicalLayersOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition board.cpp:2572
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
Definition board.cpp:2176
BOARD_DESIGN_SETTINGS & GetDesignSettings()
Definition board.cpp:1318
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 SaveSelection(const PCB_SELECTION &selected, bool isFootprintEditor)
void SetWriter(std::function< void(const wxString &)> aWriter)
void SetBoard(BOARD *aBoard)
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition commit.h:68
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
Definition commit.h:86
int Checkpoint()
Definition commit.h:134
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition commit.h:74
Handles action that are shared between different applications.
The base frame for deriving all KiCad main window classes.
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:43
virtual void FinalizeGroupDeserialization()
Definition eda_group.h:66
void AddItem(EDA_ITEM *aItem)
Add item to group.
Definition eda_group.cpp:58
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual VECTOR2I GetPosition() const
Definition eda_item.h:348
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition eda_item.cpp:280
const KIID m_Uuid
Definition eda_item.h:599
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:116
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual void SetParentGroup(EDA_GROUP *aGroup)
Definition eda_item.h:115
virtual wxString GetFriendlyName() const
Definition eda_item.cpp:575
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
Handle actions specific to filling copper zones.
Definition kiid.h:46
std::string AsStdString() const
Definition kiid.cpp:270
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:604
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Definition lset.h:63
Definition pad.h:61
static TOOL_ACTION genRemove
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.
bool IsMandatory() const
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
void RebuildCells(const BOARD &aBoard, GENERATED_TABLE_REFRESH *aRefresh=nullptr)
Regenerate the cells from the board.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:51
The selection tool: currently supports:
PCB_SELECTION & GetSelection()
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int AddItemsToSel(const TOOL_EVENT &aEvent)
int RemoveItemsFromSel(const TOOL_EVENT &aEvent)
void SetReferencePoint(const VECTOR2I &aP)
virtual void Serialize(google::protobuf::Any &aContainer) const
Serializes this object to the given Any message.
virtual bool Deserialize(const google::protobuf::Any &aContainer)
Deserializes the given protobuf message into this object.
Represent a set of closed polygons.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
@ RUN
Tool is invoked after being inactive.
Definition tool_base.h:75
Master controller class:
T * GetTool()
Return the tool of given type or nullptr if there is no such tool registered.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
bool PostAPIAction(const TOOL_ACTION &aAction, COMMIT *aCommit)
bool RunSynchronousAction(const TOOL_ACTION &aAction, COMMIT *aCommit, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
TOOL_BASE * FindTool(int aId) const
Search for a tool with given ID.
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject, bool aAllowEscapes)
Replace any environment variable & text variable references with their values.
Definition common.cpp:777
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, RESOLUTION_CONTEXT aContext)
Definition common.cpp:60
@ INTERNAL
Definition common.h:96
#define _(s)
@ RECURSE
Definition eda_item.h:51
int RefreshGeneratedTables(BOARD &aBoard)
Bring every generated table on the board up to date and return how many were rebuilt.
#define GENERATOR_TOOL_NAME
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ Rescue
Definition layer_ids.h:117
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:167
FLIP_DIRECTION
Definition mirror.h:26
void PackLayerSet(google::protobuf::RepeatedField< int > &aOutput, const LSET &aLayerSet)
void PackBoardStackup(const BOARD &aBoard, BoardStackup &aOut)
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API std::optional< KICAD_T > TypeNameFromAny(const google::protobuf::Any &aMessage)
Definition api_utils.cpp:50
KICOMMON_API ApiResponseStatus MakeResponseStatus(ApiStatusCode aCode, const std::string &aMessage)
Definition api_utils.cpp:39
KICOMMON_API void PackBox2(types::Box2 &aOutput, const BOX2I &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API std::optional< wxString > GeneratorTypeFromAny(const google::protobuf::Any &aMessage)
KICOMMON_API void PackPolyLine(types::PolyLine &aOutput, const SHAPE_LINE_CHAIN &aSlc, const EDA_IU_SCALE &aScale)
STL namespace.
Class to handle a set of BOARD_ITEMs.
bool IsGeneratedTableCell(const EDA_ITEM *aItem)
True for a cell whose text is generated from the board, so only its formatting is the user's.
Definition pcb_table.h:355
std::vector< EDA_ITEM * > EDA_ITEMS
std::string ClientName
Definition api_handler.h:53
RequestMessageType Request
Definition api_handler.h:54
const std::string table
wxString result
Test unit parsing edge cases and error handling.
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
Definition typeinfo.h:261
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ PCB_CONSTRAINT_T
a geometric constraint between board items
Definition typeinfo.h:237
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition typeinfo.h:80
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:98
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:95
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
Definition typeinfo.h:83
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89
@ TYPE_NOT_INIT
Definition typeinfo.h:73
@ PCB_DRILL_MAP_T
class PCB_DRILL_MAP, drill symbols drawn at the holes
Definition typeinfo.h:240
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:96
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition typeinfo.h:103
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition typeinfo.h:85
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition typeinfo.h:100
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:84
@ PCB_3D_BODY_T
class PCB_3D_BODY, a 3D body (extruded or model) on a footprint
Definition typeinfo.h:241
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
Definition typeinfo.h:81
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition typeinfo.h:82
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:91
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
Definition typeinfo.h:93
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition typeinfo.h:99
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
Definition typeinfo.h:87
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:78
@ PCB_GRID_ITEM_T
a subgrid placed on a board
Definition typeinfo.h:238
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:94
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:90
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
Definition typeinfo.h:92
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition typeinfo.h:86
@ PCB_STACKUP_TABLE_T
class PCB_STACKUP_TABLE, a live stackup table derived from PCB_TABLE
Definition typeinfo.h:242
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
Definition typeinfo.h:105
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:88
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:97
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
Definition typeinfo.h:239
constexpr bool IsGeneratedTableType(const KICAD_T aType)
A PCB_TABLE subclass whose cells are generated from the board rather than typed by the user.
Definition typeinfo.h:328