/* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2023 Jon Evans * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #include #include std::unique_ptr CreateItemForType( KICAD_T aType, BOARD_ITEM_CONTAINER* aContainer ) { switch( aType ) { case PCB_TRACE_T: return std::make_unique( aContainer ); case PCB_ARC_T: return std::make_unique( aContainer ); case PCB_VIA_T: return std::make_unique( aContainer ); case PCB_TEXT_T: return std::make_unique( aContainer ); case PCB_TEXTBOX_T: return std::make_unique( aContainer ); case PCB_SHAPE_T: return std::make_unique( aContainer ); case PCB_ZONE_T: return std::make_unique( aContainer ); case PCB_GROUP_T: return std::make_unique( aContainer ); case PCB_REFERENCE_IMAGE_T: return std::make_unique( aContainer ); case PCB_PAD_T: { FOOTPRINT* footprint = dynamic_cast( aContainer ); if( !footprint ) return nullptr; return std::make_unique( footprint ); } case PCB_FOOTPRINT_T: { BOARD* board = dynamic_cast( aContainer ); if( !board ) return nullptr; return std::make_unique( board ); } default: return nullptr; } } namespace kiapi::board { void PackLayerSet( google::protobuf::RepeatedField& aOutput, const LSET& aLayerSet ) { for( const PCB_LAYER_ID& layer : aLayerSet.Seq() ) aOutput.Add( ToProtoEnum( layer ) ); } LSET UnpackLayerSet( const google::protobuf::RepeatedField& aProtoLayerSet ) { LSET set; for( int layer : aProtoLayerSet ) { wxCHECK2( layer >= F_Cu && layer < PCB_LAYER_ID_COUNT, continue ); PCB_LAYER_ID boardLayer = FromProtoEnum( static_cast( layer ) ); set.set( boardLayer ); } return set; } } // namespace kiapi::board