Eeschema: Do not use ElectricPinType for SheetLabel items. ERC does not use ElectricPinType to test sheet labels, which do net have an actual electrical type property

Replace ElectricPinType by ELECTRICAL_PINTYPE as enum name to be compliant with coding style.
Enforce ELECTRICAL_PINTYPE control in methods.
This commit is contained in:
jean-pierre charras 2016-02-19 17:51:23 +01:00
parent 8a9c6f71b7
commit 37c26cba71
10 changed files with 28 additions and 26 deletions

View File

@ -173,8 +173,9 @@ NETLIST_OBJECT::NETLIST_OBJECT()
* contains this pin
*/
m_Flag = 0; /* flag used in calculations */
m_ElectricalType = 0; /* Has meaning only for Pins and hierarchical pins: electrical
* type */
m_ElectricalPinType = PIN_INPUT; /* Has meaning only for Pins: electrical type of the pin
* used to detect conflicts between pins in ERC
*/
m_netCode = 0; /* net code for all items except BUS labels because a BUS
* label has as many net codes as bus members
*/

View File

@ -105,8 +105,7 @@ public:
int m_Flag; /* flag used in calculations */
SCH_SHEET_PATH m_SheetPath; // the sheet path which contains this item
SCH_SHEET_PATH m_SheetPathInclude; // sheet path which contains the hierarchical label
int m_ElectricalType; /* Has meaning only for Pins and
* hierarchical pins: electrical type */
ELECTRICAL_PINTYPE m_ElectricalPinType; // Has meaning only for Pins: electrical type of the pin
int m_BusNetCode; /* Used for BUS connections */
int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member
* created from the BUS label ) member number.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2016 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -134,7 +134,7 @@ void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event )
int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() );
int pinLength = ValueFromString( g_UserUnit, GetLength() );
int pinShape = LIB_PIN::GetStyleCode( GetStyle() );
int pinType = GetElectricalType();
ELECTRICAL_PINTYPE pinType = GetElectricalType();
m_dummyPin->SetName( GetPinName() );
m_dummyPin->SetNameTextSize( pinNameSize );

View File

@ -64,9 +64,12 @@ public:
{
m_choiceElectricalType->SetSelection( type );
}
int GetElectricalType( void )
ELECTRICAL_PINTYPE GetElectricalType( void )
{
return m_choiceElectricalType->GetSelection();
// m_choiceElectricalType is expected having the eletrical type names
// order indentical to the ELECTRICAL_PINTYPE enum
return (ELECTRICAL_PINTYPE)m_choiceElectricalType->GetSelection();
}
void SetStyleList( const wxArrayString& list, const BITMAP_DEF* aBitmaps );

View File

@ -279,7 +279,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
return;
}
ii = aNetItemRef->m_ElectricalType;
ii = aNetItemRef->m_ElectricalPinType;
wxString string_pinnum, cmp_ref;
char ascii_buf[5];
@ -337,7 +337,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst,
if( aNetItemTst ) /* Error between 2 pins */
{
jj = aNetItemTst->m_ElectricalType;
jj = aNetItemTst->m_ElectricalPinType;
int errortype = ERCE_PIN_TO_PIN_WARNING;
if( aDiag == ERR )
@ -378,7 +378,7 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList,
int erc = OK;
/* Analysis of the table of connections. */
int ref_elect_type = aList->GetItem( aNetItemRef )->m_ElectricalType;
ELECTRICAL_PINTYPE ref_elect_type = aList->GetItem( aNetItemRef )->m_ElectricalPinType;
int local_minconn = NOC;
if( ref_elect_type == PIN_NC )
@ -476,7 +476,7 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList,
break;
case NET_PIN:
jj = aList->GetItem( netItemTst )->m_ElectricalType;
jj = aList->GetItem( netItemTst )->m_ElectricalPinType;
local_minconn = std::max( MinimalReq[ref_elect_type][jj], local_minconn );
if( netItemTst <= aNetItemRef )

View File

@ -405,13 +405,13 @@ void LIB_PIN::SetShape( int aShape )
}
void LIB_PIN::SetType( int aType )
void LIB_PIN::SetType( ELECTRICAL_PINTYPE aType )
{
if( aType < 0 )
aType = 0;
if( aType < PIN_INPUT )
aType = PIN_INPUT;
if( aType >= (int)PIN_ELECTRICAL_TYPE_CNT )
aType = PIN_ELECTRICAL_TYPE_CNT - 1;
if( aType >= PIN_NMAX )
aType = PIN_NC;
if( m_type != aType )
{

View File

@ -38,7 +38,7 @@
/**
* The component library pin object electrical types used in ERC tests.
*/
enum ElectricPinType {
enum ELECTRICAL_PINTYPE {
PIN_INPUT,
PIN_OUTPUT,
PIN_BIDI,
@ -50,7 +50,7 @@ enum ElectricPinType {
PIN_OPENCOLLECTOR,
PIN_OPENEMITTER,
PIN_NC, /* No connect */
PIN_NMAX /* End of List (no used as pin type) */
PIN_NMAX /* End of List (not used as pin type) */
};
@ -96,7 +96,7 @@ class LIB_PIN : public LIB_ITEM
int m_orientation; ///< Pin orientation (Up, Down, Left, Right)
int m_shape; ///< Bitwise ORed of pin shapes (see enum DrawPinShape)
int m_width; ///< Line width of the pin.
int m_type; ///< Electrical type of the pin. See enum ElectricPinType.
ELECTRICAL_PINTYPE m_type; ///< Electrical type of the pin. See enum ELECTRICAL_PINTYPE.
int m_attributes; ///< Set bit 0 to indicate pin is invisible.
wxString m_name;
long m_number; ///< Pin number defined as 4 ASCII characters like "12", "anod",
@ -279,7 +279,7 @@ public:
*
* @return The electrical type of the pin (see enun ElectricPinType for values).
*/
int GetType() const { return m_type; }
ELECTRICAL_PINTYPE GetType() const { return m_type; }
/**
* return a string giving the electrical type of a pin.
@ -321,9 +321,9 @@ public:
* This will also update the electrical type of the pins marked by
* EnableEditMode().
*
* @param aType - The electrical type of the pin(see enun ElectricPinType for values).
* @param aType - The electrical type of the pin(see enun ELECTRICAL_PINTYPE for values).
*/
void SetType( int aType );
void SetType( ELECTRICAL_PINTYPE aType );
/**
* Set the pin length.

View File

@ -55,7 +55,7 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
static wxPoint OldPos;
static wxPoint PinPreviousPos;
static int LastPinType = PIN_INPUT;
static ELECTRICAL_PINTYPE LastPinType = PIN_INPUT;
static int LastPinOrient = PIN_RIGHT;
static int LastPinShape = NONE;
static bool LastPinCommonConvert = false;

View File

@ -1900,7 +1900,7 @@ void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
item->m_SheetPath = *aSheetPath;
item->m_Type = NET_PIN;
item->m_Link = (SCH_ITEM*) this;
item->m_ElectricalType = pin->GetType();
item->m_ElectricalPinType = pin->GetType();
item->m_PinNum = pin->GetNumber();
item->m_Label = pin->GetName();
item->m_Start = item->m_End = pos;

View File

@ -1092,7 +1092,6 @@ void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
item->m_Comp = &m_pins[i];
item->m_Link = this;
item->m_Type = NET_SHEETLABEL;
item->m_ElectricalType = m_pins[i].GetShape();
item->m_Label = m_pins[i].GetText();
item->m_Start = item->m_End = m_pins[i].GetPosition();
aNetListItems.push_back( item );