KiCad PCB EDA Suite
pin_type.cpp File Reference
#include <bitmaps.h>
#include <cstddef>
#include <core/arraydim.h>
#include <lib_pin.h>
#include <pin_type.h>
#include "pgm_base.h"

Go to the source code of this file.

Classes

struct  pinTypeStruct
 
struct  pinShapeStruct
 

Macros

#define PIN_ORIENTATION_CNT   arrayDim( pin_orientation_codes )
 

Functions

wxString PinOrientationName (unsigned aPinOrientationCode)
 
int PinOrientationCode (int index)
 
int PinOrientationIndex (int code)
 
void InitTables ()
 
const wxArrayString & PinTypeNames ()
 
const std::vector< BITMAPS > & PinTypeIcons ()
 
const wxArrayString & PinShapeNames ()
 
const std::vector< BITMAPS > & PinShapeIcons ()
 
const wxArrayString & PinOrientationNames ()
 
const std::vector< BITMAPS > & PinOrientationIcons ()
 
wxString ElectricalPinTypeGetText (ELECTRICAL_PINTYPE aType)
 
BITMAPS ElectricalPinTypeGetBitmap (ELECTRICAL_PINTYPE aType)
 
wxString PinShapeGetText (GRAPHIC_PINSHAPE aShape)
 
BITMAPS PinShapeGetBitmap (GRAPHIC_PINSHAPE aShape)
 

Variables

static std::vector< BITMAPSg_typeIcons
 
static wxArrayString g_typeNames
 
static std::vector< BITMAPSg_shapeIcons
 
static wxArrayString g_shapeNames
 
static std::vector< BITMAPSg_orientationIcons
 
static wxArrayString g_orientationNames
 
std::map< ELECTRICAL_PINTYPE, struct pinTypeStructg_pinTypes
 
int g_pinTypesLanguage = wxLANGUAGE_UNKNOWN
 
const std::map< GRAPHIC_PINSHAPE, struct pinShapeStructpinShapes
 
static const int pin_orientation_codes []
 
static const BITMAPS iconsPinsOrientations []
 

Macro Definition Documentation

◆ PIN_ORIENTATION_CNT

#define PIN_ORIENTATION_CNT   arrayDim( pin_orientation_codes )

Definition at line 112 of file pin_type.cpp.

Function Documentation

◆ ElectricalPinTypeGetBitmap()

BITMAPS ElectricalPinTypeGetBitmap ( ELECTRICAL_PINTYPE  aType)

Definition at line 268 of file pin_type.cpp.

269{
270 auto findIt = g_pinTypes.find( aType );
271
272 wxCHECK_MSG( findIt != g_pinTypes.end(), BITMAPS::INVALID_BITMAP, wxT( "Pin type not found!" ) );
273
274 return findIt->second.bitmap;
275}
@ INVALID_BITMAP
std::map< ELECTRICAL_PINTYPE, struct pinTypeStruct > g_pinTypes
Definition: pin_type.cpp:51

References g_pinTypes, and INVALID_BITMAP.

Referenced by LIB_PIN::GetMenuImage(), InitTables(), and PinTypeComboBox::PinTypeComboBox().

◆ ElectricalPinTypeGetText()

wxString ElectricalPinTypeGetText ( ELECTRICAL_PINTYPE  aType)

Definition at line 240 of file pin_type.cpp.

241{
242 if( g_pinTypesLanguage != Pgm().GetSelectedLanguageIdentifier() )
243 {
244 g_pinTypes[ELECTRICAL_PINTYPE::PT_INPUT].name = _( "Input" );
245 g_pinTypes[ELECTRICAL_PINTYPE::PT_OUTPUT].name = _( "Output" );
246 g_pinTypes[ELECTRICAL_PINTYPE::PT_BIDI].name = _( "Bidirectional" );
247 g_pinTypes[ELECTRICAL_PINTYPE::PT_TRISTATE].name = _( "Tri-state" );
248 g_pinTypes[ELECTRICAL_PINTYPE::PT_PASSIVE].name = _( "Passive" );
249 g_pinTypes[ELECTRICAL_PINTYPE::PT_NIC].name = _( "Free" );
250 g_pinTypes[ELECTRICAL_PINTYPE::PT_UNSPECIFIED].name = _( "Unspecified" );
251 g_pinTypes[ELECTRICAL_PINTYPE::PT_POWER_IN].name = _( "Power input" );
252 g_pinTypes[ELECTRICAL_PINTYPE::PT_POWER_OUT].name = _( "Power output" );
253 g_pinTypes[ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR].name = _( "Open collector" );
254 g_pinTypes[ELECTRICAL_PINTYPE::PT_OPENEMITTER].name = _( "Open emitter" );
255 g_pinTypes[ELECTRICAL_PINTYPE::PT_NC].name = _( "Unconnected" );
256
257 g_pinTypesLanguage = Pgm().GetSelectedLanguageIdentifier();
258 }
259
260 auto findIt = g_pinTypes.find( aType );
261
262 wxCHECK_MSG( findIt != g_pinTypes.end(), wxT( "???" ), wxT( "Pin type not found!" ) );
263
264 return findIt->second.name;
265}
#define _(s)
int g_pinTypesLanguage
Definition: pin_type.cpp:67
@ PT_INPUT
usual pin input: must be connected
@ PT_NC
not connected (must be left open)
@ PT_OUTPUT
usual output
@ PT_TRISTATE
tris state bus pin
@ PT_NIC
not internally connected (may be connected to anything)
@ PT_BIDI
input or output (like port for a microprocessor)
@ PT_OPENEMITTER
pin type open emitter
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
@ PT_OPENCOLLECTOR
pin type open collector
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References _, g_pinTypes, g_pinTypesLanguage, Pgm(), PT_BIDI, PT_INPUT, PT_NC, PT_NIC, PT_OPENCOLLECTOR, PT_OPENEMITTER, PT_OUTPUT, PT_PASSIVE, PT_POWER_IN, PT_POWER_OUT, PT_TRISTATE, and PT_UNSPECIFIED.

Referenced by LIB_PIN::GetElectricalTypeName(), LIB_PIN::GetMsgPanelInfo(), SCH_PIN::GetMsgPanelInfo(), InitTables(), PinTypeComboBox::PinTypeComboBox(), and ERC_TESTER::TestPinToPin().

◆ InitTables()

void InitTables ( )

Definition at line 164 of file pin_type.cpp.

165{
166 for( unsigned i = 0; i < ELECTRICAL_PINTYPES_TOTAL; ++i )
167 {
168 g_typeIcons.push_back( ElectricalPinTypeGetBitmap( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
169 g_typeNames.push_back( ElectricalPinTypeGetText( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
170 }
171
172 for( unsigned i = 0; i < GRAPHIC_PINSHAPES_TOTAL; ++i )
173 {
174 g_shapeIcons.push_back( PinShapeGetBitmap( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
175 g_shapeNames.push_back( PinShapeGetText( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
176 }
177
178 for( unsigned i = 0; i < PIN_ORIENTATION_CNT; ++i )
179 {
181 g_orientationNames.push_back( PinOrientationName( i ) );
182 }
183}
wxString PinOrientationName(unsigned aPinOrientationCode)
Definition: pin_type.cpp:119
BITMAPS PinShapeGetBitmap(GRAPHIC_PINSHAPE aShape)
Definition: pin_type.cpp:288
static const BITMAPS iconsPinsOrientations[]
Definition: pin_type.cpp:103
static std::vector< BITMAPS > g_orientationIcons
Definition: pin_type.cpp:40
static std::vector< BITMAPS > g_typeIcons
Definition: pin_type.cpp:34
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE aType)
Definition: pin_type.cpp:240
static wxArrayString g_shapeNames
Definition: pin_type.cpp:38
static wxArrayString g_typeNames
Definition: pin_type.cpp:35
BITMAPS ElectricalPinTypeGetBitmap(ELECTRICAL_PINTYPE aType)
Definition: pin_type.cpp:268
wxString PinShapeGetText(GRAPHIC_PINSHAPE aShape)
Definition: pin_type.cpp:278
#define PIN_ORIENTATION_CNT
Definition: pin_type.cpp:112
static std::vector< BITMAPS > g_shapeIcons
Definition: pin_type.cpp:37
static wxArrayString g_orientationNames
Definition: pin_type.cpp:41
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition: pin_type.h:36
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:53
#define GRAPHIC_PINSHAPES_TOTAL
Definition: pin_type.h:70
GRAPHIC_PINSHAPE
Definition: pin_type.h:56

References ELECTRICAL_PINTYPES_TOTAL, ElectricalPinTypeGetBitmap(), ElectricalPinTypeGetText(), g_orientationIcons, g_orientationNames, g_shapeIcons, g_shapeNames, g_typeIcons, g_typeNames, GRAPHIC_PINSHAPES_TOTAL, iconsPinsOrientations, PIN_ORIENTATION_CNT, PinOrientationName(), PinShapeGetBitmap(), and PinShapeGetText().

Referenced by PinOrientationIcons(), PinOrientationNames(), PinShapeIcons(), PinShapeNames(), PinTypeIcons(), and PinTypeNames().

◆ PinOrientationCode()

int PinOrientationCode ( int  index)

Definition at line 141 of file pin_type.cpp.

142{
143 if( index >= 0 && index < (int) PIN_ORIENTATION_CNT )
144 return pin_orientation_codes[ index ];
145
146 return PIN_RIGHT;
147}
@ PIN_RIGHT
Definition: lib_pin.h:46
static const int pin_orientation_codes[]
Definition: pin_type.cpp:92

References PIN_ORIENTATION_CNT, pin_orientation_codes, and PIN_RIGHT.

Referenced by DIALOG_PIN_PROPERTIES::OnPropertiesChange(), PIN_TABLE_DATA_MODEL::SetValue(), and DIALOG_PIN_PROPERTIES::TransferDataFromWindow().

◆ PinOrientationIcons()

const std::vector< BITMAPS > & PinOrientationIcons ( )

Definition at line 231 of file pin_type.cpp.

232{
233 if( g_orientationIcons.empty() )
234 InitTables();
235
236 return g_orientationIcons;
237}
void InitTables()
Definition: pin_type.cpp:164

References g_orientationIcons, and InitTables().

Referenced by DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE(), and DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES().

◆ PinOrientationIndex()

int PinOrientationIndex ( int  code)

Definition at line 150 of file pin_type.cpp.

151{
152 size_t i;
153
154 for( i = 0; i < PIN_ORIENTATION_CNT; i++ )
155 {
156 if( pin_orientation_codes[i] == code )
157 return (int) i;
158 }
159
160 return wxNOT_FOUND;
161}

References PIN_ORIENTATION_CNT, and pin_orientation_codes.

Referenced by LIB_PIN::GetMsgPanelInfo(), SCH_PIN::GetMsgPanelInfo(), PIN_TABLE_DATA_MODEL::GetValue(), and DIALOG_PIN_PROPERTIES::TransferDataToWindow().

◆ PinOrientationName()

wxString PinOrientationName ( unsigned  aPinOrientationCode)

Definition at line 119 of file pin_type.cpp.

120{
121 /* Note: The following name lists are sentence capitalized per the GNOME UI
122 * standards for list controls. Please do not change the capitalization
123 * of these strings unless the GNOME UI standards are changed.
124 */
125 const wxString pin_orientation_names[] =
126 {
127 _( "Right" ),
128 _( "Left" ),
129 _( "Up" ),
130 _( "Down" ),
131 wxT( "???" )
132 };
133
134 if( aPinOrientationCode > PIN_ORIENTATION_CNT )
135 aPinOrientationCode = PIN_ORIENTATION_CNT;
136
137 return pin_orientation_names[ aPinOrientationCode ];
138}

References _, and PIN_ORIENTATION_CNT.

Referenced by LIB_PIN::GetMsgPanelInfo(), SCH_PIN::GetMsgPanelInfo(), and InitTables().

◆ PinOrientationNames()

const wxArrayString & PinOrientationNames ( )

◆ PinShapeGetBitmap()

BITMAPS PinShapeGetBitmap ( GRAPHIC_PINSHAPE  aShape)

Definition at line 288 of file pin_type.cpp.

289{
290 auto findIt = pinShapes.find( aShape );
291
292 wxCHECK_MSG( findIt != pinShapes.end(), BITMAPS::INVALID_BITMAP, wxT( "Pin type not found!" ) );
293
294 return findIt->second.bitmap;
295}
const std::map< GRAPHIC_PINSHAPE, struct pinShapeStruct > pinShapes
Definition: pin_type.cpp:78

References INVALID_BITMAP, and pinShapes.

Referenced by InitTables(), and PinShapeComboBox::PinShapeComboBox().

◆ PinShapeGetText()

wxString PinShapeGetText ( GRAPHIC_PINSHAPE  aShape)

Definition at line 278 of file pin_type.cpp.

279{
280 auto findIt = pinShapes.find( aShape );
281
282 wxCHECK_MSG( findIt != pinShapes.end(), wxT( "?" ), wxT( "Pin type not found!" ) );
283
284 return findIt->second.name;
285}

References pinShapes.

Referenced by LIB_PIN::GetMsgPanelInfo(), SCH_PIN::GetMsgPanelInfo(), LIB_PIN::GetSelectMenuText(), InitTables(), and PinShapeComboBox::PinShapeComboBox().

◆ PinShapeIcons()

const std::vector< BITMAPS > & PinShapeIcons ( )

◆ PinShapeNames()

◆ PinTypeIcons()

const std::vector< BITMAPS > & PinTypeIcons ( )

◆ PinTypeNames()

Variable Documentation

◆ g_orientationIcons

std::vector<BITMAPS> g_orientationIcons
static

Definition at line 40 of file pin_type.cpp.

Referenced by InitTables(), and PinOrientationIcons().

◆ g_orientationNames

wxArrayString g_orientationNames
static

Definition at line 41 of file pin_type.cpp.

Referenced by InitTables(), and PinOrientationNames().

◆ g_pinTypes

std::map<ELECTRICAL_PINTYPE, struct pinTypeStruct> g_pinTypes
Initial value:
= {
{ ELECTRICAL_PINTYPE::PT_BIDI, { _( "Bidirectional" ), BITMAPS::pintype_bidi } },
}
@ pintype_notspecif
@ pintype_bidi
@ pintype_passive
@ pintype_output
@ pintype_opencoll
@ pintype_powerinput
@ pintype_noconnect
@ pintype_poweroutput
@ pintype_input
@ pintype_3states
@ pintype_openemit

Definition at line 51 of file pin_type.cpp.

Referenced by ElectricalPinTypeGetBitmap(), and ElectricalPinTypeGetText().

◆ g_pinTypesLanguage

int g_pinTypesLanguage = wxLANGUAGE_UNKNOWN

Definition at line 67 of file pin_type.cpp.

Referenced by ElectricalPinTypeGetText().

◆ g_shapeIcons

std::vector<BITMAPS> g_shapeIcons
static

Definition at line 37 of file pin_type.cpp.

Referenced by InitTables(), and PinShapeIcons().

◆ g_shapeNames

wxArrayString g_shapeNames
static

Definition at line 38 of file pin_type.cpp.

Referenced by InitTables(), and PinShapeNames().

◆ g_typeIcons

std::vector<BITMAPS> g_typeIcons
static

Definition at line 34 of file pin_type.cpp.

Referenced by InitTables(), and PinTypeIcons().

◆ g_typeNames

wxArrayString g_typeNames
static

Definition at line 35 of file pin_type.cpp.

Referenced by InitTables(), and PinTypeNames().

◆ iconsPinsOrientations

const BITMAPS iconsPinsOrientations[]
static
Initial value:

Definition at line 103 of file pin_type.cpp.

Referenced by InitTables().

◆ pin_orientation_codes

const int pin_orientation_codes[]
static
Initial value:
=
{
}
@ PIN_LEFT
Definition: lib_pin.h:47
@ PIN_UP
Definition: lib_pin.h:48
@ PIN_DOWN
Definition: lib_pin.h:49

Definition at line 92 of file pin_type.cpp.

Referenced by PinOrientationCode(), and PinOrientationIndex().

◆ pinShapes

const std::map<GRAPHIC_PINSHAPE, struct pinShapeStruct> pinShapes
Initial value:
= {
}
@ pinshape_invert
@ pinshape_clock_active_low
@ pinshape_clock_normal
@ pinshape_nonlogic
@ pinshape_clock_invert
@ pinshape_active_low_input
@ pinshape_normal
@ pinshape_active_low_output
@ pinshape_clock_fall

Definition at line 78 of file pin_type.cpp.

Referenced by PinShapeGetBitmap(), and PinShapeGetText().