Commit 2ac58935 authored by Dick Hollenbeck's avatar Dick Hollenbeck

Make option KICAD_KEEPCASE actually functional for Eeschema, and make the setting default ON.

The desire is to migrate designs *away from* case independence, and to create
designs which use literally (case specific) interpreted component names. But for
backwards compatibility, you may turn OFF this option if you really must.
(Remember that with KiCad using text data files, typically you would be better
off simply doctoring those files into a case literal state with a text editor
and move forward into the brave new world of case specificity. Also, BOM
generators may not work properly when you have this option turned OFF, the xml
export's referential integrity is broken on library part name. Hence the default
is ON now, as of 29-Jan-2014.
parent 690a0016
...@@ -17,8 +17,18 @@ set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules ) ...@@ -17,8 +17,18 @@ set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
option( USE_KIWAY_DLLS option( USE_KIWAY_DLLS
"Build the major modules as DLLs or DSOs, will soon be the norm." OFF ) "Build the major modules as DLLs or DSOs, will soon be the norm." OFF )
#for those who bored with uppercase # The desire is to migrate designs *away from* case independence, and to create designs which use
option( KICAD_KEEPCASE "turn-off automatic component name conversion to uppercase if selected" ) # literally (case specific) interpreted component names. But for backwards compatibility,
# you may turn OFF this option if you really must. (Remember that with KiCad using text
# data files, typically you would be better off simply doctoring those files into
# a case literal state with a text editor and move forward into the brave new
# world of case specificity. Also, BOM generators may not work properly when you
# have this option turned OFF, the xml export's referential integrity is broken
# on library part name. Hence the default is ON now, as of 29-Jan-2014.
option( KICAD_KEEPCASE
"ON= case specific string matching on component names, OFF= match names as if they were spelt using uppercase."
ON
)
option( USE_WX_GRAPHICS_CONTEXT option( USE_WX_GRAPHICS_CONTEXT
"Use wxGraphicsContext for rendering ( default OFF). Warning, this is experimental" ) "Use wxGraphicsContext for rendering ( default OFF). Warning, this is experimental" )
......
...@@ -63,6 +63,6 @@ PCBNew ...@@ -63,6 +63,6 @@ PCBNew
Dick's Final TODO List: Dick's Final TODO List:
====================== ======================
*) Get licensing cleaned up. *) Get licensing cleaned up.
*) Re-arrange the repo architecture.
*) DLL-ization of pcbnew & eeschema *) DLL-ization of pcbnew & eeschema
http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/ http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/
https://blueprints.launchpad.net/kicad/+spec/modular-kicad
...@@ -588,7 +588,7 @@ bool LIB_COMPONENT::Save( OUTPUTFORMATTER& aFormatter ) ...@@ -588,7 +588,7 @@ bool LIB_COMPONENT::Save( OUTPUTFORMATTER& aFormatter )
// Save data // Save data
aFormatter.Print( 0, "DEF" ); aFormatter.Print( 0, "DEF" );
#if defined(DEBUG) #if 0 && defined(DEBUG)
if( value.GetText() == wxT( "R" ) ) if( value.GetText() == wxT( "R" ) )
{ {
int breakhere = 1; int breakhere = 1;
...@@ -779,7 +779,11 @@ bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg ) ...@@ -779,7 +779,11 @@ bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
if( componentName[0] != '~' ) if( componentName[0] != '~' )
{ {
m_name = FROM_UTF8( componentName ); m_name = FROM_UTF8( componentName );
#ifndef KICAD_KEEPCASE
m_name = m_name.MakeUpper(); m_name = m_name.MakeUpper();
#endif
value.SetText( m_name ); value.SetText( m_name );
} }
else else
......
...@@ -45,15 +45,31 @@ class LIB_COMPONENT; ...@@ -45,15 +45,31 @@ class LIB_COMPONENT;
class LIB_FIELD; class LIB_FIELD;
/// Compiler controlled string compare function, either case independent or not:
inline int Cmp_KEEPCASE( const wxString& aString1, const wxString& aString2 )
{
#ifdef KICAD_KEEPCASE
// case specificity:
return aString1.Cmp( aString2 );
#else
// case independence:
return aString1.CmpNoCase( aString2 );
#endif
}
/** /**
* LIB_ALIAS map sorting. * LIB_ALIAS map sorting.
*/ */
struct AliasMapSort struct AliasMapSort
{ {
bool operator() ( const wxString& aItem1, const wxString& aItem2 ) const bool operator() ( const wxString& aItem1, const wxString& aItem2 ) const
{ return aItem1.CmpNoCase( aItem2 ) < 0; } {
return Cmp_KEEPCASE( aItem1, aItem2 ) < 0;
}
}; };
/** /**
* Alias map used by component library object. * Alias map used by component library object.
*/ */
......
...@@ -45,13 +45,14 @@ ...@@ -45,13 +45,14 @@
#include <wx/regex.h> #include <wx/regex.h>
static const wxString duplicate_name_msg = static const wxString duplicate_name_msg =
_( "Library <%s> has duplicate entry name <%s>.\n\ _( "Library '%s' has duplicate entry name '%s'.\n"
This may cause some unexpected behavior when loading components into a schematic." ); "This may cause some unexpected behavior when loading components into a schematic." );
bool operator==( const CMP_LIBRARY& aLibrary, const wxString& aName ) bool operator==( const CMP_LIBRARY& aLibrary, const wxString& aName )
{ {
return aLibrary.GetName().CmpNoCase( aName ) == 0; // See our header class_libentry.h for function Cmp_KEEPCASE().
return Cmp_KEEPCASE( aLibrary.GetName(), aName ) == 0;
} }
...@@ -70,9 +71,9 @@ bool operator<( const CMP_LIBRARY& aItem1, const CMP_LIBRARY& aItem2 ) ...@@ -70,9 +71,9 @@ bool operator<( const CMP_LIBRARY& aItem1, const CMP_LIBRARY& aItem2 )
if( aItem1.IsCache() ) if( aItem1.IsCache() )
return false; return false;
/* If the sort order array isn't set, then sort alphabetically except. */ // If the sort order array isn't set, then sort alphabetically except.
if( CMP_LIBRARY::GetSortOrder().IsEmpty() ) if( CMP_LIBRARY::GetSortOrder().IsEmpty() )
return aItem1.GetName().CmpNoCase( aItem2.GetName() ) < 0; return Cmp_KEEPCASE( aItem1.GetName(), aItem2.GetName() ) < 0;
int i1 = CMP_LIBRARY::GetSortOrder().Index( aItem1.GetName(), false ); int i1 = CMP_LIBRARY::GetSortOrder().Index( aItem1.GetName(), false );
int i2 = CMP_LIBRARY::GetSortOrder().Index( aItem2.GetName(), false ); int i2 = CMP_LIBRARY::GetSortOrder().Index( aItem2.GetName(), false );
...@@ -111,6 +112,7 @@ CMP_LIBRARY::~CMP_LIBRARY() ...@@ -111,6 +112,7 @@ CMP_LIBRARY::~CMP_LIBRARY()
{ {
LIB_ALIAS* alias = (*it).second; LIB_ALIAS* alias = (*it).second;
LIB_COMPONENT* component = alias->GetComponent(); LIB_COMPONENT* component = alias->GetComponent();
alias = component->RemoveAlias( alias ); alias = component->RemoveAlias( alias );
if( alias == NULL ) if( alias == NULL )
...@@ -165,7 +167,6 @@ void CMP_LIBRARY::SearchEntryNames( std::vector<wxArrayString>& aNames, ...@@ -165,7 +167,6 @@ void CMP_LIBRARY::SearchEntryNames( std::vector<wxArrayString>& aNames,
for( it = aliases.begin(); it!=aliases.end(); it++ ) for( it = aliases.begin(); it!=aliases.end(); it++ )
{ {
if( !aKeySearch.IsEmpty() && KeyWordOk( aKeySearch, (*it).second->GetKeyWords() ) ) if( !aKeySearch.IsEmpty() && KeyWordOk( aKeySearch, (*it).second->GetKeyWords() ) )
{ {
wxArrayString item; wxArrayString item;
...@@ -226,7 +227,6 @@ bool CMP_LIBRARY::Conflicts( LIB_COMPONENT* aComponent ) ...@@ -226,7 +227,6 @@ bool CMP_LIBRARY::Conflicts( LIB_COMPONENT* aComponent )
LIB_ALIAS* CMP_LIBRARY::FindEntry( const wxString& aName ) LIB_ALIAS* CMP_LIBRARY::FindEntry( const wxString& aName )
{ {
LIB_ALIAS_MAP::iterator it = aliases.find( aName ); LIB_ALIAS_MAP::iterator it = aliases.find( aName );
if( it != aliases.end() ) if( it != aliases.end() )
...@@ -247,10 +247,19 @@ LIB_ALIAS* CMP_LIBRARY::GetFirstEntry() ...@@ -247,10 +247,19 @@ LIB_ALIAS* CMP_LIBRARY::GetFirstEntry()
LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxString& aName ) LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxString& aName )
{ {
#if 0 && defined(DEBUG)
if( !aName.Cmp( wxT( "TI_STELLARIS_BOOSTERPACK" ) ) )
{
int breakhere = 1;
(void) breakhere;
}
#endif
LIB_COMPONENT* component = NULL; LIB_COMPONENT* component = NULL;
LIB_ALIAS* entry = FindEntry( aName ); LIB_ALIAS* entry = FindEntry( aName );
if( entry != NULL ) if( entry )
component = entry->GetComponent(); component = entry->GetComponent();
return component; return component;
...@@ -259,7 +268,15 @@ LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxString& aName ) ...@@ -259,7 +268,15 @@ LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxString& aName )
bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias ) bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias )
{ {
wxASSERT( aAlias != NULL ); wxASSERT( aAlias );
#if 0 && defined(DEBUG)
if( !aAlias->GetName().Cmp( wxT( "TI_STELLARIS_BOOSTERPACK" ) ) )
{
int breakhere = 1;
(void) breakhere;
}
#endif
LIB_ALIAS_MAP::iterator it = aliases.find( aAlias->GetName() ); LIB_ALIAS_MAP::iterator it = aliases.find( aAlias->GetName() );
...@@ -281,7 +298,7 @@ bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias ) ...@@ -281,7 +298,7 @@ bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias )
LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
{ {
if( aComponent == NULL ) if( !aComponent )
return NULL; return NULL;
// Conflict detection: See if already existing aliases exist, // Conflict detection: See if already existing aliases exist,
...@@ -296,7 +313,6 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) ...@@ -296,7 +313,6 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
return NULL; return NULL;
} }
LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aComponent, this ); LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aComponent, this );
for( size_t i = 0; i < newCmp->m_aliases.size(); i++ ) for( size_t i = 0; i < newCmp->m_aliases.size(); i++ )
......
...@@ -193,10 +193,10 @@ public: ...@@ -193,10 +193,10 @@ public:
*/ */
void GetEntryNames( wxArrayString& aNames, bool aSort = true, void GetEntryNames( wxArrayString& aNames, bool aSort = true,
bool aMakeUpperCase = bool aMakeUpperCase =
#ifndef KICAD_KEEPCASE #ifdef KICAD_KEEPCASE
true
#else
false false
#else
true
#endif #endif
); );
......
...@@ -112,7 +112,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname, ...@@ -112,7 +112,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
if( aHistoryList.GetCount() ) if( aHistoryList.GetCount() )
dlg.SetComponentName( aHistoryList[0] ); dlg.SetComponentName( aHistoryList[0] );
if ( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return wxEmptyString; return wxEmptyString;
if( dlg.m_GetExtraFunction ) if( dlg.m_GetExtraFunction )
...@@ -166,7 +166,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname, ...@@ -166,7 +166,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
libEntry = CMP_LIBRARY::FindLibraryComponent( cmpName, aLibname ); libEntry = CMP_LIBRARY::FindLibraryComponent( cmpName, aLibname );
if( ( libEntry == NULL ) && allowWildSeach ) // Search with wildcard if( !libEntry && allowWildSeach ) // Search with wildcard
{ {
allowWildSeach = false; allowWildSeach = false;
wxString wildname = wxChar( '*' ) + cmpName + wxChar( '*' ); wxString wildname = wxChar( '*' ) + cmpName + wxChar( '*' );
...@@ -176,11 +176,11 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname, ...@@ -176,11 +176,11 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
if( !cmpName.IsEmpty() ) if( !cmpName.IsEmpty() )
libEntry = CMP_LIBRARY::FindLibraryComponent( cmpName, aLibname ); libEntry = CMP_LIBRARY::FindLibraryComponent( cmpName, aLibname );
if( libEntry == NULL ) if( !libEntry )
return wxEmptyString; return wxEmptyString;
} }
if( libEntry == NULL ) if( !libEntry )
{ {
msg.Printf( _( "Failed to find part <%s> in library" ), GetChars( cmpName ) ); msg.Printf( _( "Failed to find part <%s> in library" ), GetChars( cmpName ) );
DisplayError( this, msg ); DisplayError( this, msg );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment