KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pads_sch_schematic_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 (C) 2025 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 3
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
20#ifndef PADS_SCH_SCHEMATIC_BUILDER_H_
21#define PADS_SCH_SCHEMATIC_BUILDER_H_
22
24#include <sch_label.h>
25#include <map>
26#include <set>
27#include <vector>
28#include <memory>
29#include <wx/string.h>
30
31class SCH_SCREEN;
32class SCH_SHEET;
33class SCH_SHEET_PATH;
34class SCH_SHEET_PIN;
35class SCH_HIERLABEL;
36class SCH_GLOBALLABEL;
37class SCH_LINE;
38class SCH_JUNCTION;
39class SCH_LABEL;
41class SCH_SYMBOL;
42class SCHEMATIC;
43
44namespace PADS_SCH
45{
46
52{
53public:
54 PADS_SCH_SCHEMATIC_BUILDER( const PARAMETERS& aParams, SCHEMATIC* aSchematic );
56
57 int CreateWires( const std::vector<SCH_SIGNAL>& aSignals, SCH_SCREEN* aScreen );
58
59 SCH_LINE* CreateWire( const WIRE_SEGMENT& aWire );
60
61 int CreateJunctions( const std::vector<SCH_SIGNAL>& aSignals, SCH_SCREEN* aScreen );
62
68 int CreateNetLabels( const std::vector<SCH_SIGNAL>& aSignals, SCH_SCREEN* aScreen,
69 const std::set<std::string>& aSignalOpcIds,
70 const std::set<std::string>& aSkipSignals = {},
71 const std::map<std::string, NETNAME_LABEL>& aNetNameLabels = {} );
72
81 static SPIN_STYLE SpinFromNetNameLabel( const NETNAME_LABEL& aLabel );
82
87 SCH_GLOBALLABEL* CreateNetLabel( const SCH_SIGNAL& aSignal, const VECTOR2I& aPosition,
88 SPIN_STYLE aOrientation = SPIN_STYLE::RIGHT );
89
90 int CreateBusWires( const std::vector<SCH_SIGNAL>& aSignals, SCH_SCREEN* aScreen );
91
92 SCH_LINE* CreateBusWire( const WIRE_SEGMENT& aWire );
93
94 static bool IsBusSignal( const std::string& aName );
95
99 void ApplyPartAttributes( SCH_SYMBOL* aSymbol, const PART_PLACEMENT& aPlacement );
100
101 void ApplyFieldSettings( SCH_SYMBOL* aSymbol, const PART_PLACEMENT& aPlacement );
102
106 int CreateCustomFields( SCH_SYMBOL* aSymbol, const PART_PLACEMENT& aPlacement );
107
112 void CreateTitleBlock( SCH_SCREEN* aScreen );
113
118 SCH_SHEET* CreateHierarchicalSheet( int aSheetNumber, int aTotalSheets,
119 SCH_SHEET* aParentSheet,
120 const wxString& aBaseFilename );
121
123
127 VECTOR2I CalculateSheetPosition( int aSheetIndex, int aTotalSheets ) const;
128
133 SCH_SHEET_PIN* CreateSheetPin( SCH_SHEET* aSheet, const std::string& aSignalName,
134 int aPinIndex );
135
140 SCH_HIERLABEL* CreateHierLabel( const std::string& aSignalName, const VECTOR2I& aPosition,
141 SCH_SCREEN* aScreen );
142
146 static bool IsGlobalSignal( const std::string& aSignalName,
147 const std::set<int>& aSheetNumbers );
148
152 static SPIN_STYLE computeLabelOrientation( const VECTOR2I& aLabelPos,
153 const VECTOR2I& aAdjacentPos );
154
155private:
156 int toKiCadUnits( double aPadsValue ) const;
157
161 int toKiCadY( double aPadsY ) const;
162
166 std::vector<VECTOR2I> findJunctionPoints( const std::vector<SCH_SIGNAL>& aSignals );
167
168 VECTOR2I chooseLabelPosition( const SCH_SIGNAL& aSignal );
169
173 wxString convertNetName( const std::string& aName ) const;
174
178};
179
180} // namespace PADS_SCH
181
182#endif // PADS_SCH_SCHEMATIC_BUILDER_H_
SCH_LINE * CreateWire(const WIRE_SEGMENT &aWire)
std::vector< VECTOR2I > findJunctionPoints(const std::vector< SCH_SIGNAL > &aSignals)
Find points where 3+ wire segments meet.
static SPIN_STYLE SpinFromNetNameLabel(const NETNAME_LABEL &aLabel)
Map a PADS NETNAMES label entry to a KiCad global-label spin style.
int toKiCadY(double aPadsY) const
Convert PADS Y coordinate to KiCad Y, accounting for Y-axis inversion and page offset.
SCH_SHEET_PIN * CreateSheetPin(SCH_SHEET *aSheet, const std::string &aSignalName, int aPinIndex)
Create a sheet pin that connects to a hierarchical label in the sub-schematic.
int CreateJunctions(const std::vector< SCH_SIGNAL > &aSignals, SCH_SCREEN *aScreen)
void ApplyPartAttributes(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
Set reference, value, footprint and other fields on a symbol from a part placement.
PADS_SCH_SCHEMATIC_BUILDER(const PARAMETERS &aParams, SCHEMATIC *aSchematic)
void CreateTitleBlock(SCH_SCREEN *aScreen)
Set the title block from PADS fields, checking custom names too because PADS designs often leave the ...
VECTOR2I CalculateSheetPosition(int aSheetIndex, int aTotalSheets) const
Position a sheet symbol in a roughly square grid on the parent.
static SPIN_STYLE computeLabelOrientation(const VECTOR2I &aLabelPos, const VECTOR2I &aAdjacentPos)
Orient a label opposite to the wire direction at its position so it clears the wire.
int CreateCustomFields(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
Create KiCad user fields for PADS attributes that have no standard-field mapping.
VECTOR2I chooseLabelPosition(const SCH_SIGNAL &aSignal)
SCH_LINE * CreateBusWire(const WIRE_SEGMENT &aWire)
SCH_HIERLABEL * CreateHierLabel(const std::string &aSignalName, const VECTOR2I &aPosition, SCH_SCREEN *aScreen)
Create a hierarchical label that connects to a sheet pin on the parent.
void ApplyFieldSettings(SCH_SYMBOL *aSymbol, const PART_PLACEMENT &aPlacement)
int CreateWires(const std::vector< SCH_SIGNAL > &aSignals, SCH_SCREEN *aScreen)
SCH_GLOBALLABEL * CreateNetLabel(const SCH_SIGNAL &aSignal, const VECTOR2I &aPosition, SPIN_STYLE aOrientation=SPIN_STYLE::RIGHT)
Create a net label.
static bool IsGlobalSignal(const std::string &aSignalName, const std::set< int > &aSheetNumbers)
A signal is global when it spans multiple sheets or is a common power net.
int CreateBusWires(const std::vector< SCH_SIGNAL > &aSignals, SCH_SCREEN *aScreen)
wxString convertNetName(const std::string &aName) const
Convert a PADS net name to a KiCad label, mapping a "/" prefix to a "~{}" overbar.
SCH_SHEET * CreateHierarchicalSheet(int aSheetNumber, int aTotalSheets, SCH_SHEET *aParentSheet, const wxString &aBaseFilename)
Create a sub-sheet positioned on its parent and backed by its own screen.
int CreateNetLabels(const std::vector< SCH_SIGNAL > &aSignals, SCH_SCREEN *aScreen, const std::set< std::string > &aSignalOpcIds, const std::set< std::string > &aSkipSignals={}, const std::map< std::string, NETNAME_LABEL > &aNetNameLabels={})
Create net labels for named signals.
static bool IsBusSignal(const std::string &aName)
Holds all the data relating to one schematic.
Definition schematic.h:148
Class for a wire to bus entry.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:39
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Define a sheet pin (label) used in sheets to create hierarchical schematics.
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:75
Wire segment connecting two endpoints through coordinate vertices.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683