KiCad PCB EDA Suite
Loading...
Searching...
No Matches
netlist_exporter_xml.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 1992-2013 jp.charras at wanadoo.fr
5 * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <[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
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU 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#pragma once
23
25#include <project.h>
26#include <sch_edit_frame.h>
27
29class XNODE;
30
31#define GENERIC_INTERMEDIATE_NETLIST_EXT wxT( "xml" )
32
37{
38 GNL_LIBRARIES = 1 << 0,
39 GNL_SYMBOLS = 1 << 1,
40 GNL_PARTS = 1 << 2,
41 GNL_HEADER = 1 << 3,
42 GNL_NETS = 1 << 4,
43 GNL_OPT_KICAD = 1 << 5,
44 GNL_OPT_BOM = 1 << 6,
45};
46
47
55{
56public:
58 NETLIST_EXPORTER_BASE( aSchematic ),
60 {}
61
70 bool writeNetlist( const wxString& aOutFileName, unsigned aNetlistOptions, REPORTER& aReporter ) override;
71
72#define GNL_ALL ( GNL_LIBRARIES | GNL_SYMBOLS | GNL_PARTS | GNL_HEADER | GNL_NETS )
73
74protected:
83 XNODE* node( const wxString& aName, const wxString& aTextualContent = wxEmptyString );
84
92 XNODE* makeRoot( unsigned aCtl = GNL_ALL );
93
97 XNODE* makeSymbols( unsigned aCtl );
98
102 XNODE* makeGroups();
103
108
114
120
125 XNODE* makeListOfNets( unsigned aCtl );
126
128
135
136 void addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH& aSheet,
137 const SCH_SHEET_LIST& aSheetList, const wxString& aVariant );
138
142 std::vector<wxString> getComponentClassNamesForAllSymbolUnits( SCH_SYMBOL* aSymbol,
143 const SCH_SHEET_PATH& aSymbolSheet,
144 const SCH_SHEET_LIST& aSheetList );
145
146private:
148
149protected:
150 RESOLUTION_CONTEXT m_resolveTextVars; // Export textVar references resolved
151
152private:
153 std::set<wxString> m_libraries; // Set of library nicknames.
154
156 std::map<SCH_SHEET_PATH, std::unordered_set<wxString>> m_sheetComponentClasses;
157};
Calculate the connectivity of a schematic and generate netlists.
NETLIST_EXPORTER_BASE(SCHEMATIC *aSchematic)
std::map< SCH_SHEET_PATH, std::unordered_set< wxString > > m_sheetComponentClasses
Map of all sheets to component classes covering the whole sheet.
XNODE * makeDesignHeader()
Fill out a project "design" header into an XML node.
NETLIST_EXPORTER_XML(SCHEMATIC *aSchematic)
XNODE * makeLibraries()
Fill out an XML node with a list of used libraries and returns it.
XNODE * node(const wxString &aName, const wxString &aTextualContent=wxEmptyString)
A convenience function that creates a new XNODE with an optional textual child.
XNODE * makeListOfNets(unsigned aCtl)
Fill out an XML node with a list of nets and returns it.
RESOLUTION_CONTEXT m_resolveTextVars
bool writeNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter) override
Write generic netlist to aOutFileName.
std::vector< wxString > getComponentClassNamesForAllSymbolUnits(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSymbolSheet, const SCH_SHEET_LIST &aSheetList)
Finds all component class names attached to any sub-unit of a given symbol.
XNODE * makeSymbols(unsigned aCtl)
void addSymbolFields(XNODE *aNode, SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSheet, const SCH_SHEET_LIST &aSheetList, const wxString &aVariant)
Holder for multi-unit symbol fields.
XNODE * makeRoot(unsigned aCtl=GNL_ALL)
Build the entire document tree for the generic export.
std::set< wxString > m_libraries
XNODE * makeLibParts()
Fill out an XML node with the unique library parts and returns it.
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Holds all the data relating to one schematic.
Definition schematic.h:148
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition sch_symbol.h:75
An extension of wxXmlNode that can format its contents as KiCad-style s-expressions.
Definition xnode.h:67
RESOLUTION_CONTEXT
Definition common.h:87
@ RESOLVED
Definition common.h:93
#define GNL_ALL
GNL_T
A set of bits which control the totality of the tree built by makeRoot()
@ GNL_LIBRARIES
@ GNL_OPT_KICAD
@ GNL_SYMBOLS
@ GNL_OPT_BOM