/* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2024 Jon Evans * Copyright (C) 2024 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 #include #include #include #include "api_sch_utils.h" std::unique_ptr CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer ) { SCH_ITEM* parentSchItem = dynamic_cast( aContainer ); switch( aType ) { case SCH_JUNCTION_T: return std::make_unique(); case SCH_NO_CONNECT_T: return std::make_unique(); case SCH_BUS_WIRE_ENTRY_T: return std::make_unique(); case SCH_BUS_BUS_ENTRY_T: return std::make_unique(); case SCH_LINE_T: return std::make_unique(); case SCH_SHAPE_T: return std::make_unique(); case SCH_BITMAP_T: return std::make_unique(); case SCH_TEXTBOX_T: return std::make_unique(); case SCH_TEXT_T: return std::make_unique(); case SCH_TABLE_T: return std::make_unique(); case SCH_TABLECELL_T: return std::make_unique(); case SCH_LABEL_T: return std::make_unique(); case SCH_GLOBAL_LABEL_T: return std::make_unique(); case SCH_HIER_LABEL_T: return std::make_unique(); case SCH_DIRECTIVE_LABEL_T: return std::make_unique(); case SCH_FIELD_T: return std::make_unique( parentSchItem ); case SCH_SYMBOL_T: { // TODO: constructing currently requires more than just a "container" LIB_SYMBOL return nullptr; } case SCH_SHEET_PIN_T: { if( aContainer && aContainer->Type() == SCH_SHEET_T ) return std::make_unique( static_cast( aContainer ) ); return nullptr; } case SCH_SHEET_T: return std::make_unique(); case SCH_PIN_T: { if( aContainer && aContainer->Type() == LIB_SYMBOL_T ) return std::make_unique( static_cast( aContainer ) ); return nullptr; } case LIB_SYMBOL_T: return nullptr; // TODO: ctor currently requires non-null name default: return nullptr; } }