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>

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
 
const std::map< ELECTRICAL_PINTYPE, struct pinTypeStructpinTypes
 
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 109 of file pin_type.cpp.

Function Documentation

◆ ElectricalPinTypeGetBitmap()

BITMAPS ElectricalPinTypeGetBitmap ( ELECTRICAL_PINTYPE  aType)

Definition at line 247 of file pin_type.cpp.

248 {
249  auto findIt = pinTypes.find( aType );
250 
251  wxCHECK_MSG( findIt != pinTypes.end(), BITMAPS::INVALID_BITMAP,
252  "Could not find pin type in lookup map" );
253 
254  return findIt->second.bitmap;
255 }
const std::map< ELECTRICAL_PINTYPE, struct pinTypeStruct > pinTypes
Definition: pin_type.cpp:50

References INVALID_BITMAP, and pinTypes.

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

◆ ElectricalPinTypeGetText()

wxString ElectricalPinTypeGetText ( ELECTRICAL_PINTYPE  aType)

Definition at line 237 of file pin_type.cpp.

238 {
239  auto findIt = pinTypes.find( aType );
240 
241  wxCHECK_MSG( findIt != pinTypes.end(), wxT( "???" ), "Could not find pin type in lookup map" );
242 
243  return findIt->second.name;
244 }
const std::map< ELECTRICAL_PINTYPE, struct pinTypeStruct > pinTypes
Definition: pin_type.cpp:50

References pinTypes.

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

◆ InitTables()

void InitTables ( )

Definition at line 161 of file pin_type.cpp.

162 {
163  for( unsigned i = 0; i < ELECTRICAL_PINTYPES_TOTAL; ++i )
164  {
165  g_typeIcons.push_back( ElectricalPinTypeGetBitmap( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
166  g_typeNames.push_back( ElectricalPinTypeGetText( static_cast<ELECTRICAL_PINTYPE>( i ) ) );
167  }
168 
169  for( unsigned i = 0; i < GRAPHIC_PINSHAPES_TOTAL; ++i )
170  {
171  g_shapeIcons.push_back( PinShapeGetBitmap( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
172  g_shapeNames.push_back( PinShapeGetText( static_cast<GRAPHIC_PINSHAPE>( i ) ) );
173  }
174 
175  for( unsigned i = 0; i < PIN_ORIENTATION_CNT; ++i )
176  {
177  g_orientationIcons.push_back( iconsPinsOrientations[ i ] );
178  g_orientationNames.push_back( PinOrientationName( i ) );
179  }
180 }
static std::vector< BITMAPS > g_typeIcons
Definition: pin_type.cpp:33
#define PIN_ORIENTATION_CNT
Definition: pin_type.cpp:109
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE aType)
Definition: pin_type.cpp:237
BITMAPS ElectricalPinTypeGetBitmap(ELECTRICAL_PINTYPE aType)
Definition: pin_type.cpp:247
wxString PinShapeGetText(GRAPHIC_PINSHAPE aShape)
Definition: pin_type.cpp:258
static std::vector< BITMAPS > g_orientationIcons
Definition: pin_type.cpp:39
wxString PinOrientationName(unsigned aPinOrientationCode)
Definition: pin_type.cpp:116
static std::vector< BITMAPS > g_shapeIcons
Definition: pin_type.cpp:36
#define GRAPHIC_PINSHAPES_TOTAL
Definition: pin_type.h:70
static wxArrayString g_shapeNames
Definition: pin_type.cpp:37
static wxArrayString g_orientationNames
Definition: pin_type.cpp:40
BITMAPS PinShapeGetBitmap(GRAPHIC_PINSHAPE aShape)
Definition: pin_type.cpp:268
static wxArrayString g_typeNames
Definition: pin_type.cpp:34
#define ELECTRICAL_PINTYPES_TOTAL
Definition: pin_type.h:53
static const BITMAPS iconsPinsOrientations[]
Definition: pin_type.cpp:100

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 138 of file pin_type.cpp.

139 {
140  if( index >= 0 && index < (int) PIN_ORIENTATION_CNT )
141  return pin_orientation_codes[ index ];
142 
143  return PIN_RIGHT;
144 }
#define PIN_ORIENTATION_CNT
Definition: pin_type.cpp:109
static const int pin_orientation_codes[]
Definition: pin_type.cpp:89

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 228 of file pin_type.cpp.

229 {
230  if( g_orientationIcons.empty() )
231  InitTables();
232 
233  return g_orientationIcons;
234 }
void InitTables()
Definition: pin_type.cpp:161
static std::vector< BITMAPS > g_orientationIcons
Definition: pin_type.cpp:39

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 147 of file pin_type.cpp.

148 {
149  size_t i;
150 
151  for( i = 0; i < PIN_ORIENTATION_CNT; i++ )
152  {
153  if( pin_orientation_codes[i] == code )
154  return (int) i;
155  }
156 
157  return wxNOT_FOUND;
158 }
#define PIN_ORIENTATION_CNT
Definition: pin_type.cpp:109
static const int pin_orientation_codes[]
Definition: pin_type.cpp:89

References PIN_ORIENTATION_CNT, and pin_orientation_codes.

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

◆ PinOrientationName()

wxString PinOrientationName ( unsigned  aPinOrientationCode)

Definition at line 116 of file pin_type.cpp.

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

References _, and PIN_ORIENTATION_CNT.

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

◆ PinOrientationNames()

const wxArrayString& PinOrientationNames ( )

Definition at line 219 of file pin_type.cpp.

220 {
221  if( g_orientationNames.empty() )
222  InitTables();
223 
224  return g_orientationNames;
225 }
void InitTables()
Definition: pin_type.cpp:161
static wxArrayString g_orientationNames
Definition: pin_type.cpp:40

References g_orientationNames, and InitTables().

Referenced by DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE(), DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES(), PIN_TABLE_DATA_MODEL::GetValue(), and PIN_TABLE_DATA_MODEL::SetValue().

◆ PinShapeGetBitmap()

BITMAPS PinShapeGetBitmap ( GRAPHIC_PINSHAPE  aShape)

Definition at line 268 of file pin_type.cpp.

269 {
270  auto findIt = pinShapes.find( aShape );
271 
272  wxCHECK_MSG( findIt != pinShapes.end(), BITMAPS::INVALID_BITMAP,
273  "Could not find pinshape in lookup map" );
274 
275  return findIt->second.bitmap;
276 }
const std::map< GRAPHIC_PINSHAPE, struct pinShapeStruct > pinShapes
Definition: pin_type.cpp:75

References INVALID_BITMAP, and pinShapes.

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

◆ PinShapeGetText()

wxString PinShapeGetText ( GRAPHIC_PINSHAPE  aShape)

Definition at line 258 of file pin_type.cpp.

259 {
260  auto findIt = pinShapes.find( aShape );
261 
262  wxCHECK_MSG( findIt != pinShapes.end(), wxT( "?" ), "Could not find pinshape in lookup map" );
263 
264  return findIt->second.name;
265 }
const std::map< GRAPHIC_PINSHAPE, struct pinShapeStruct > pinShapes
Definition: pin_type.cpp:75

References pinShapes.

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

◆ PinShapeIcons()

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

Definition at line 210 of file pin_type.cpp.

211 {
212  if( g_shapeIcons.empty() )
213  InitTables();
214 
215  return g_shapeIcons;
216 }
void InitTables()
Definition: pin_type.cpp:161
static std::vector< BITMAPS > g_shapeIcons
Definition: pin_type.cpp:36

References g_shapeIcons, and InitTables().

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

◆ PinShapeNames()

◆ PinTypeIcons()

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

Definition at line 192 of file pin_type.cpp.

193 {
194  if( g_typeIcons.empty() )
195  InitTables();
196 
197  return g_typeIcons;
198 }
static std::vector< BITMAPS > g_typeIcons
Definition: pin_type.cpp:33
void InitTables()
Definition: pin_type.cpp:161

References g_typeIcons, and InitTables().

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

◆ PinTypeNames()

Variable Documentation

◆ g_orientationIcons

std::vector<BITMAPS> g_orientationIcons
static

Definition at line 39 of file pin_type.cpp.

Referenced by InitTables(), and PinOrientationIcons().

◆ g_orientationNames

wxArrayString g_orientationNames
static

Definition at line 40 of file pin_type.cpp.

Referenced by InitTables(), and PinOrientationNames().

◆ g_shapeIcons

std::vector<BITMAPS> g_shapeIcons
static

Definition at line 36 of file pin_type.cpp.

Referenced by InitTables(), and PinShapeIcons().

◆ g_shapeNames

wxArrayString g_shapeNames
static

Definition at line 37 of file pin_type.cpp.

Referenced by InitTables(), and PinShapeNames().

◆ g_typeIcons

std::vector<BITMAPS> g_typeIcons
static

Definition at line 33 of file pin_type.cpp.

Referenced by InitTables(), and PinTypeIcons().

◆ g_typeNames

wxArrayString g_typeNames
static

Definition at line 34 of file pin_type.cpp.

Referenced by InitTables(), and PinTypeNames().

◆ iconsPinsOrientations

◆ pin_orientation_codes

const int pin_orientation_codes[]
static
Initial value:

Definition at line 89 of file pin_type.cpp.

Referenced by PinOrientationCode(), and PinOrientationIndex().

◆ pinShapes

const std::map<GRAPHIC_PINSHAPE, struct pinShapeStruct> pinShapes

◆ pinTypes

const std::map<ELECTRICAL_PINTYPE, struct pinTypeStruct> pinTypes
Initial value:
= {
{ ELECTRICAL_PINTYPE::PT_BIDI, { _( "Bidirectional" ), BITMAPS::pintype_bidi } },
}
power input (GND, VCC for ICs). Must be connected to a power output.
pin for passive symbols: must be connected, and can be connected to any pin
unknown electrical properties: creates always a warning when connected
not internally connected (may be connected to anything)
#define _(s)
usual pin input: must be connected
input or output (like port for a microprocessor)
not connected (must be left open)
output of a regulator: intended to be connected to power input pins

Definition at line 50 of file pin_type.cpp.

Referenced by ElectricalPinTypeGetBitmap(), and ElectricalPinTypeGetText().