KiCad PCB EDA Suite
Loading...
Searching...
No Matches
easypc_sch_builder.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
28
29#ifndef EASYPC_SCH_BUILDER_H
30#define EASYPC_SCH_BUILDER_H
31
32#include <map>
33#include <set>
34#include <vector>
35
36#include <math/vector2d.h>
37#include <wx/string.h>
38
39class REPORTER;
40class SCHEMATIC;
41class SCH_LABEL_BASE;
42class SCH_SCREEN;
43class SCH_SHEET;
44class SCH_SHEET_PATH;
45class SCH_SYMBOL;
46
47namespace EASYPC
48{
49
50struct SOURCE_BUS;
51struct SOURCE_COMPONENT;
53struct SOURCE_DESIGN;
54struct SOURCE_NODE;
55struct SOURCE_SHAPE;
56struct SOURCE_SYMBOL;
58struct DESIGN_DOCUMENT;
59struct POINT32;
60struct SCH_FRAME;
61
62
64bool IsNamedNet( const wxString& aName );
65
66
69{
70public:
71 void AddSheet( const DESIGN_DOCUMENT& aDoc );
72
73 wxString Name( const wxString& aStoredName ) const;
74
76 bool Shared( const wxString& aName ) const;
77
78private:
79 std::map<wxString, wxString> m_canonical;
80 std::map<wxString, int> m_sheetCount;
81};
82
83
85{
86public:
87 SCH_BUILDER( SCHEMATIC* aSchematic, const SCH_NET_NAMES& aNames, REPORTER* aReporter );
88
89 void BuildSheet( const DESIGN_DOCUMENT& aDoc, SCH_SHEET* aSheet, const SCH_SHEET_PATH& aSheetPath );
90
92 void SetProjectSymbols( const std::vector<const DESIGN_DOCUMENT*>& aDocs );
93
94private:
95 VECTOR2I toSheet( int32_t aX, int32_t aY ) const;
96 VECTOR2I toSheet( const POINT32& aPoint ) const;
97
98 void computeOffset( const SOURCE_DESIGN& aDesign );
99 void buildSymbols( const SOURCE_DESIGN& aDesign, const SCH_SHEET_PATH& aSheetPath );
100 void buildWires( const SOURCE_DESIGN& aDesign );
101 void buildLabels( const SOURCE_DESIGN& aDesign );
102 void buildCommonPinCopies( const SOURCE_DESIGN& aDesign );
103 void buildBuses( const SOURCE_DESIGN& aDesign );
104 void addBusAlias( const SOURCE_BUS& aBus, const SOURCE_SHAPE& aShape );
105 void placePinItems( const SOURCE_COMPONENT& aPart, const SOURCE_SYMBOL_INSTANCE& aInst, const SCH_FRAME& aFrame );
106 void placeFields( SCH_SYMBOL& aSymbol, const SOURCE_COMPONENT_INSTANCE& aComp, const SOURCE_SYMBOL_INSTANCE& aInst,
107 bool aPower, const SCH_FRAME& aFrame );
108
110 SCH_LABEL_BASE* addLabel( const wxString& aName, const VECTOR2I& aAt );
111
116 const SOURCE_DESIGN* m_design = nullptr;
117
118 int32_t m_originX = 0;
119 int32_t m_originY = 0;
120
121 std::map<wxString, const SOURCE_SYMBOL*> m_projectSymbols;
122 std::set<VECTOR2I> m_sharedPoints;
123 std::set<wxString> m_powerNets;
124 std::set<const SOURCE_NODE*> m_powerNodes;
125 std::set<wxString> m_labelledNets;
126 bool m_keepUpright = false;
128};
129
130} // namespace EASYPC
131
132#endif // EASYPC_SCH_BUILDER_H
void buildBuses(const SOURCE_DESIGN &aDesign)
void placePinItems(const SOURCE_COMPONENT &aPart, const SOURCE_SYMBOL_INSTANCE &aInst, const SCH_FRAME &aFrame)
std::map< wxString, const SOURCE_SYMBOL * > m_projectSymbols
by name, first sheet wins
void placeFields(SCH_SYMBOL &aSymbol, const SOURCE_COMPONENT_INSTANCE &aComp, const SOURCE_SYMBOL_INSTANCE &aInst, bool aPower, const SCH_FRAME &aFrame)
void addBusAlias(const SOURCE_BUS &aBus, const SOURCE_SHAPE &aShape)
std::set< const SOURCE_NODE * > m_powerNodes
const SOURCE_DESIGN * m_design
void buildWires(const SOURCE_DESIGN &aDesign)
std::set< wxString > m_labelledNets
upper-cased nets a label names
SCH_BUILDER(SCHEMATIC *aSchematic, const SCH_NET_NAMES &aNames, REPORTER *aReporter)
void buildSymbols(const SOURCE_DESIGN &aDesign, const SCH_SHEET_PATH &aSheetPath)
void BuildSheet(const DESIGN_DOCUMENT &aDoc, SCH_SHEET *aSheet, const SCH_SHEET_PATH &aSheetPath)
SCH_LABEL_BASE * addLabel(const wxString &aName, const VECTOR2I &aAt)
A local label, global when the name crosses sheets or a global power symbol names it.
VECTOR2I toSheet(int32_t aX, int32_t aY) const
void SetProjectSymbols(const std::vector< const DESIGN_DOCUMENT * > &aDocs)
Symbols of every sheet, for gates placed on a sheet other than the one being built.
std::set< VECTOR2I > m_sharedPoints
points where connections of different nets meet
void buildLabels(const SOURCE_DESIGN &aDesign)
void computeOffset(const SOURCE_DESIGN &aDesign)
int32_t m_originX
design point at the sheet's top left corner
void buildCommonPinCopies(const SOURCE_DESIGN &aDesign)
std::set< wxString > m_powerNets
upper-cased nets a power symbol names
const SCH_NET_NAMES & m_names
Project-wide net naming: a user name takes the spelling of its first occurrence.
void AddSheet(const DESIGN_DOCUMENT &aDoc)
bool Shared(const wxString &aName) const
A user name used on more than one sheet, which is one net across the project.
wxString Name(const wxString &aStoredName) const
std::map< wxString, int > m_sheetCount
std::map< wxString, wxString > m_canonical
upper-cased name to first spelling
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
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
Schematic symbol object.
Definition sch_symbol.h:73
bool IsNamedNet(const wxString &aName)
True unless aName is an automatic net name (N or n and digits, an optional !sheet!...
@ SCH_SYMBOL
one item stream of a Schematic Symbol Library
A point read as two int32 values.
Design to KiCad mapping: X shifted, Y negated about the origin.
The document: OLE items, then the design.
A placed footprint (gate -1) or a placed schematic gate.
Footprints and schematic symbols alike.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708