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:
57 NETLIST_EXPORTER_XML( SCHEMATIC* aSchematic, KIWAY* aKiway ) :
58 NETLIST_EXPORTER_BASE( aSchematic, aKiway ),
60 {}
61
71 bool writeNetlist( const wxString& aOutFileName, unsigned aNetlistOptions, REPORTER& aReporter ) override;
72
73#define GNL_ALL ( GNL_LIBRARIES | GNL_SYMBOLS | GNL_PARTS | GNL_HEADER | GNL_NETS )
74
75protected:
84 XNODE* node( const wxString& aName, const wxString& aTextualContent = wxEmptyString );
85
93 XNODE* makeRoot( unsigned aCtl = GNL_ALL );
94
98 XNODE* makeSymbols( unsigned aCtl );
99
103 XNODE* makeGroups();
104
109
115
121
126 XNODE* makeListOfNets( unsigned aCtl );
127
129
136
137 void addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH& aSheet,
138 const SCH_SHEET_LIST& aSheetList, const wxString& aVariant );
139
143 std::vector<wxString> getComponentClassNamesForAllSymbolUnits( SCH_SYMBOL* aSymbol,
144 const SCH_SHEET_PATH& aSymbolSheet,
145 const SCH_SHEET_LIST& aSheetList );
146
147private:
149
150protected:
151 RESOLUTION_CONTEXT m_resolveTextVars; // Export textVar references resolved
152
153private:
154 std::set<wxString> m_libraries; // Set of library nicknames.
155
157 std::map<SCH_SHEET_PATH, std::unordered_set<wxString>> m_sheetComponentClasses;
158};
Calculate the connectivity of a schematic and generate netlists.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:348
NETLIST_EXPORTER_BASE(SCHEMATIC *aSchematic, KIWAY *aKiway)
NETLIST_EXPORTER_XML(SCHEMATIC *aSchematic, KIWAY *aKiway)
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.
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:149
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:73
An extension of wxXmlNode that can format its contents as KiCad-style s-expressions.
Definition xnode.h:67
RESOLUTION_CONTEXT
Definition common.h:89
@ RESOLVED
Definition common.h:95
#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