Commit 1edd8c8a authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: remove the compil option KICAD_KEEPCASE. Eeschema is now always case...

Eeschema: remove the compil option KICAD_KEEPCASE. Eeschema is now always case sensitive when seraching components in libs.
However to be compatible with old versions of Eeschema, when a search in library fails, a case insensitive search is made.
Therefore, this version should be compatible with sch files created by previous Eeschema versions compiled with KICAD_KEEPCASE = OFF
parent aa9de21c
......@@ -26,20 +26,6 @@ set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
#option( USE_KIWAY_DLLS "Build the major modules as KIFACE DLLs or DSOs, will soon be the norm." ON )
set( USE_KIWAY_DLLS true ) # this is now mandatory, the code is the same anyways, the old code is gone.
# 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" )
......@@ -245,10 +231,6 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
if( KICAD_KEEPCASE )
add_definitions( -DKICAD_KEEPCASE )
endif()
if( USE_WX_OVERLAY OR APPLE )
add_definitions( -DUSE_WX_OVERLAY )
endif()
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
......@@ -795,11 +795,6 @@ bool LIB_PART::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
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
......@@ -46,11 +46,11 @@ 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
#if 1
// case specificity:
return aString1.Cmp( aString2 );
#else
// case independence:
// case independence (no more in use)
return aString1.CmpNoCase( aString2 );
#endif
}
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
......@@ -899,6 +899,41 @@ LIB_ALIAS* PART_LIBS::FindLibraryEntry( const wxString& aName, const wxString& a
return entry;
}
/* searches all libraries in the list for an entry, using a case insensitive comparison.
* Used to find an entry, when the normal (case sensitive) search fails.
*/
LIB_ALIAS* PART_LIBS::FindLibraryNearEntry( const wxString& aEntryName,
const wxString& aLibraryName )
{
BOOST_FOREACH( PART_LIB& lib, *this )
{
if( !!aLibraryName && lib.GetName() != aLibraryName )
continue;
LIB_ALIAS* entry = lib.GetFirstEntry();
if( ! entry )
continue;
wxString first_entry_name = entry->GetName();
wxString entry_name = first_entry_name;
for( ;; )
{
if( entry_name.CmpNoCase( aEntryName ) == 0 )
return entry;
entry = lib.GetNextEntry( entry_name );
entry_name = entry->GetName();
if( first_entry_name == entry_name )
break;
}
}
return NULL;
}
int PART_LIBS::s_modify_generation = 1; // starts at 1 and goes up
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
......@@ -209,13 +209,33 @@ public:
*
* The object can be either a part or an alias.
*
* @param aEntryName - Name of entry to search for.
* @param aEntryName - Name of entry to search for (case sensitive).
* @param aLibraryName - Name of the library to search.
* @return The entry object if found, otherwise NULL.
*/
LIB_ALIAS* FindLibraryEntry( const wxString& aEntryName,
const wxString& aLibraryName = wxEmptyString );
/**
* Function FindLibraryNearEntry
* Searches all libraries in the list for an entry, using a case insensitive comparison.
* Used to find an entry, when the normal (case sensitive) search fails.
* Needed because during a long time, eeschema was using a case insensitive search.
* Therefore, for old schematics (<= 2013), or libs,
* which mixed upper case and lower case entry names, for compatibility reasons, if
* a normal search fails, this case insensitive search can be made.
* Could be also usefull also in some dialogs, when searching parts in libs.
* Remember this is a linear search, therefore slower than the normal binary search
*
* The object can be either a part or an alias.
*
* @param aEntryName - Name of entry to search for (case insensitive).
* @param aLibraryName - Name of the library to search.
* @return The entry object if found, otherwise NULL.
*/
LIB_ALIAS* FindLibraryNearEntry( const wxString& aEntryName,
const wxString& aLibraryName = wxEmptyString );
/**
* Function RemoveCacheLibrary
* removes all cache libraries from library list.
......@@ -332,13 +352,7 @@ public:
* @param aMakeUpperCase - Force entry names to upper case.
*/
void GetEntryNames( wxArrayString& aNames, bool aSort = true,
bool aMakeUpperCase =
#ifdef KICAD_KEEPCASE
false
#else
true
#endif
);
bool aMakeUpperCase = false );
/**
* Load string array with entry names matching name and/or key word.
......@@ -377,7 +391,7 @@ public:
/**
* Find entry by name.
*
* @param aName - Name of entry, case insensitive.
* @param aName - Name of entry, case sensitive.
* @return Entry if found. NULL if not found.
*/
LIB_ALIAS* FindEntry( const wxString& aName );
......@@ -388,7 +402,7 @@ public:
* This is a helper for FindEntry so casting a LIB_ALIAS pointer to
* a LIB_PART pointer is not required.
*
* @param aName - Name of part, case insensitive.
* @param aName - Name of part, case sensitive.
* @return LIB_PART* - part if found, else NULL.
*/
LIB_PART* FindPart( const wxString& aName );
......@@ -396,7 +410,7 @@ public:
/**
* Find alias by \a nName.
*
* @param aName - Name of alias, case insensitive.
* @param aName - Name of alias, case sensitive.
* @return Alias if found. NULL if not found.
*/
LIB_ALIAS* FindAlias( const wxString& aName )
......
......@@ -71,9 +71,7 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
std::vector<wxArrayString> nameList;
wxString msg;
#ifndef KICAD_KEEPCASE
BufName.MakeUpper();
#endif
// BufName.MakeUpper();
Keys.MakeUpper();
/* Review the list of libraries for counting. */
......
......@@ -226,10 +226,6 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
{
wxString newname = chipnameTextCtrl->GetValue();
#ifndef KICAD_KEEPCASE
newname.MakeUpper();
#endif
newname.Replace( wxT( " " ), wxT( "_" ) );
if( newname.IsEmpty() )
......@@ -242,10 +238,28 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
if( libs->FindLibraryEntry( newname ) == NULL )
{
wxString msg = wxString::Format( _(
"Component '%s' not found!" ),
GetChars( newname ) );
DisplayError( this, msg );
if( LIB_ALIAS* entry = libs->FindLibraryNearEntry( newname ) )
{
wxString near_name = entry->GetName();
wxString msg = wxString::Format( _(
"Component '%s' not found!\n"
"But the component '%s' exists\n"
"Do you want to use it?"),
GetChars( newname ), GetChars( near_name ) );
if( IsOK( this, msg ) )
{
chipnameTextCtrl->SetValue( near_name );
m_Cmp->SetPartName( near_name, libs );
}
}
else
{
wxString msg = wxString::Format( _(
"Component '%s' not found!" ),
GetChars( newname ) );
DisplayError( this, msg );
}
}
else // Change component from lib!
{
......
......@@ -185,10 +185,6 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
return NULL;
}
#ifndef KICAD_KEEPCASE
name.MakeUpper();
#endif
m_canvas->SetIgnoreMouseEvents( false );
m_canvas->MoveCursorToCrossHair();
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras ar wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
......@@ -32,11 +32,8 @@
#include <confirm.h>
#include <class_sch_screen.h>
#include <wxstruct.h>
#include <sch_item_struct.h>
#include <wxEeschemaStruct.h>
#include <general.h>
#include <netlist.h>
#include <class_library.h>
#include <sch_component.h>
#include <sch_sheet.h>
......@@ -69,7 +66,8 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
libCache->SetCache();
/* examine all screens (not sheets) used and build the list of components
* found in lib complex hierarchies are not a problem because we just want
* found in lib.
* Complex hierarchies are not a problem because we just want
* to know used components in libraries
*/
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
......@@ -89,6 +87,17 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
// AddPart() does first clone the part before adding.
libCache->AddPart( part );
}
else // Search for a part/alias using case insensitive search
{ // for compatibility with old versions of schematics
LIB_ALIAS* entry = libs->FindLibraryNearEntry( component->GetPartName() );
if( entry && !libCache->FindEntry( entry->GetName() ) )
{
if( LIB_PART* part = libs->FindLibPart( entry->GetName() ) )
libCache->AddPart( part );
}
}
}
}
}
......
......@@ -638,11 +638,7 @@ void LIB_EDIT_FRAME::CreateNewLibraryPart( wxCommandEvent& event )
return;
}
#ifndef KICAD_KEEPCASE
name = dlg.GetName().MakeUpper();
#else
name = dlg.GetName();
#endif
name.Replace( wxT( " " ), wxT( "_" ) );
PART_LIB* lib = GetCurLib();
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -265,6 +265,22 @@ bool SCH_COMPONENT::Resolve( PART_LIBS* aLibs )
return true;
}
// the part was not found. try to search with no case comparison
// because during a long time, Eeschema was using upper case only
// for names.
// and we could have loaded an old schematic using upper case only
// and libs using upper+lower case for lib items names
if( LIB_ALIAS* entry = aLibs->FindLibraryNearEntry( m_part_name ) )
{
// Now find the part (the lib part if we are using an alias) using
// the "near" name
if( LIB_PART* part = aLibs->FindLibPart( entry->GetName() ) )
{
m_part = part->SharedPtr();
return true;
}
}
return false;
}
......
......@@ -350,12 +350,14 @@ void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
void KICAD_MANAGER_FRAME::OnRunPcbFpEditor( wxCommandEvent& event )
{
KIWAY_PLAYER* frame = Kiway.Player( FRAME_PCB_MODULE_EDITOR, false );
if( !frame )
{
frame = Kiway.Player( FRAME_PCB_MODULE_EDITOR, true );
// frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
frame->Show( true );
}
frame->Raise();
}
......
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