--- eeschema/class_netlist_object.cpp | 6 +++--- eeschema/class_netlist_object.h | 8 ++++++-- eeschema/dialogs/dialog_lib_edit_pin.cpp | 2 +- eeschema/dialogs/dialog_lib_edit_pin.h | 6 +++--- eeschema/erc.cpp | 10 +++++----- eeschema/lib_pin.cpp | 26 +++++++++++------------- eeschema/lib_pin.h | 34 ++++++++++++++++---------------- eeschema/pinedit.cpp | 16 +++++++-------- eeschema/sch_component.cpp | 2 +- eeschema/sch_sheet.cpp | 2 +- 10 files changed, 56 insertions(+), 56 deletions(-)
diff --git a/eeschema/class_netlist_object.cpp b/eeschema/class_netlist_object.cpp index 5469e75..f4ae258 100644 --- a/eeschema/class_netlist_object.cpp +++ b/eeschema/class_netlist_object.cpp @@ -200,14 +200,14 @@ NETLIST_OBJECT::~NETLIST_OBJECT() } -int NETLIST_OBJECT::GetElectricalType() const +ElectricPinType NETLIST_OBJECT::GetElectricalType() const { if( m_Type == NET_PIN ) - return m_ElectricalType; + return m_ElectricalType.pin; if( IsLabelType() ) { - switch( m_ElectricalType ) + switch( m_ElectricalType.label ) { case NET_INPUT: return PIN_INPUT; diff --git a/eeschema/class_netlist_object.h b/eeschema/class_netlist_object.h index fb18cd0..cd82dc1 100644 --- a/eeschema/class_netlist_object.h +++ b/eeschema/class_netlist_object.h @@ -103,7 +103,11 @@ 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 + union + { + ElectricPinType pin; + int label; + } m_ElectricalType; /* Has meaning only for Pins and * hierarchical pins: electrical type */ int m_BusNetCode; /* Used for BUS connections */ int m_Member; /* for labels type NET_BUSLABELMEMBER ( bus member @@ -160,7 +164,7 @@ public: return m_ConnectionType; } - int GetElectricalType() const; + ElectricPinType GetElectricalType() const; /** * Set m_netNameCandidate to a connected item which will diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp index 6c205d1..74e2966 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp @@ -130,7 +130,7 @@ void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event ) int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() ); int pinLength = ValueFromString( g_UserUnit, GetLength() ); PinShape pinShape = GetStyle(); - int pinType = GetElectricalType(); + ElectricPinType pinType = GetElectricalType(); m_dummyPin->SetName( GetPinName() ); m_dummyPin->SetNameTextSize( pinNameSize ); diff --git a/eeschema/dialogs/dialog_lib_edit_pin.h b/eeschema/dialogs/dialog_lib_edit_pin.h index 057e840..9542467 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin.h +++ b/eeschema/dialogs/dialog_lib_edit_pin.h @@ -59,13 +59,13 @@ public: int GetOrientation( void ) { return m_choiceOrientation->GetSelection(); } void SetElectricalTypeList( const wxArrayString& list, const BITMAP_DEF* aBitmaps ); - void SetElectricalType( int type ) + void SetElectricalType( ElectricPinType type ) { m_choiceElectricalType->SetSelection( type ); } - int GetElectricalType( void ) + ElectricPinType GetElectricalType( void ) { - return m_choiceElectricalType->GetSelection(); + return static_cast<ElectricPinType>( m_choiceElectricalType->GetSelection() ); } void SetStyle( PinShape style ) { m_choiceStyle->SetSelection( style ); } diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 0572887..c21a253 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -224,9 +224,9 @@ int TestDuplicateSheetNames( bool aCreateMarker ) void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, int aMinConn, int aDiag ) { - SCH_MARKER* marker = NULL; - SCH_SCREEN* screen; - int ii, jj; + SCH_MARKER* marker = NULL; + SCH_SCREEN* screen; + ElectricPinType ii, jj; if( aDiag == OK ) return; @@ -359,11 +359,11 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList, int* aNetNbItems, int* aMinConnexion ) { unsigned netItemTst = aNetStart; - int jj; + ElectricPinType jj; int erc = OK; /* Analysis of the table of connections. */ - int ref_elect_type = aList->GetItem( aNetItemRef )->GetElectricalType(); + ElectricPinType ref_elect_type = aList->GetItem( aNetItemRef )->GetElectricalType(); int local_minconn = NOC; if( ref_elect_type == PIN_NC ) diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index c53ad64..58d0c48 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -90,8 +90,10 @@ static const BITMAP_DEF iconsPinsElectricalType[] = #define PIN_ELECTRICAL_TYPE_CNT DIM( iconsPinsElectricalType ) -const wxString LIB_PIN::GetCanonicalElectricalTypeName( unsigned aType ) +const wxString LIB_PIN::GetCanonicalElectricalTypeName( ElectricPinType aType ) { + assert( aType >= 0 && aType < PIN_NMAX ); + // These strings are the canonical name of the electrictal type // Not translated, no space in name, only ASCII chars. // to use when the string name must be known and well defined @@ -108,12 +110,11 @@ const wxString LIB_PIN::GetCanonicalElectricalTypeName( unsigned aType ) wxT( "power_out" ), wxT( "openCol" ), wxT( "openEm" ), - wxT( "NotConnected" ), - wxT( "???" ) + wxT( "NotConnected" ) }; if( aType > PIN_NMAX ) - aType = PIN_NMAX; + return wxT( "???" ); return msgPinElectricType[ aType ]; } @@ -144,7 +145,7 @@ static const wxString getPinOrientationName( unsigned aPinOrientationCode ) return pin_orientation_names[ aPinOrientationCode ]; } -const wxString LIB_PIN::GetElectricalTypeName( unsigned aPinsElectricalType ) +const wxString LIB_PIN::GetElectricalTypeName( ElectricPinType aPinsElectricalType ) { const wxString pin_electrical_type_names[] = { // Keep these translated strings not static @@ -158,12 +159,11 @@ const wxString LIB_PIN::GetElectricalTypeName( unsigned aPinsElectricalType ) _( "Power output" ), _( "Open collector" ), _( "Open emitter" ), - _( "Not connected" ), - wxT( "???" ) + _( "Not connected" ) }; if( aPinsElectricalType > PIN_ELECTRICAL_TYPE_CNT ) - aPinsElectricalType = PIN_ELECTRICAL_TYPE_CNT; + return wxT( "???" ); return pin_electrical_type_names[ aPinsElectricalType ]; } @@ -352,13 +352,9 @@ void LIB_PIN::SetShape( PinShape aShape ) } -void LIB_PIN::SetType( int aType ) +void LIB_PIN::SetType( ElectricPinType aType ) { - if( aType < 0 ) - aType = 0; - - if( aType >= (int)PIN_ELECTRICAL_TYPE_CNT ) - aType = PIN_ELECTRICAL_TYPE_CNT - 1; + assert( aType >= 0 && aType < PIN_NMAX ); if( m_type != aType ) { @@ -2213,7 +2209,7 @@ wxArrayString LIB_PIN::GetElectricalTypeNames( void ) wxArrayString tmp; for( unsigned ii = 0; ii < PIN_ELECTRICAL_TYPE_CNT; ii++ ) - tmp.Add( LIB_PIN::GetElectricalTypeName( ii ) ); + tmp.Add( LIB_PIN::GetElectricalTypeName( static_cast<ElectricPinType>( ii ) ) ); return tmp; } diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index bc84be6..3cfc8da 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -54,19 +54,19 @@ enum DrawPinOrient { class LIB_PIN : public LIB_ITEM { - wxPoint m_position; ///< Position of the pin. - int m_length; ///< Length of the pin. - int m_orientation; ///< Pin orientation (Up, Down, Left, Right) - PinShape m_shape; ///< Shape drawn around pin - int m_width; ///< Line width of the pin. - int m_type; ///< Electrical type of the pin. See enum ElectricPinType. - 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", - ///< "G6", or "12". It is stored as "12\0\0" and does not - ///< depend on endian type. - int m_numTextSize; - int m_nameTextSize; ///< Pin num and Pin name sizes + wxPoint m_position; ///< Position of the pin. + int m_length; ///< Length of the pin. + int m_orientation; ///< Pin orientation (Up, Down, Left, Right) + PinShape m_shape; ///< Shape drawn around pin + int m_width; ///< Line width of the pin. + ElectricPinType m_type; ///< Electrical type of the pin. See enum ElectricPinType. + 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", + ///< "G6", or "12". It is stored as "12\0\0" and does not + ///< depend on endian type. + int m_numTextSize; + int m_nameTextSize; ///< Pin num and Pin name sizes /** * Draw a pin, with or without the pin texts @@ -233,7 +233,7 @@ public: * * @return The electrical type of the pin (see enun ElectricPinType for values). */ - int GetType() const { return m_type; } + ElectricPinType GetType() const { return m_type; } /** * return a string giving the electrical type of a pin. @@ -241,7 +241,7 @@ public: * @param aType is the electrical type (see enum ElectricPinType ) * @return The electrical name for a pin type (see enun MsgPinElectricType for names). */ - static const wxString GetCanonicalElectricalTypeName( unsigned aType ); + static const wxString GetCanonicalElectricalTypeName( ElectricPinType aType ); /** * return a string giving the electrical type of the pin. @@ -258,7 +258,7 @@ public: * @param aType is the electrical type (see enum ElectricPinType ) * @return The electrical name of the pin (see enun MsgPinElectricType for names). */ - static const wxString GetElectricalTypeName( unsigned aType ); + static const wxString GetElectricalTypeName( ElectricPinType aType ); /** * return a translated string for messages giving the electrical type of the pin. @@ -277,7 +277,7 @@ public: * * @param aType - The electrical type of the pin(see enun ElectricPinType for values). */ - void SetType( int aType ); + void SetType( ElectricPinType aType ); /** * Set the pin length. diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 7be4b3d..d77b8de 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -53,14 +53,14 @@ static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC ); static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon, bool aErase ); -static wxPoint OldPos; -static wxPoint PinPreviousPos; -static int LastPinType = PIN_INPUT; -static int LastPinOrient = PIN_RIGHT; -static PinShape LastPinShape = PINSHAPE_LINE; -static bool LastPinCommonConvert = false; -static bool LastPinCommonUnit = false; -static bool LastPinVisible = true; +static wxPoint OldPos; +static wxPoint PinPreviousPos; +static ElectricPinType LastPinType = PIN_INPUT; +static int LastPinOrient = PIN_RIGHT; +static PinShape LastPinShape = PINSHAPE_LINE; +static bool LastPinCommonConvert = false; +static bool LastPinCommonUnit = false; +static bool LastPinVisible = true; // The -1 is a non-valid value to trigger delayed initialization static int LastPinLength = -1; diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 554adb9..b88df53 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1782,7 +1782,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_ElectricalType.pin = pin->GetType(); item->m_PinNum = pin->GetNumber(); item->m_Label = pin->GetName(); item->m_Start = item->m_End = pos; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 8910ad2..ad523a5 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -1096,7 +1096,7 @@ 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_ElectricalType.label = 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 );
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp