KiCad PCB EDA Suite
Loading...
Searching...
No Matches
conn_pin_name.cpp
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#include "conn_pin_name.h"
21
22#include <string_utils.h>
23#include <kiid.h>
24
25namespace SCH_CONNECTIVITY
26{
27wxString RenderPinNetName( const PIN_NAME_FACT& aPin, const PIN_NAME_REFERENCE& aReference,
28 bool aForceNoConnect )
29{
30 const bool unconnected = aForceNoConnect || aPin.noConnect;
31 wxString name = unconnected ? "unconnected-(" : "Net-(";
32
33 if( aReference.reference.IsEmpty() || aReference.reference.Last() == '?' )
34 {
35 wxString number = aPin.number;
36
37 if( aPin.padNumber != aPin.shownNumber && !aPin.padNumber.IsEmpty() )
38 number = aPin.padNumber;
39
40 if( aReference.reference.IsEmpty() )
41 name << aReference.symbolUuid;
42 else
43 name << aReference.reference
44 << wxString::Format( wxS( "-%08x" ),
45 static_cast<unsigned>( KIID( aReference.symbolUuid ).Hash() & 0xFFFFFFFF ) );
46
47 name << "-Pad" << number << ")";
48 }
49 else if( !aPin.name.IsEmpty() && aPin.name != aPin.shownNumber )
50 {
51 // Pin names may repeat across units; pad numbers are unique across the symbol.
52 name << aReference.referenceWithUnit << "-" << EscapeString( aPin.name, CTX_NETNAME );
53
54 if( unconnected || aPin.hasDuplicateName )
55 name << "-Pad" << EscapeString( aPin.padNumber, CTX_NETNAME );
56
57 name << ")";
58 }
59 else
60 {
61 name << aReference.reference << "-Pad" << EscapeString( aPin.padNumber, CTX_NETNAME ) << ")";
62 }
63
64 return name;
65}
66}
const char * name
Definition kiid.h:46
size_t Hash() const
Definition kiid.cpp:231
wxString RenderPinNetName(const PIN_NAME_FACT &aPin, const PIN_NAME_REFERENCE &aReference, bool aForceNoConnect)
Render a non-power pin name from unescaped values; an absent reference uses the symbol UUID.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_NETNAME