KiCad PCB EDA Suite
Loading...
Searching...
No Matches
conn_facts.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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#pragma once
21
22#include <cstdint>
23#include <map>
24#include <optional>
25#include <vector>
26#include <geometry/seg.h>
28#include <kiid.h>
29#include <lib_id.h>
31#include <eda_shape.h>
33#include <template_fieldnames.h>
34#include <core/typeinfo.h>
35#include <jumper_group.h>
36#include <pin_type.h>
37#include <pin_map.h>
38#include <pin_comparison.h>
39#include <sim/sim_model_input.h>
40#include <set>
41#include <wx/string.h>
42#include <wx/arrstr.h>
43
44class LIB_SYMBOL;
45class SCH_ITEM;
46class SCH_SCREEN;
47class SCH_SYMBOL;
48class SCH_FIELD;
49class SCH_SHEET_PATH;
50
51namespace SCH_CONNECTIVITY
52{
61
68{
71 bool operator==( const PORT_FACT& ) const = default;
72};
73
75{
78 int unit = 0;
80 wxString libraryName;
81 wxString name;
82 wxString shownName;
83 wxString shownNumber;
84 wxString number;
85 wxString padNumber;
86 bool canDrive = false;
87 bool globalPower = false;
88 bool localPower = false;
89 bool invisible = false;
90 bool globalPowerParent = false;
91 bool localPowerParent = false;
92 bool operator==( const PIN_FACT& ) const = default;
93};
94
101{
105 std::vector<PORT_FACT> ports;
106 std::optional<SEG> segment;
107 int lineWidth = 0;
108 std::vector<PIN_FACT> pins;
109 std::vector<KIID> jumperedWith;
110 wxString rawText;
111 std::vector<wxString> netclassFields;
112 bool outputShape = false;
113 bool multiUnit = false;
114 bool operator==( const ITEM_FACT& ) const = default;
115};
116
118{
121 std::vector<KIID> containedItems;
122 std::vector<KIID> attachedDirectives;
123 bool operator==( const RULE_AREA_FACT& aOther ) const;
124};
125
127{
129 std::vector<KIID> containedItems;
130 std::vector<KIID> attachedDirectives;
131 std::vector<wxString> netclasses;
132 bool operator==( const INSTANCE_RULE_AREA_FACT& ) const = default;
133};
134
136{
140 wxString name;
141 bool operator==( const FIELD_NAME_FACT& ) const = default;
142};
143
145{
146 wxString name;
147 bool powerInput = false;
148 bool input = false;
149 bool bidirectional = false;
150 bool operator==( const UNIT_FACT& ) const = default;
151};
152
154{
157 std::vector<UNIT_FACT> units;
158 bool operator==( const MULTI_UNIT_FACT& ) const = default;
159};
160
162{
164 wxString reference;
165 wxString name;
166 wxString footprint;
167 int unit = 0;
168 bool operator==( const MULTI_UNIT_REFERENCE& ) const = default;
169};
170
172{
176 std::vector<ASSOCIATED_FOOTPRINT> footprints;
177 std::set<wxString> pinNumbers;
179 bool operator==( const PIN_MAP_FACT& ) const = default;
180};
181
183{
186 wxArrayString filters;
187 bool operator==( const FOOTPRINT_FACT& ) const = default;
188};
189
191{
193 int unit = 0;
194 int bodyStyle = 0;
195 bool isPrivate = false;
198
199 int Compare( const LIBRARY_SHAPE_FACT& aOther, int aCompareFlags ) const;
200 bool operator==( const LIBRARY_SHAPE_FACT& aOther ) const;
201};
202
204{
206 bool mandatory = false;
207 wxString name;
208 wxString text;
210 bool visible = false;
211 bool nameShown = false;
212 bool isPrivate = false;
213 uintptr_t fontIdentity = 0;
215
216 bool Matches( const LIBRARY_FIELD_FACT& aOther, int aCompareFlags ) const;
217 bool operator==( const LIBRARY_FIELD_FACT& ) const = default;
218};
219
221
223{
227 bool hasEmbeddedSymbol = false;
228 int unitCount = 1;
230 std::vector<PIN_COMPARISON_DATA> pins;
231 std::vector<LIBRARY_SHAPE_FACT> shapes;
233 std::vector<LIBRARY_FIELD_FACT> fields;
234 std::optional<std::vector<PIN_COMPARISON_DATA>> inheritedPins;
235
236 // Content comparison for ERC; object/parent identity is excluded by SymbolCompareFlags.
237 bool Matches( const LIBRARY_SYMBOL_FACT& aOther, int aCompareFlags ) const;
238 bool HasDuplicatePins() const;
239 bool operator==( const LIBRARY_SYMBOL_FACT& ) const = default;
240};
241
243using LIBRARY_SYMBOL_FACTS = std::vector<LIBRARY_SYMBOL_FACT>;
244
251{
252 std::shared_ptr<const LIBRARY_SYMBOL_FACTS> librarySymbols;
253 std::vector<FOOTPRINT_FACT> footprints;
254 std::vector<PIN_MAP_FACT> pinMaps;
255 std::vector<MULTI_UNIT_FACT> multiUnits;
256 std::vector<ITEM_FACT> items;
257 std::vector<RULE_AREA_FACT> ruleAreas;
258 std::vector<KIID> netclassOwners;
259 std::vector<FIELD_NAME_FACT> invalidFieldNames;
261 bool operator==( const SCREEN_FACTS& aOther ) const;
262};
263
265{
267 wxString name;
268 wxString ncName;
269 std::vector<wxString> netclasses;
270 bool canDrive = false;
271 wxString reference;
272 bool operator==( const ITEM_TEXT_FACT& ) const = default;
273};
274
283
285{
288 wxString name;
289 bool operator==( const CHILD_SHEET_FACT& ) const = default;
290};
291
293{
296 wxString number;
297 wxString footprint;
298 bool ignoresDangling = false;
299 bool operator==( const PIN_MAP_CANDIDATE_FACT& ) const = default;
300};
301
303{
304 bool warning = false;
305 wxString message;
306 bool operator==( const TEXT_ASSERTION& ) const = default;
307};
308
319
321{
323 std::map<wxString, LIB_ID> overrides;
324 bool operator==( const VARIANT_SYMBOL_FACT& ) const = default;
325};
326
327std::optional<VARIANT_SYMBOL_FACT> ExtractVariantSymbolFact( const SCH_SYMBOL& aSymbol,
328 const SCH_SHEET_PATH& aPath );
329
337
338// Capture after current connectivity, netclasses and rule-area membership have been applied.
339std::vector<SIMULATION_MODEL_FACT> ExtractSimulationModelFacts( const SCH_SHEET_PATH& aPath,
340 const wxString& aVariantName );
341
348{
349 std::vector<std::pair<KIID, wxString>> footprints;
350 std::vector<VARIANT_SYMBOL_FACT> variantSymbols;
351 std::vector<PIN_MAP_CANDIDATE_FACT> pinMapCandidates;
352 int pageOrder = 0;
353 std::vector<MULTI_UNIT_REFERENCE> multiUnits;
354 std::vector<std::pair<KIID, int>> units;
355 std::vector<ITEM_TEXT_FACT> items;
356 std::vector<INSTANCE_RULE_AREA_FACT> ruleAreas;
357 std::vector<NETCLASS_REFERENCE> netclassReferences;
358 std::vector<CHILD_SHEET_FACT> childSheets;
359 bool operator==( const INSTANCE_FACTS& ) const = default;
360};
361
362std::vector<TEXT_ASSERTION> ExtractTextAssertions( const wxString& aText );
363
364std::vector<TEXT_CHECK_FACT> ExtractTextChecks( const SCH_SCREEN& aScreen, const SCH_SHEET_PATH& aPath );
365
366// The caller must install a private drawing layout so rendering cannot replace canvas-owned objects.
367std::vector<TEXT_CHECK_FACT> ExtractDrawingSheetTextChecks( const SCH_SCREEN& aScreen, const SCH_SHEET_PATH& aPath );
368
369std::optional<PIN_MAP_FACT> ExtractPinMapFacts( const SCH_SYMBOL& aSymbol );
370
371std::vector<UNIT_FACT> ExtractUnitFacts( const LIB_SYMBOL& aSymbol );
372
378 std::shared_ptr<const LIBRARY_SYMBOL_FACTS> aLibrarySymbols = {},
379 const SCREEN_FACTS* aUnchangedNonLines = nullptr );
380INSTANCE_FACTS ExtractInstanceFacts( const SCREEN_FACTS& aFacts, const SCH_SCREEN& aScreen,
381 const SCH_SHEET_PATH& aPath );
382} // namespace SCH_CONNECTIVITY
Represents an (ordered) list of JUMPER_GROUP objects.
Definition kiid.h:46
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
Define a library symbol object.
Definition lib_symbol.h:114
A symbol-owned ordered set of named pin maps.
Definition pin_map.h:124
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
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:74
Represent a set of closed polygons.
@ NO_FILL
Definition eda_fill.h:30
@ SEGMENT
Definition eda_shape.h:56
KIID niluuid(0)
Value keys and the key session of the schematic connectivity engine.
LIBRARY_FIELD_FACT ExtractLibraryFieldFact(const SCH_FIELD &aField)
std::optional< PIN_MAP_FACT > ExtractPinMapFacts(const SCH_SYMBOL &aSymbol)
INSTANCE_FACTS ExtractInstanceFacts(const SCREEN_FACTS &aFacts, const SCH_SCREEN &aScreen, const SCH_SHEET_PATH &aPath)
std::vector< SIMULATION_MODEL_FACT > ExtractSimulationModelFacts(const SCH_SHEET_PATH &aPath, const wxString &aVariantName)
std::vector< TEXT_CHECK_FACT > ExtractTextChecks(const SCH_SCREEN &aScreen, const SCH_SHEET_PATH &aPath)
LIBRARY_SYMBOL_FACT ExtractLibrarySymbolFact(const LIB_SYMBOL &aSymbol)
std::vector< TEXT_ASSERTION > ExtractTextAssertions(const wxString &aText)
std::vector< TEXT_CHECK_FACT > ExtractDrawingSheetTextChecks(const SCH_SCREEN &aScreen, const SCH_SHEET_PATH &aPath)
SCREEN_FACTS ExtractScreenFacts(const SCH_SCREEN &aScreen, std::shared_ptr< const LIBRARY_SYMBOL_FACTS > aLibrarySymbols, const SCREEN_FACTS *aUnchangedNonLines)
Main-thread snapshots; no derived connectivity or model pointers survive extraction.
std::vector< LIBRARY_SYMBOL_FACT > LIBRARY_SYMBOL_FACTS
Definition conn_facts.h:243
std::optional< VARIANT_SYMBOL_FACT > ExtractVariantSymbolFact(const SCH_SYMBOL &aSymbol, const SCH_SHEET_PATH &aPath)
std::vector< UNIT_FACT > ExtractUnitFacts(const LIB_SYMBOL &aSymbol)
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition pin_type.h:32
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
Definition pin_type.h:41
bool operator==(const CHILD_SHEET_FACT &) const =default
bool operator==(const FIELD_NAME_FACT &) const =default
bool operator==(const FOOTPRINT_FACT &) const =default
The text and unit data that one sheet instance resolves for the items of its screen.
Definition conn_facts.h:348
std::vector< INSTANCE_RULE_AREA_FACT > ruleAreas
Definition conn_facts.h:356
std::vector< std::pair< KIID, int > > units
Definition conn_facts.h:354
bool operator==(const INSTANCE_FACTS &) const =default
std::vector< PIN_MAP_CANDIDATE_FACT > pinMapCandidates
Definition conn_facts.h:351
std::vector< CHILD_SHEET_FACT > childSheets
Definition conn_facts.h:358
std::vector< ITEM_TEXT_FACT > items
Definition conn_facts.h:355
std::vector< MULTI_UNIT_REFERENCE > multiUnits
Definition conn_facts.h:353
std::vector< std::pair< KIID, wxString > > footprints
Definition conn_facts.h:349
std::vector< VARIANT_SYMBOL_FACT > variantSymbols
Definition conn_facts.h:350
std::vector< NETCLASS_REFERENCE > netclassReferences
Definition conn_facts.h:357
bool operator==(const INSTANCE_RULE_AREA_FACT &) const =default
A value copy of one connectable item, or of one group of pins that share a number and a position.
Definition conn_facts.h:101
std::vector< wxString > netclassFields
Definition conn_facts.h:111
std::vector< PIN_FACT > pins
Definition conn_facts.h:108
KIID owner
The parent symbol or sheet, or niluuid.
Definition conn_facts.h:104
std::vector< KIID > jumperedWith
Definition conn_facts.h:109
bool operator==(const ITEM_FACT &) const =default
std::optional< SEG > segment
Definition conn_facts.h:106
std::vector< PORT_FACT > ports
Definition conn_facts.h:105
std::vector< wxString > netclasses
Definition conn_facts.h:269
bool operator==(const ITEM_TEXT_FACT &) const =default
bool Matches(const LIBRARY_FIELD_FACT &aOther, int aCompareFlags) const
bool operator==(const LIBRARY_FIELD_FACT &) const =default
int Compare(const LIBRARY_SHAPE_FACT &aOther, int aCompareFlags) const
bool operator==(const LIBRARY_SHAPE_FACT &aOther) const
std::vector< LIBRARY_FIELD_FACT > fields
Definition conn_facts.h:233
bool operator==(const LIBRARY_SYMBOL_FACT &) const =default
std::vector< PIN_COMPARISON_DATA > pins
Definition conn_facts.h:230
std::optional< std::vector< PIN_COMPARISON_DATA > > inheritedPins
Definition conn_facts.h:234
bool Matches(const LIBRARY_SYMBOL_FACT &aOther, int aCompareFlags) const
std::vector< LIBRARY_SHAPE_FACT > shapes
Definition conn_facts.h:231
bool operator==(const MULTI_UNIT_FACT &) const =default
std::vector< UNIT_FACT > units
Definition conn_facts.h:157
bool operator==(const MULTI_UNIT_REFERENCE &) const =default
bool operator==(const NETCLASS_REFERENCE &) const =default
bool operator==(const PIN_FACT &) const =default
ELECTRICAL_PINTYPE type
Definition conn_facts.h:79
bool operator==(const PIN_MAP_CANDIDATE_FACT &) const =default
std::set< wxString > pinNumbers
Definition conn_facts.h:177
JUMPER_GROUP_SET jumperGroups
Definition conn_facts.h:178
bool operator==(const PIN_MAP_FACT &) const =default
std::vector< ASSOCIATED_FOOTPRINT > footprints
Definition conn_facts.h:176
One connection point of an item.
Definition conn_facts.h:68
bool operator==(const PORT_FACT &) const =default
std::vector< KIID > attachedDirectives
Definition conn_facts.h:122
std::vector< KIID > containedItems
Definition conn_facts.h:121
bool operator==(const RULE_AREA_FACT &aOther) const
The value copy of one screen.
Definition conn_facts.h:251
bool operator==(const SCREEN_FACTS &aOther) const
std::vector< KIID > netclassOwners
Definition conn_facts.h:258
std::vector< MULTI_UNIT_FACT > multiUnits
Definition conn_facts.h:255
std::vector< FIELD_NAME_FACT > invalidFieldNames
Definition conn_facts.h:259
std::vector< ITEM_FACT > items
Definition conn_facts.h:256
const LIBRARY_SYMBOL_FACTS & LibrarySymbols() const
std::vector< RULE_AREA_FACT > ruleAreas
Definition conn_facts.h:257
std::vector< PIN_MAP_FACT > pinMaps
Definition conn_facts.h:254
std::vector< FOOTPRINT_FACT > footprints
Definition conn_facts.h:253
std::shared_ptr< const LIBRARY_SYMBOL_FACTS > librarySymbols
Definition conn_facts.h:252
bool operator==(const SIMULATION_MODEL_FACT &) const =default
bool operator==(const TEXT_ASSERTION &) const =default
std::vector< TEXT_ASSERTION > assertions
Definition conn_facts.h:315
bool operator==(const TEXT_CHECK_FACT &) const =default
bool operator==(const UNIT_FACT &) const =default
bool operator==(const VARIANT_SYMBOL_FACT &) const =default
std::map< wxString, LIB_ID > overrides
Definition conn_facts.h:323
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ USER
The field ID hasn't been set yet; field is invalid.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ TYPE_NOT_INIT
Definition typeinfo.h:73
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683