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 )
option( USE_KIWAY_DLLS
"Build the major modules as DLLs or DSOs, will soon be the norm." OFF )
#for those who bored with uppercase
option( KICAD_KEEPCASE "turn-off automatic component name conversion to uppercase if selected" )
# 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.
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
"Use wxGraphicsContext for rendering ( default OFF). Warning, this is experimental" )
......
......@@ -63,6 +63,6 @@ PCBNew
Dick's Final TODO List:
======================
*) Get licensing cleaned up.
*) Re-arrange the repo architecture.
*) DLL-ization of pcbnew & eeschema
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 )
// Save data
aFormatter.Print( 0, "DEF" );
#if defined(DEBUG)
#if 0 && defined(DEBUG)
if( value.GetText() == wxT( "R" ) )
{
int breakhere = 1;
......@@ -779,7 +779,11 @@ bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
if( componentName[0] != '~' )
{
m_name = FROM_UTF8( componentName );
#ifndef KICAD_KEEPCASE
m_name = m_name.MakeUpper();
#endif
value.SetText( m_name );
}
else
......
......@@ -45,15 +45,31 @@ class LIB_COMPONENT;
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.
*/
struct AliasMapSort
{
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.
*/
......
......@@ -45,13 +45,14 @@
#include <wx/regex.h>
static const wxString duplicate_name_msg =
_( "Library <%s> has duplicate entry name <%s>.\n\
This may cause some unexpected behavior when loading components into a schematic." );
_( "Library '%s' has duplicate entry name '%s'.\n"
"This may cause some unexpected behavior when loading components into a schematic." );
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 )
if( aItem1.IsCache() )
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() )
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 i2 = CMP_LIBRARY::GetSortOrder().Index( aItem2.GetName(), false );
......@@ -111,6 +112,7 @@ CMP_LIBRARY::~CMP_LIBRARY()
{
LIB_ALIAS* alias = (*it).second;
LIB_COMPONENT* component = alias->GetComponent();
alias = component->RemoveAlias( alias );
if( alias == NULL )
......@@ -165,7 +167,6 @@ void CMP_LIBRARY::SearchEntryNames( std::vector<wxArrayString>& aNames,
for( it = aliases.begin(); it!=aliases.end(); it++ )
{
if( !aKeySearch.IsEmpty() && KeyWordOk( aKeySearch, (*it).second->GetKeyWords() ) )
{
wxArrayString item;
......@@ -226,7 +227,6 @@ bool CMP_LIBRARY::Conflicts( LIB_COMPONENT* aComponent )
LIB_ALIAS* CMP_LIBRARY::FindEntry( const wxString& aName )
{
LIB_ALIAS_MAP::iterator it = aliases.find( aName );
if( it != aliases.end() )
......@@ -247,10 +247,19 @@ LIB_ALIAS* CMP_LIBRARY::GetFirstEntry()
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_ALIAS* entry = FindEntry( aName );
if( entry != NULL )
if( entry )
component = entry->GetComponent();
return component;
......@@ -259,7 +268,15 @@ LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxString& aName )
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() );
......@@ -281,7 +298,7 @@ bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias )
LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
{
if( aComponent == NULL )
if( !aComponent )
return NULL;
// Conflict detection: See if already existing aliases exist,
......@@ -296,7 +313,6 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
return NULL;
}
LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aComponent, this );
for( size_t i = 0; i < newCmp->m_aliases.size(); i++ )
......
......@@ -193,10 +193,10 @@ public:
*/
void GetEntryNames( wxArrayString& aNames, bool aSort = true,
bool aMakeUpperCase =
#ifndef KICAD_KEEPCASE
true
#else
#ifdef KICAD_KEEPCASE
false
#else
true
#endif
);
......
......@@ -112,7 +112,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
if( aHistoryList.GetCount() )
dlg.SetComponentName( aHistoryList[0] );
if ( dlg.ShowModal() == wxID_CANCEL )
if( dlg.ShowModal() == wxID_CANCEL )
return wxEmptyString;
if( dlg.m_GetExtraFunction )
......@@ -166,7 +166,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
libEntry = CMP_LIBRARY::FindLibraryComponent( cmpName, aLibname );
if( ( libEntry == NULL ) && allowWildSeach ) // Search with wildcard
if( !libEntry && allowWildSeach ) // Search with wildcard
{
allowWildSeach = false;
wxString wildname = wxChar( '*' ) + cmpName + wxChar( '*' );
......@@ -176,11 +176,11 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
if( !cmpName.IsEmpty() )
libEntry = CMP_LIBRARY::FindLibraryComponent( cmpName, aLibname );
if( libEntry == NULL )
if( !libEntry )
return wxEmptyString;
}
if( libEntry == NULL )
if( !libEntry )
{
msg.Printf( _( "Failed to find part <%s> in library" ), GetChars( cmpName ) );
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