Commit 7e483f69 authored by Dick Hollenbeck's avatar Dick Hollenbeck

Modular KiCad Blueprint Milestone B), major portions:

  *) When kicad.exe closes a project, close any open KIFACEs so that they cannot
     get disassociated from their true PROJECT.
  *) Allow loading eeschema library editor from kicad.exe
  *) Allow loading pcbnew library editor from kicad.exe
  *) Rename LIB_COMPONENT to LIB_PART.
  *) Add class PART_LIBS, and PART_LIB.
  *) Make PART_LIBS non-global, i.e. PROJECT specific.
  *) Implement "data on demand" for PART_LIBS
  *) Implement "data on demand" for schematic SEARCH_STACK.
  *) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
  *) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
     a weak pointer.
  *) Remove all chdir() calls so projects don't need to be CWD.
  *) Romove APPEND support from OpenProjectFiles().
  *) Make OpenProjectFiles() robust, even for creating new projects.
  *) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
     and save them in the .eeschema config file, not in the project file.
  *) Fix bug with wxDir() while accessing protected dirs in kicad.exe
  *) Consolidate template copying into PROJECT class, not in kicad.exe source.
  *) Generally untangle eeschema, making its libraries not global but rather
     held in the PROJECT.
parent c6345965
...@@ -64,18 +64,13 @@ PCBNew ...@@ -64,18 +64,13 @@ PCBNew
Dick's Final TODO List: Dick's Final TODO List:
====================== ======================
*) Get licensing cleaned up. *) Milestone B of Modular KiCad Blueprint:
* Put SEARCH_STACK::LastVisitedPath() out of its misery.
*) DLL-ization of pcbnew & eeschema * Combine CVPCB into PCBNEW.
http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/
https://blueprints.launchpad.net/kicad/+spec/modular-kicad
Issues as a result of minimal testing:
* If eeschema launched from C++ project manager and does not find all libraries,
then the dialog showing the names of missing libraries is shown twice.
* Clear all/some? retained strings on project change. *) Milestone C of Modular KiCad Blueprint
* Clear the FP_LIB_TABLE when the last KIWAY_PLAYER using it is closed. * SWIG class KIWAY, PROJECT, and KIWAY_MGR and fill out KIWAY_MGR as needed.
* Implement PROJECT::Substitute().
* Other stuff in blueprint milestone.
*) Get licensing cleaned up.
Fix export gencad
\ No newline at end of file
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
void wxConfigSaveParams( wxConfigBase* aCfg, void wxConfigLoadParams( wxConfigBase* aCfg,
const PARAM_CFG_ARRAY& aList, const wxString& aGroup ) const PARAM_CFG_ARRAY& aList, const wxString& aGroup )
{ {
wxASSERT( aCfg ); wxASSERT( aCfg );
...@@ -55,32 +55,18 @@ void wxConfigSaveParams( wxConfigBase* aCfg, ...@@ -55,32 +55,18 @@ void wxConfigSaveParams( wxConfigBase* aCfg,
if( param.m_Setup ) if( param.m_Setup )
continue; continue;
if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data param.ReadParam( aCfg );
{
if( !!param.m_Ident )
aCfg->DeleteGroup( param.m_Ident );
}
else
{
param.SaveParam( aCfg );
}
} }
} }
void wxConfigLoadParams( wxConfigBase* aCfg, void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
const PARAM_CFG_ARRAY& aList, const wxString& aGroup )
{ {
wxASSERT( aCfg ); wxASSERT( aCfg );
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList ) BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
{ {
if( !!param.m_Group ) if( !param.m_Setup )
aCfg->SetPath( param.m_Group );
else
aCfg->SetPath( aGroup );
if( param.m_Setup )
continue; continue;
param.ReadParam( aCfg ); param.ReadParam( aCfg );
...@@ -88,13 +74,19 @@ void wxConfigLoadParams( wxConfigBase* aCfg, ...@@ -88,13 +74,19 @@ void wxConfigLoadParams( wxConfigBase* aCfg,
} }
void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList ) void wxConfigSaveParams( wxConfigBase* aCfg,
const PARAM_CFG_ARRAY& aList, const wxString& aGroup )
{ {
wxASSERT( aCfg ); wxASSERT( aCfg );
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList ) BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
{ {
if( !param.m_Setup ) if( !!param.m_Group )
aCfg->SetPath( param.m_Group );
else
aCfg->SetPath( aGroup );
if( param.m_Setup )
continue; continue;
if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
...@@ -110,7 +102,7 @@ void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList ) ...@@ -110,7 +102,7 @@ void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
} }
void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList ) void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
{ {
wxASSERT( aCfg ); wxASSERT( aCfg );
...@@ -119,12 +111,19 @@ void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList ) ...@@ -119,12 +111,19 @@ void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
if( !param.m_Setup ) if( !param.m_Setup )
continue; continue;
param.ReadParam( aCfg ); if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( !!param.m_Ident )
aCfg->DeleteGroup( param.m_Ident );
}
else
{
param.SaveParam( aCfg );
}
} }
} }
void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue ) void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue )
{ {
// Use a single strategy, regardless of wx version. // Use a single strategy, regardless of wx version.
......
...@@ -62,8 +62,7 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl ...@@ -62,8 +62,7 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl
// pray that aParent is either a KIWAY_PLAYER or DIALOG_SHIM derivation. // pray that aParent is either a KIWAY_PLAYER or DIALOG_SHIM derivation.
KIWAY_HOLDER* h = dynamic_cast<KIWAY_HOLDER*>( aParent ); KIWAY_HOLDER* h = dynamic_cast<KIWAY_HOLDER*>( aParent );
wxASSERT_MSG( h, // wxASSERT_MSG( h, wxT( "DIALOG_SHIM's parent is NULL or not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) );
wxT( "DIALOG_SHIM's parent is NULL or not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) );
if( h ) if( h )
SetKiway( this, &h->Kiway() ); SetKiway( this, &h->Kiway() );
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <macros.h> // DIM() #include <macros.h> // DIM()
#include <common.h> #include <common.h>
#include <project.h>
#include <confirm.h> #include <confirm.h>
#include <gr_basic.h> #include <gr_basic.h>
#include <base_struct.h> #include <base_struct.h>
...@@ -781,9 +782,11 @@ void DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog() ...@@ -781,9 +782,11 @@ void DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog()
// Called on .kicad_wks file description selection change // Called on .kicad_wks file description selection change
void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event ) void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
{ {
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
// Display a file picker dialog // Display a file picker dialog
wxFileDialog fileDialog( this, _( "Select Page Layout Descr File" ), wxFileDialog fileDialog( this, _( "Select Page Layout Descr File" ),
wxGetCwd(), GetWksFileName(), pro_dir, GetWksFileName(),
PageLayoutDescrFileWildcard, PageLayoutDescrFileWildcard,
wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST ); wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
...@@ -800,11 +803,14 @@ void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event ) ...@@ -800,11 +803,14 @@ void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
// For Win/Linux/macOS compatibility, a relative path is a good idea // For Win/Linux/macOS compatibility, a relative path is a good idea
if( fn.IsAbsolute() && fileName != GetWksFileName() ) if( fn.IsAbsolute() && fileName != GetWksFileName() )
{ {
fn.MakeRelativeTo( wxGetCwd() ); fn.MakeRelativeTo( pro_dir );
wxString msg;
msg.Printf( _( "The page layout descr filename has changed\n" wxString msg = wxString::Format( _(
"Do you want to use the relative path:\n%s"), "The page layout descr filename has changed.\n"
fn.GetFullPath().GetData() ); "Do you want to use the relative path:\n"
"'%s'" ),
GetChars( fn.GetFullPath() )
);
if( IsOK( this, msg ) ) if( IsOK( this, msg ) )
shortFileName = fn.GetFullPath(); shortFileName = fn.GetFullPath();
} }
......
...@@ -37,12 +37,14 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl ...@@ -37,12 +37,14 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
const wxArrayString& aItemHeaders, const wxArrayString& aItemHeaders,
const std::vector<wxArrayString>& aItemList, const std::vector<wxArrayString>& aItemList,
const wxString& aSelection, const wxString& aSelection,
void( *aCallBackFunction )( wxString& ), void( *aCallBackFunction )( wxString&, void* ),
void* aCallBackFunctionData,
bool aSortList ) : bool aSortList ) :
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ) EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle )
{ {
m_sortList = aSortList; m_sortList = aSortList;
m_callBackFct = aCallBackFunction; m_cb_func = aCallBackFunction;
m_cb_data = aCallBackFunctionData;
m_itemsListCp = &aItemList; m_itemsListCp = &aItemList;
for( unsigned i = 0; i < aItemHeaders.Count(); i++ ) for( unsigned i = 0; i < aItemHeaders.Count(); i++ )
...@@ -57,7 +59,7 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl ...@@ -57,7 +59,7 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
InsertItems( aItemList, 0 ); InsertItems( aItemList, 0 );
if( m_callBackFct == NULL ) if( m_cb_func == NULL )
{ {
m_messages->Show( false ); m_messages->Show( false );
m_staticTextMsg->Show( false ); m_staticTextMsg->Show( false );
...@@ -231,12 +233,11 @@ void EDA_LIST_DIALOG::onCancelClick( wxCommandEvent& event ) ...@@ -231,12 +233,11 @@ void EDA_LIST_DIALOG::onCancelClick( wxCommandEvent& event )
void EDA_LIST_DIALOG::onListItemSelected( wxListEvent& event ) void EDA_LIST_DIALOG::onListItemSelected( wxListEvent& event )
{ {
if( m_cb_func )
if( m_callBackFct )
{ {
m_messages->Clear(); m_messages->Clear();
wxString text = GetTextSelection(); wxString text = GetTextSelection();
m_callBackFct( text ); m_cb_func( text, m_cb_data );
m_messages->WriteText( text ); m_messages->WriteText( text );
} }
} }
......
...@@ -659,7 +659,7 @@ void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper, ...@@ -659,7 +659,7 @@ void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
} }
void EDA_DRAW_FRAME::ClearMsgPanel( void ) void EDA_DRAW_FRAME::ClearMsgPanel()
{ {
if( m_messagePanel == NULL ) if( m_messagePanel == NULL )
return; return;
......
...@@ -41,100 +41,6 @@ ...@@ -41,100 +41,6 @@
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/dir.h> #include <wx/dir.h>
/* List of default paths used to locate help files and KiCad library files.
*
* Under windows, KiCad search its files from the binary path file (first
* argument when running "main") So for a standard install, default paths
* are not mandatory, but they exist, just in case.
* KiCad is often installed in c:/Program Files/kicad or c:/kicad (or d: or
* e: ... ) and the directory "share" has no meaning under windows.
*
* Under linux, the problem is more complex.
* In fact there are 3 cases:
* 1 - When released in a distribution:
* binaries are in /usr/bin, KiCad libs in /usr/share/kicad/ and doc in
* /usr/share/doc/kicad/
* 2 - When compiled by an user:
* binaries also can be in /usr/local/bin, KiCad libs in
* /usr/local/share/kicad/ and doc in /usr/local/share/doc/kicad/
* 3 - When in an "universal tarball" or build for a server:
* all files are in /usr/local/kicad
* This is mandatory when KiCad is installed on a server (in a school for
* instance) because one can export /usr/local/kicad and obviously the others
* paths cannot be used (cannot be mounted by the client, because they are
* already used).
*
* in cases 1 and 2 KiCad files cannot be found from the binary path.
* in case 3 KiCad files can be found from the binary path only if this is
* a KiCad binary file which is launched.
* But if an user creates a symbolic link to the actual binary file to run
* KiCad, the binary path is not good and the defaults paths must be used
*
* Note:
* KiCad uses first the bin path lo locate KiCad tree.
* if not found KiCad uses the environment variable KICAD to find its files
* and at last KiCad uses the default paths.
* So we can export (linux and windows) the variable KICAD:
* like export KICAD=/my_path/kicad if /my_path/kicad is not a default path
*/
wxString MakeReducedFileName( const wxString& fullfilename,
const wxString& default_path,
const wxString& default_ext )
{
wxString reduced_filename = fullfilename;
wxString Cwd, ext, path;
Cwd = default_path;
ext = default_ext;
path = wxPathOnly( reduced_filename ) + UNIX_STRING_DIR_SEP;
reduced_filename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
if( Cwd.Last() != '/' )
Cwd += UNIX_STRING_DIR_SEP;
path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
#ifdef __WINDOWS__
// names are case insensitive under windows
path.MakeLower();
Cwd.MakeLower();
ext.MakeLower();
#endif
// if the path is "default_path" -> remove it
wxString root_path = path.Left( Cwd.Length() );
if( root_path == Cwd )
{
reduced_filename.Remove( 0, Cwd.Length() );
}
else // if the path is the current path -> change path to ./
{
Cwd = wxGetCwd() + UNIX_STRING_DIR_SEP;
#ifdef __WINDOWS__
Cwd.MakeLower();
#endif
Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
if( path == Cwd )
{ // the path is the current path -> path = "./"
reduced_filename.Remove( 0, Cwd.Length() );
wxString tmp = wxT( "./" ) + reduced_filename;
reduced_filename = tmp;
}
}
// remove extension if == default_ext:
if( !ext.IsEmpty() && reduced_filename.Contains( ext ) )
reduced_filename.Truncate( reduced_filename.Length() - ext.Length() );
return reduced_filename;
}
void AddDelimiterString( wxString& string ) void AddDelimiterString( wxString& string )
{ {
......
...@@ -676,16 +676,17 @@ void ParseHotkeyConfig( const wxString& data, ...@@ -676,16 +676,17 @@ void ParseHotkeyConfig( const wxString& data,
} }
/** void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList )
* Function ImportHotkeyConfigFromFile
* Prompt the user for an old hotkey file to read, and read it.
* @param aDescList = current hotkey list descr. to initialize.
*/
void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDescList )
{ {
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
wxString mask = wxT( "*." ) + ext; wxString mask = wxT( "*." ) + ext;
#if 0 // pass in the project dir as an argument
wxString path = wxPathOnly( Prj().GetProjectFullName() );
#else
wxString path = wxGetCwd(); wxString path = wxGetCwd();
#endif
wxString filename = Kiface().Name() + wxT( '.' ) + ext; wxString filename = Kiface().Name() + wxT( '.' ) + ext;
filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ), filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ),
...@@ -704,16 +705,17 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDesc ...@@ -704,16 +705,17 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDesc
} }
/** void EDA_BASE_FRAME::ExportHotkeyConfigToFile( EDA_HOTKEY_CONFIG* aDescList )
* Function ExportHotkeyConfigToFile
* Prompt the user for an old hotkey file to read, and read it.
* @param aDescList = current hotkey list descr. to initialize.
*/
void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescList )
{ {
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT; wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
wxString mask = wxT( "*." ) + ext; wxString mask = wxT( "*." ) + ext;
#if 0
wxString path = wxPathOnly( Prj().GetProjectFullName() );
#else
wxString path = wxGetCwd(); wxString path = wxGetCwd();
#endif
wxString filename = Kiface().Name() + wxT( "." ) + ext; wxString filename = Kiface().Name() + wxT( "." ) + ext;
filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ), filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ),
......
...@@ -364,6 +364,8 @@ bool PGM_BASE::initPgm() ...@@ -364,6 +364,8 @@ bool PGM_BASE::initPgm()
{ {
wxFileName pgm_name( App().argv[0] ); wxFileName pgm_name( App().argv[0] );
wxConfigBase::DontCreateOnDemand();
wxInitAllImageHandlers(); wxInitAllImageHandlers();
m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) + wxGetUserId() ); m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) + wxGetUserId() );
...@@ -536,7 +538,9 @@ void PGM_BASE::saveCommonSettings() ...@@ -536,7 +538,9 @@ void PGM_BASE::saveCommonSettings()
// process startup: initPgm(), so test before using: // process startup: initPgm(), so test before using:
if( m_common_settings ) if( m_common_settings )
{ {
m_common_settings->Write( workingDirKey, wxGetCwd() ); wxString cur_dir = wxGetCwd();
m_common_settings->Write( workingDirKey, cur_dir );
} }
} }
......
...@@ -45,12 +45,13 @@ PROJECT::PROJECT() ...@@ -45,12 +45,13 @@ PROJECT::PROJECT()
void PROJECT::ElemsClear() void PROJECT::ElemsClear()
{ {
DBG( printf( "%s: clearing all _ELEMS for project %s\n", __func__, TO_UTF8( GetProjectFullName() ) );)
// careful here, this should work, but the virtual destructor may not // careful here, this should work, but the virtual destructor may not
// be in the same link image as PROJECT. // be in the same link image as PROJECT.
for( unsigned i = 0; i<DIM(m_elems); ++i ) for( unsigned i = 0; i < DIM( m_elems ); ++i )
{ {
delete m_elems[i]; SetElem( ELEM_T( i ), NULL );
m_elems[i] = NULL;
} }
} }
...@@ -63,24 +64,28 @@ PROJECT::~PROJECT() ...@@ -63,24 +64,28 @@ PROJECT::~PROJECT()
void PROJECT::SetProjectFullName( const wxString& aFullPathAndName ) void PROJECT::SetProjectFullName( const wxString& aFullPathAndName )
{ {
// Edge transitions only. This is what clears the project
// data using the Clear() function.
if( m_project_name != aFullPathAndName )
{
Clear(); // clear the data when the project changes.
DBG(printf( "%s: old:'%s' new:'%s'\n", __func__, TO_UTF8( GetProjectFullName() ), TO_UTF8( aFullPathAndName ) );)
m_project_name = aFullPathAndName; m_project_name = aFullPathAndName;
wxASSERT( m_project_name.GetName() == NAMELESS_PROJECT || m_project_name.IsAbsolute() ); wxASSERT( m_project_name.IsAbsolute() );
#if 0
wxASSERT( m_project_name.GetExt() == ProjectFileExtension ) wxASSERT( m_project_name.GetExt() == ProjectFileExtension );
#else
m_project_name.SetExt( ProjectFileExtension );
#endif
// until multiple projects are in play, set an environment variable for the // until multiple projects are in play, set an environment variable for the
// the project pointer. // the project pointer.
{ {
wxString path = m_project_name.GetPath(); wxString path = m_project_name.GetPath();
// wxLogDebug( wxT( "Setting env %s to '%s'." ), PROJECT_VAR_NAME, GetChars( path ) );
wxSetEnv( PROJECT_VAR_NAME, path ); wxSetEnv( PROJECT_VAR_NAME, path );
} }
}
} }
...@@ -185,90 +190,63 @@ void PROJECT::SetElem( ELEM_T aIndex, _ELEM* aElem ) ...@@ -185,90 +190,63 @@ void PROJECT::SetElem( ELEM_T aIndex, _ELEM* aElem )
if( unsigned( aIndex ) < DIM( m_elems ) ) if( unsigned( aIndex ) < DIM( m_elems ) )
{ {
#if defined(DEBUG) && 0
if( aIndex == ELEM_SCH_PART_LIBS )
{
printf( "%s: &m_elems[%i]:%p aElem:%p\n", __func__, aIndex, &m_elems[aIndex], aElem );
}
#endif
delete m_elems[aIndex];
m_elems[aIndex] = aElem; m_elems[aIndex] = aElem;
} }
} }
// non-member so it can be moved easily, and kept REALLY private. static bool copy_pro_file_template( const SEARCH_STACK& aSearchS, const wxString& aDestination )
// Do NOT Clear() in here.
static void add_search_paths( SEARCH_STACK* aDst, wxConfigBase* aCfg, int aIndex )
{ {
for( int i=1; true; ++i ) wxString templateFile = wxT( "kicad." ) + ProjectFileExtension;
wxString kicad_pro_template = aSearchS.FindValidPath( templateFile );
if( !kicad_pro_template )
{
DBG( printf( "%s: template file '%s' not found using search paths.\n", __func__, TO_UTF8( templateFile ) );)
wxFileName templ( wxStandardPaths::Get().GetDocumentsDir(),
wxT( "kicad" ), ProjectFileExtension );
if( !templ.IsFileReadable() )
{ {
wxString key = wxString::Format( wxT( "LibraryPath%d" ), i ); wxString msg = wxString::Format( _(
wxString upath = aCfg->Read( key, wxEmptyString ); "Unable to find '%s' template config file." ),
GetChars( templateFile ) );
if( !upath ) DisplayError( NULL, msg );
break;
aDst->AddPaths( upath, aIndex ); return false;
} }
}
kicad_pro_template = templ.GetFullPath();
}
// non-member so it can be moved easily, and kept REALLY private. DBG( printf( "%s: using template file '%s' as project file.\n", __func__, TO_UTF8( kicad_pro_template ) );)
// Do NOT Clear() in here.
static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
{
for( unsigned i=0; i<aSrc.GetCount(); ++i )
aDst->AddPaths( aSrc[i], aIndex );
}
wxCopyFile( kicad_pro_template, aDestination );
/*
bool PROJECT::MaybeLoadProjectSettings( const std::vector<wxString>& aFileSet )
{
// @todo
return true; return true;
} }
*/
wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString& aFileName, wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList,
const wxString& aGroupName, bool aForceUseLocalConfig ) const wxString& aGroupName, const wxString& aFileName )
{ {
wxConfigBase* cfg = 0; wxConfigBase* cfg = 0;
wxString cur_pro_fn = !aFileName ? GetProjectFullName() : aFileName;
wxFileName fn = aFileName; if( wxFileName( cur_pro_fn ).IsFileReadable() )
fn.SetExt( ProjectFileExtension );
wxString cur_pro_fn = fn.GetFullPath();
// is there an edge transition, a change in m_project_filename?
if( m_project_name != cur_pro_fn )
{
m_sch_search.Clear();
// to the empty lists, add project dir as first
m_sch_search.AddPaths( fn.GetPath() );
// append all paths from aSList
add_search_paths( &m_sch_search, aSList, -1 );
// addLibrarySearchPaths( SEARCH_STACK* aSP, wxConfigBase* aCfg )
// This is undocumented, but somebody wanted to store !schematic!
// library search paths in the .kicad_common file?
add_search_paths( &m_sch_search, Pgm().CommonSettings(), -1 );
#if 1 && defined(DEBUG)
m_sch_search.Show( __func__ );
#endif
}
// Init local config filename
if( aForceUseLocalConfig || fn.FileExists() )
{ {
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString ); cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString );
cfg->DontCreateOnDemand();
if( aForceUseLocalConfig )
{
SetProjectFullName( cur_pro_fn );
return cfg;
}
/* Check the application version against the version saved in the /* Check the application version against the version saved in the
* project file. * project file.
* *
...@@ -286,12 +264,11 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString& ...@@ -286,12 +264,11 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString&
if( version > 0 ) if( version > 0 )
{ {
cfg->SetPath( wxCONFIG_PATH_SEPARATOR ); cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
SetProjectFullName( cur_pro_fn );
return cfg; return cfg;
} }
else // Version incorrect else // Version incorrect
{ {
wxLogDebug( wxT( "Project file version is zero, not using this old project file, going with template." ) ); DBG( printf( "%s: project file version is zero, not using this old project file, going with template.", __func__ );)
delete cfg; delete cfg;
cfg = 0; cfg = 0;
} }
...@@ -299,49 +276,18 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString& ...@@ -299,49 +276,18 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString&
// No suitable pro file was found, either does not exist, or is too old. // No suitable pro file was found, either does not exist, or is too old.
// Use the template kicad.pro file. Find it by using caller's SEARCH_STACK. // Use the template kicad.pro file. Find it by using caller's SEARCH_STACK.
wxString templateFile = wxT( "kicad." ) + ProjectFileExtension; copy_pro_file_template( aSList, cur_pro_fn );
wxString kicad_pro_template = aSList.FindValidPath( templateFile );
if( !kicad_pro_template )
{
wxLogDebug( wxT( "Template file <%s> not found using search paths." ),
GetChars( templateFile ) );
wxFileName templ( wxStandardPaths::Get().GetDocumentsDir(),
wxT( "kicad" ), ProjectFileExtension );
if( !templ.IsFileReadable() )
{
wxString msg = wxString::Format( _( "Unable to find %s template config file." ),
GetChars( templateFile ) );
DisplayError( NULL, msg );
return NULL;
}
kicad_pro_template = templ.GetFullPath();
}
// The project config file is not found (happens for new projects,
// or if the schematic editor is run outside an existing project
// In this case the default template (kicad.pro) is used
cur_pro_fn = kicad_pro_template;
wxLogDebug( wxT( "Use template file '%s' as project file." ), GetChars( cur_pro_fn ) );
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString ); cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString );
cfg->DontCreateOnDemand();
SetProjectFullName( cur_pro_fn );
return cfg; return cfg;
} }
void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aFileName, void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aGroupName,
const wxString& aGroupName, const PARAM_CFG_ARRAY& aParams ) const PARAM_CFG_ARRAY& aParams, const wxString& aFileName )
{ {
std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aFileName, aGroupName, true ) ); std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aGroupName, aFileName ) );
if( !cfg.get() ) if( !cfg.get() )
{ {
...@@ -373,11 +319,10 @@ void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aFileName ...@@ -373,11 +319,10 @@ void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aFileName
} }
bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName, bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aGroupName,
const wxString& aGroupName, const PARAM_CFG_ARRAY& aParams, const PARAM_CFG_ARRAY& aParams, const wxString& aForeignProjectFileName )
bool doLoadOnlyIfNew )
{ {
std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aFileName, aGroupName, false ) ); std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aGroupName, aForeignProjectFileName ) );
if( !cfg.get() ) if( !cfg.get() )
{ {
...@@ -389,11 +334,6 @@ bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName, ...@@ -389,11 +334,6 @@ bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName,
wxString timestamp = cfg->Read( wxT( "update" ) ); wxString timestamp = cfg->Read( wxT( "update" ) );
if( doLoadOnlyIfNew && timestamp.size() && timestamp == m_pro_date_and_time )
{
return false;
}
m_pro_date_and_time = timestamp; m_pro_date_and_time = timestamp;
wxConfigLoadParams( cfg.get(), aParams, aGroupName ); wxConfigLoadParams( cfg.get(), aParams, aGroupName );
...@@ -401,3 +341,17 @@ bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName, ...@@ -401,3 +341,17 @@ bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName,
return true; return true;
} }
const wxString PROJECT::AbsolutePath( const wxString& aFileName ) const
{
wxFileName fn = aFileName;
if( !fn.IsAbsolute() )
{
wxString pro_dir = wxPathOnly( GetProjectFullName() );
fn.Normalize( wxPATH_NORM_ALL, pro_dir );
}
return fn.GetFullPath();
}
...@@ -11,17 +11,39 @@ ...@@ -11,17 +11,39 @@
#endif #endif
wxString SEARCH_STACK::FilenameWithRelativePathInSearchList( const wxString& aFullFilename ) int SEARCH_STACK::Split( wxArrayString* aResult, const wxString aPathString )
{
wxStringTokenizer tokenizer( aPathString, PATH_SEPS, wxTOKEN_STRTOK );
while( tokenizer.HasMoreTokens() )
{
wxString path = tokenizer.GetNextToken();
aResult->Add( path );
}
return aResult->GetCount();
}
// Convert aRelativePath to an absolute path based on aBaseDir
static wxString base_dir( const wxString& aRelativePath, const wxString& aBaseDir )
{
wxFileName fn = aRelativePath;
if( !fn.IsAbsolute() && !!aBaseDir )
{
wxASSERT_MSG( wxFileName( aBaseDir ).IsAbsolute(), wxT( "Must pass absolute path in aBaseDir" ) );
fn.MakeRelativeTo( aBaseDir );
}
return fn.GetFullPath();
}
wxString SEARCH_STACK::FilenameWithRelativePathInSearchList(
const wxString& aFullFilename, const wxString& aBaseDir )
{ {
/* If the library path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of
* these default paths
* Note we accept only sub paths,
* not relative paths starting by ../ that are not subpaths and are outside kicad libs paths
*/
wxFileName fn = aFullFilename; wxFileName fn = aFullFilename;
wxString filename = aFullFilename; wxString filename = aFullFilename;
...@@ -33,7 +55,7 @@ wxString SEARCH_STACK::FilenameWithRelativePathInSearchList( const wxString& aFu ...@@ -33,7 +55,7 @@ wxString SEARCH_STACK::FilenameWithRelativePathInSearchList( const wxString& aFu
fn = aFullFilename; fn = aFullFilename;
// Search for the shortest subpath within 'this': // Search for the shortest subpath within 'this':
if( fn.MakeRelativeTo( (*this)[kk] ) ) if( fn.MakeRelativeTo( base_dir( (*this)[kk], aBaseDir ) ) )
{ {
if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths
continue; continue;
...@@ -52,13 +74,16 @@ wxString SEARCH_STACK::FilenameWithRelativePathInSearchList( const wxString& aFu ...@@ -52,13 +74,16 @@ wxString SEARCH_STACK::FilenameWithRelativePathInSearchList( const wxString& aFu
void SEARCH_STACK::RemovePaths( const wxString& aPaths ) void SEARCH_STACK::RemovePaths( const wxString& aPaths )
{ {
wxStringTokenizer tokenizer( aPaths, PATH_SEPS, wxTOKEN_STRTOK ); bool isCS = wxFileName::IsCaseSensitive();
wxArrayString paths;
while( tokenizer.HasMoreTokens() ) Split( &paths, aPaths );
for( unsigned i=0; i<paths.GetCount(); ++i )
{ {
wxString path = tokenizer.GetNextToken(); wxString path = paths[i];
if( Index( path, wxFileName::IsCaseSensitive() ) != wxNOT_FOUND ) if( Index( path, isCS ) != wxNOT_FOUND )
{ {
Remove( path ); Remove( path );
} }
...@@ -69,14 +94,16 @@ void SEARCH_STACK::RemovePaths( const wxString& aPaths ) ...@@ -69,14 +94,16 @@ void SEARCH_STACK::RemovePaths( const wxString& aPaths )
void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex ) void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
{ {
bool isCS = wxFileName::IsCaseSensitive(); bool isCS = wxFileName::IsCaseSensitive();
wxStringTokenizer tokenizer( aPaths, PATH_SEPS, wxTOKEN_STRTOK ); wxArrayString paths;
Split( &paths, aPaths );
// appending all of them, on large or negative aIndex // appending all of them, on large or negative aIndex
if( unsigned( aIndex ) >= GetCount() ) if( unsigned( aIndex ) >= GetCount() )
{ {
while( tokenizer.HasMoreTokens() ) for( unsigned i=0; i<paths.GetCount(); ++i )
{ {
wxString path = tokenizer.GetNextToken(); wxString path = paths[i];
if( wxFileName::IsDirReadable( path ) if( wxFileName::IsDirReadable( path )
&& Index( path, isCS ) == wxNOT_FOUND ) && Index( path, isCS ) == wxNOT_FOUND )
...@@ -89,9 +116,9 @@ void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex ) ...@@ -89,9 +116,9 @@ void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
// inserting all of them: // inserting all of them:
else else
{ {
while( tokenizer.HasMoreTokens() ) for( unsigned i=0; i<paths.GetCount(); ++i )
{ {
wxString path = tokenizer.GetNextToken(); wxString path = paths[i];
if( wxFileName::IsDirReadable( path ) if( wxFileName::IsDirReadable( path )
&& Index( path, isCS ) == wxNOT_FOUND ) && Index( path, isCS ) == wxNOT_FOUND )
...@@ -104,6 +131,8 @@ void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex ) ...@@ -104,6 +131,8 @@ void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
} }
#if 1 // this function is too convoluted for words.
const wxString SEARCH_STACK::LastVisitedPath( const wxString& aSubPathToSearch ) const wxString SEARCH_STACK::LastVisitedPath( const wxString& aSubPathToSearch )
{ {
wxString path; wxString path;
...@@ -142,6 +171,7 @@ const wxString SEARCH_STACK::LastVisitedPath( const wxString& aSubPathToSearch ) ...@@ -142,6 +171,7 @@ const wxString SEARCH_STACK::LastVisitedPath( const wxString& aSubPathToSearch )
return path; return path;
} }
#endif
#if defined(DEBUG) #if defined(DEBUG)
......
...@@ -270,20 +270,6 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) ...@@ -270,20 +270,6 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
argv1.MakeAbsolute(); argv1.MakeAbsolute();
argSet[0] = argv1.GetFullPath(); argSet[0] = argv1.GetFullPath();
if( !Pgm().LockFile( argSet[0] ) )
{
wxLogSysError( _( "This file is already open." ) );
return false;
}
}
// @todo: setting CWD is taboo in a multi-project environment, this
// will not be possible soon.
if( argv1.GetPath().size() ) // path only
{
// wxSetWorkingDirectory() does not like empty paths
wxSetWorkingDirectory( argv1.GetPath() );
} }
// Use the KIWAY_PLAYER::OpenProjectFiles() API function: // Use the KIWAY_PLAYER::OpenProjectFiles() API function:
...@@ -298,24 +284,6 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) ...@@ -298,24 +284,6 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
return false; return false;
} }
} }
else
{
/*
The lean single_top program launcher has no access to program
settings, for if it did, it would not be lean. That kind of
functionality is in the KIFACE now, but it cannot assume that it is
the only KIFACE in memory. So this looks like a dead concept here,
or an expensive one in terms of code size.
wxString dir;
if( m_pgmSettings->Read( workingDirKey, &dir ) && wxDirExists( dir ) )
{
wxSetWorkingDirectory( dir );
}
*/
}
frame->Show(); frame->Show();
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <fctsys.h> #include <fctsys.h>
#include <common.h> #include <common.h>
#include <kiface_i.h>
#include <project.h> #include <project.h>
#include <confirm.h> #include <confirm.h>
#include <gestfich.h> #include <gestfich.h>
...@@ -91,7 +92,8 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event ) ...@@ -91,7 +92,8 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
char Line[1024]; char Line[1024];
FILE* file; FILE* file;
size_t ii; size_t ii;
SEARCH_STACK& search = Prj().SchSearchS();
SEARCH_STACK& search = Kiface().KifaceSearch();
if( m_netlist.IsEmpty() ) if( m_netlist.IsEmpty() )
return; return;
......
...@@ -59,30 +59,25 @@ PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters() ...@@ -59,30 +59,25 @@ PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters()
} }
void CVPCB_MAINFRAME::LoadProjectFile( const wxString& aFileName ) void CVPCB_MAINFRAME::LoadProjectFile()
{ {
wxFileName fn( aFileName );
PROJECT& prj = Prj(); PROJECT& prj = Prj();
m_ModuleLibNames.Clear(); m_ModuleLibNames.Clear();
m_AliasLibNames.Clear(); m_AliasLibNames.Clear();
fn.SetExt( ProjectFileExtension );
// was: Pgm().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false ); // was: Pgm().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
prj.ConfigLoad( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_CVP, GetProjectFileParameters(), false ); prj.ConfigLoad( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters() );
if( m_NetlistFileExtension.IsEmpty() ) if( m_NetlistFileExtension.IsEmpty() )
m_NetlistFileExtension = wxT( "net" ); m_NetlistFileExtension = wxT( "net" );
// Force FP_LIB_TABLE to be loaded on demand.
prj.ElemClear( PROJECT::ELEM_FPTBL );
} }
void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent ) void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
{ {
wxFileName fn = m_NetlistFileName; PROJECT& prj = Prj();
wxFileName fn = prj.AbsolutePath( m_NetlistFileName.GetFullPath() );
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
...@@ -103,11 +98,8 @@ void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent ) ...@@ -103,11 +98,8 @@ void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
if( !IsWritable( fn ) ) if( !IsWritable( fn ) )
return; return;
// was: wxString pro_name = fn.GetFullPath();
// Pgm().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
PROJECT& prj = Prj();
prj.ConfigSave( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_CVP, GetProjectFileParameters() ); prj.ConfigSave( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters(), pro_name );
} }
...@@ -217,7 +217,7 @@ public: ...@@ -217,7 +217,7 @@ public:
* Function LoadProjectFile * Function LoadProjectFile
* reads the configuration parameter from the project (.pro) file \a aFileName * reads the configuration parameter from the project (.pro) file \a aFileName
*/ */
void LoadProjectFile( const wxString& aFileName ); void LoadProjectFile();
void LoadSettings( wxConfigBase* aCfg ); // override virtual void LoadSettings( wxConfigBase* aCfg ); // override virtual
......
...@@ -169,7 +169,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles() ...@@ -169,7 +169,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
if( m_compListBox == NULL ) if( m_compListBox == NULL )
return false; return false;
LoadProjectFile( m_NetlistFileName.GetFullPath() ); LoadProjectFile();
LoadFootprintFiles(); LoadFootprintFiles();
BuildFOOTPRINTS_LISTBOX(); BuildFOOTPRINTS_LISTBOX();
......
...@@ -95,18 +95,18 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, ...@@ -95,18 +95,18 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
// Set sheet number and number of sheets. // Set sheet number and number of sheets.
SetSheetNumberAndCount(); SetSheetNumberAndCount();
/* Build component list */ // Build component list
if( aAnnotateSchematic ) if( aAnnotateSchematic )
{ {
sheets.GetComponents( references ); sheets.GetComponents( Prj().SchLibs(), references );
} }
else else
{ {
m_CurrentSheet->GetComponents( references ); m_CurrentSheet->GetComponents( Prj().SchLibs(), references );
} }
/* Break full components reference in name (prefix) and number: // Break full components reference in name (prefix) and number:
* example: IC1 become IC, and 1 */ // example: IC1 become IC, and 1
references.SplitReferences(); references.SplitReferences();
switch( aSortOption ) switch( aSortOption )
...@@ -172,15 +172,15 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, ...@@ -172,15 +172,15 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
int SCH_EDIT_FRAME::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly ) int SCH_EDIT_FRAME::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly )
{ {
/* build the screen list */ // build the screen list
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST SheetList;
SCH_REFERENCE_LIST ComponentsList; SCH_REFERENCE_LIST ComponentsList;
/* Build the list of components */ // Build the list of components
if( !aOneSheetOnly ) if( !aOneSheetOnly )
SheetList.GetComponents( ComponentsList ); SheetList.GetComponents( Prj().SchLibs(), ComponentsList );
else else
m_CurrentSheet->GetComponents( ComponentsList ); m_CurrentSheet->GetComponents( Prj().SchLibs(), ComponentsList );
return ComponentsList.CheckAnnotation( aMessageList ); return ComponentsList.CheckAnnotation( aMessageList );
} }
...@@ -54,7 +54,7 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef ...@@ -54,7 +54,7 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef
SCH_SHEET_LIST sheets; SCH_SHEET_LIST sheets;
bool isChanged = false; bool isChanged = false;
sheets.GetComponents( refs, false ); sheets.GetComponents( Prj().SchLibs(), refs, false );
DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) ); DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) );
PTREE doc; PTREE doc;
...@@ -98,7 +98,7 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef ...@@ -98,7 +98,7 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef
// We have found a candidate. // We have found a candidate.
// Note: it can be not unique (multiple parts per package) // Note: it can be not unique (multiple parts per package)
// So we *do not* stop the search here // So we *do not* stop the search here
SCH_COMPONENT* component = refs[ii].GetComponent(); SCH_COMPONENT* component = refs[ii].GetComp();
SCH_FIELD* fpfield = component->GetField( FOOTPRINT ); SCH_FIELD* fpfield = component->GetField( FOOTPRINT );
const wxString& oldfp = fpfield->GetText(); const wxString& oldfp = fpfield->GetText();
...@@ -133,9 +133,9 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam ...@@ -133,9 +133,9 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
{ {
// Build a flat list of components in schematic: // Build a flat list of components in schematic:
SCH_REFERENCE_LIST referencesList; SCH_REFERENCE_LIST referencesList;
SCH_SHEET_LIST SheetList; SCH_SHEET_LIST sheetList;
SheetList.GetComponents( referencesList, false ); sheetList.GetComponents( Prj().SchLibs(), referencesList, false );
FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) ); FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) );
if( cmpFile == NULL ) if( cmpFile == NULL )
...@@ -196,9 +196,9 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam ...@@ -196,9 +196,9 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
if( Cmp_KEEPCASE( reference, referencesList[ii].GetRef() ) == 0 ) if( Cmp_KEEPCASE( reference, referencesList[ii].GetRef() ) == 0 )
{ {
// We have found a candidate. // We have found a candidate.
// Note: it can be not unique (multiple parts per package) // Note: it can be not unique (multiple units per part)
// So we *do not* stop the search here // So we *do not* stop the search here
SCH_COMPONENT* component = referencesList[ii].GetComponent(); SCH_COMPONENT* component = referencesList[ii].GetComp();
SCH_FIELD* fpfield = component->GetField( FOOTPRINT ); SCH_FIELD* fpfield = component->GetField( FOOTPRINT );
fpfield->SetText( footprint ); fpfield->SetText( footprint );
...@@ -218,7 +218,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam ...@@ -218,7 +218,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile() bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile()
{ {
wxString path = wxGetCwd(); wxString path = wxPathOnly( Prj().GetProjectFullName() );
wxFileDialog dlg( this, _( "Load Component-Footprint Link File" ), wxFileDialog dlg( this, _( "Load Component-Footprint Link File" ),
path, wxEmptyString, path, wxEmptyString,
......
...@@ -109,12 +109,12 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -109,12 +109,12 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
break; break;
case BLOCK_DRAG: case BLOCK_DRAG: // Drag
case BLOCK_DRAG_ITEM: case BLOCK_DRAG_ITEM:
case BLOCK_MOVE: case BLOCK_MOVE: // Move
case BLOCK_COPY: case BLOCK_COPY: // Copy
if ( m_component ) if( GetCurPart() )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate, ItemCount = GetCurPart()->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert, m_unit, m_convert,
m_editPinsPerPartOrConvert ); m_editPinsPerPartOrConvert );
if( ItemCount ) if( ItemCount )
...@@ -139,57 +139,56 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -139,57 +139,56 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
break; break;
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: // Delete
if ( m_component ) if( GetCurPart() )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate, ItemCount = GetCurPart()->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert, m_unit, m_convert,
m_editPinsPerPartOrConvert ); m_editPinsPerPartOrConvert );
if( ItemCount ) if( ItemCount )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( GetCurPart() );
if ( m_component ) if( GetCurPart() )
{ {
m_component->DeleteSelectedItems(); GetCurPart()->DeleteSelectedItems();
OnModify(); OnModify();
} }
break; break;
case BLOCK_SAVE: /* Save */ case BLOCK_SAVE: // Save
case BLOCK_PASTE: case BLOCK_PASTE:
case BLOCK_FLIP: case BLOCK_FLIP:
break; break;
case BLOCK_ROTATE: case BLOCK_ROTATE:
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
if ( m_component ) if( GetCurPart() )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate, ItemCount = GetCurPart()->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert, m_unit, m_convert,
m_editPinsPerPartOrConvert ); m_editPinsPerPartOrConvert );
if( ItemCount ) if( ItemCount )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( GetCurPart() );
pt = GetScreen()->m_BlockLocate.Centre(); pt = GetScreen()->m_BlockLocate.Centre();
pt = GetNearestGridPosition( pt ); pt = GetNearestGridPosition( pt );
NEGATE( pt.y ); NEGATE( pt.y );
if ( m_component ) if( GetCurPart() )
{ {
OnModify(); OnModify();
int block_cmd = GetScreen()->m_BlockLocate.GetCommand(); int block_cmd = GetScreen()->m_BlockLocate.GetCommand();
if( block_cmd == BLOCK_MIRROR_Y) if( block_cmd == BLOCK_MIRROR_Y)
m_component->MirrorSelectedItemsH( pt ); GetCurPart()->MirrorSelectedItemsH( pt );
else if( block_cmd == BLOCK_MIRROR_X) else if( block_cmd == BLOCK_MIRROR_X)
m_component->MirrorSelectedItemsV( pt ); GetCurPart()->MirrorSelectedItemsV( pt );
else if( block_cmd == BLOCK_ROTATE ) else if( block_cmd == BLOCK_ROTATE )
m_component->RotateSelectedItems( pt ); GetCurPart()->RotateSelectedItems( pt );
} }
break; break;
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: // Window Zoom
Window_Zoom( GetScreen()->m_BlockLocate ); Window_Zoom( GetScreen()->m_BlockLocate );
break; break;
...@@ -200,10 +199,10 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -200,10 +199,10 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
break; break;
} }
if( ! nextCmd ) if( !nextCmd )
{ {
if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY && m_component ) if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY && GetCurPart() )
m_component->ClearSelectedItems(); GetCurPart()->ClearSelectedItems();
GetScreen()->m_BlockLocate.SetState( STATE_NO_BLOCK ); GetScreen()->m_BlockLocate.SetState( STATE_NO_BLOCK );
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE ); GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
...@@ -233,62 +232,62 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) ...@@ -233,62 +232,62 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
case BLOCK_IDLE: case BLOCK_IDLE:
break; break;
case BLOCK_DRAG: case BLOCK_DRAG: // Drag
case BLOCK_DRAG_ITEM: case BLOCK_DRAG_ITEM:
case BLOCK_MOVE: case BLOCK_MOVE: // Move
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: // Move with preselection list
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
if ( m_component ) if( GetCurPart() )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( GetCurPart() );
pt = GetScreen()->m_BlockLocate.GetMoveVector(); pt = GetScreen()->m_BlockLocate.GetMoveVector();
pt.y *= -1; pt.y *= -1;
if ( m_component ) if( GetCurPart() )
m_component->MoveSelectedItems( pt ); GetCurPart()->MoveSelectedItems( pt );
m_canvas->Refresh( true ); m_canvas->Refresh( true );
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: // Copy
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
if ( m_component ) if( GetCurPart() )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( GetCurPart() );
pt = GetScreen()->m_BlockLocate.GetMoveVector(); pt = GetScreen()->m_BlockLocate.GetMoveVector();
NEGATE( pt.y ); NEGATE( pt.y );
if ( m_component ) if( GetCurPart() )
m_component->CopySelectedItems( pt ); GetCurPart()->CopySelectedItems( pt );
break; break;
case BLOCK_PASTE: /* Paste (recopy the last block saved) */ case BLOCK_PASTE: // Paste (recopy the last block saved)
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
case BLOCK_ROTATE: // Invert by popup menu, from block move case BLOCK_ROTATE: // Invert by popup menu, from block move
case BLOCK_MIRROR_X: // Invert by popup menu, from block move case BLOCK_MIRROR_X: // Invert by popup menu, from block move
case BLOCK_MIRROR_Y: // Invert by popup menu, from block move case BLOCK_MIRROR_Y: // Invert by popup menu, from block move
if ( m_component ) if( GetCurPart() )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( GetCurPart() );
pt = GetScreen()->m_BlockLocate.Centre(); pt = GetScreen()->m_BlockLocate.Centre();
pt = GetNearestGridPosition( pt ); pt = GetNearestGridPosition( pt );
NEGATE( pt.y ); NEGATE( pt.y );
if ( m_component ) if( GetCurPart() )
{ {
int block_cmd = GetScreen()->m_BlockLocate.GetCommand(); int block_cmd = GetScreen()->m_BlockLocate.GetCommand();
if( block_cmd == BLOCK_MIRROR_Y) if( block_cmd == BLOCK_MIRROR_Y)
m_component->MirrorSelectedItemsH( pt ); GetCurPart()->MirrorSelectedItemsH( pt );
else if( block_cmd == BLOCK_MIRROR_X) else if( block_cmd == BLOCK_MIRROR_X)
m_component->MirrorSelectedItemsV( pt ); GetCurPart()->MirrorSelectedItemsV( pt );
else if( block_cmd == BLOCK_ROTATE ) else if( block_cmd == BLOCK_ROTATE )
m_component->RotateSelectedItems( pt ); GetCurPart()->RotateSelectedItems( pt );
} }
break; break;
...@@ -326,7 +325,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& ...@@ -326,7 +325,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent(); LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
wxASSERT( parent != NULL ); wxASSERT( parent != NULL );
LIB_COMPONENT* component = parent->GetComponent(); LIB_PART* component = parent->GetCurPart();
if( component == NULL ) if( component == NULL )
return; return;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -291,7 +291,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId ) ...@@ -291,7 +291,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
int LastReferenceNumber = 0; int LastReferenceNumber = 0;
int NumberOfUnits, Unit; int NumberOfUnits, Unit;
/* Components with an invisible reference (power...) always are re-annotated. */ // Components with an invisible reference (power...) always are re-annotated.
ResetHiddenReferences(); ResetHiddenReferences();
/* calculate index of the first component with the same reference prefix /* calculate index of the first component with the same reference prefix
...@@ -301,7 +301,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId ) ...@@ -301,7 +301,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
*/ */
unsigned first = 0; unsigned first = 0;
/* calculate the last used number for this reference prefix: */ // calculate the last used number for this reference prefix:
#ifdef USE_OLD_ALGO #ifdef USE_OLD_ALGO
int minRefId = 0; int minRefId = 0;
...@@ -330,7 +330,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId ) ...@@ -330,7 +330,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
if( ( componentFlatList[first].CompareRef( componentFlatList[ii] ) != 0 ) if( ( componentFlatList[first].CompareRef( componentFlatList[ii] ) != 0 )
|| ( aUseSheetNum && ( componentFlatList[first].m_SheetNum != componentFlatList[ii].m_SheetNum ) ) ) || ( aUseSheetNum && ( componentFlatList[first].m_SheetNum != componentFlatList[ii].m_SheetNum ) ) )
{ {
/* New reference found: we need a new ref number for this reference */ // New reference found: we need a new ref number for this reference
first = ii; first = ii;
#ifdef USE_OLD_ALGO #ifdef USE_OLD_ALGO
minRefId = 0; minRefId = 0;
...@@ -352,7 +352,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId ) ...@@ -352,7 +352,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
} }
// Annotation of one part per package components (trivial case). // Annotation of one part per package components (trivial case).
if( componentFlatList[ii].GetLibComponent()->GetPartCount() <= 1 ) if( componentFlatList[ii].GetLibComponent()->GetUnitCount() <= 1 )
{ {
if( componentFlatList[ii].m_IsNew ) if( componentFlatList[ii].m_IsNew )
{ {
...@@ -370,8 +370,8 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId ) ...@@ -370,8 +370,8 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
continue; continue;
} }
/* Annotation of multi-part components ( n parts per package ) (complex case) */ // Annotation of multi-unit parts ( n units per part ) (complex case)
NumberOfUnits = componentFlatList[ii].GetLibComponent()->GetPartCount(); NumberOfUnits = componentFlatList[ii].GetLibComponent()->GetUnitCount();
if( componentFlatList[ii].m_IsNew ) if( componentFlatList[ii].m_IsNew )
{ {
...@@ -382,7 +382,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId ) ...@@ -382,7 +382,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
#endif #endif
componentFlatList[ii].m_NumRef = LastReferenceNumber; componentFlatList[ii].m_NumRef = LastReferenceNumber;
if( !componentFlatList[ii].IsPartsLocked() ) if( !componentFlatList[ii].IsUnitsLocked() )
componentFlatList[ii].m_Unit = 1; componentFlatList[ii].m_Unit = 1;
componentFlatList[ii].m_Flag = 1; componentFlatList[ii].m_Flag = 1;
...@@ -400,9 +400,9 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId ) ...@@ -400,9 +400,9 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
int found = FindUnit( ii, Unit ); int found = FindUnit( ii, Unit );
if( found >= 0 ) if( found >= 0 )
continue; /* this unit exists for this reference (unit already annotated) */ continue; // this unit exists for this reference (unit already annotated)
/* Search a component to annotate ( same prefix, same value, not annotated) */ // Search a component to annotate ( same prefix, same value, not annotated)
for( unsigned jj = ii + 1; jj < componentFlatList.size(); jj++ ) for( unsigned jj = ii + 1; jj < componentFlatList.size(); jj++ )
{ {
if( componentFlatList[jj].m_Flag ) // already tested if( componentFlatList[jj].m_Flag ) // already tested
...@@ -420,8 +420,8 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId ) ...@@ -420,8 +420,8 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
if( !componentFlatList[jj].m_IsNew ) if( !componentFlatList[jj].m_IsNew )
continue; continue;
/* Component without reference number found, annotate it if possible */ // Component without reference number found, annotate it if possible
if( !componentFlatList[jj].IsPartsLocked() if( !componentFlatList[jj].IsUnitsLocked()
|| ( componentFlatList[jj].m_Unit == Unit ) ) || ( componentFlatList[jj].m_Unit == Unit ) )
{ {
componentFlatList[jj].m_NumRef = componentFlatList[ii].m_NumRef; componentFlatList[jj].m_NumRef = componentFlatList[ii].m_NumRef;
...@@ -486,7 +486,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) ...@@ -486,7 +486,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
// Error if unit number selected does not exist ( greater than the number of // Error if unit number selected does not exist ( greater than the number of
// parts in the component ). This can happen if a component has changed in a // parts in the component ). This can happen if a component has changed in a
// library after a previous annotation. // library after a previous annotation.
if( std::max( componentFlatList[ii].GetLibComponent()->GetPartCount(), 1 ) if( std::max( componentFlatList[ii].GetLibComponent()->GetUnitCount(), 1 )
< componentFlatList[ii].m_Unit ) < componentFlatList[ii].m_Unit )
{ {
if( componentFlatList[ii].m_NumRef >= 0 ) if( componentFlatList[ii].m_NumRef >= 0 )
...@@ -498,7 +498,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) ...@@ -498,7 +498,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
GetChars( componentFlatList[ii].GetRef() ), GetChars( componentFlatList[ii].GetRef() ),
GetChars( tmp ), GetChars( tmp ),
componentFlatList[ii].m_Unit, componentFlatList[ii].m_Unit,
componentFlatList[ii].GetLibComponent()->GetPartCount() ); componentFlatList[ii].GetLibComponent()->GetUnitCount() );
if( aMessageList ) if( aMessageList )
aMessageList->Add( msg ); aMessageList->Add( msg );
...@@ -555,8 +555,8 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) ...@@ -555,8 +555,8 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
/* Test error if units are different but number of parts per package /* Test error if units are different but number of parts per package
* too high (ex U3 ( 1 part) and we find U3B this is an error) */ * too high (ex U3 ( 1 part) and we find U3B this is an error) */
if( componentFlatList[ii].GetLibComponent()->GetPartCount() if( componentFlatList[ii].GetLibComponent()->GetUnitCount()
!= componentFlatList[ii + 1].GetLibComponent()->GetPartCount() ) != componentFlatList[ii + 1].GetLibComponent()->GetUnitCount() )
{ {
if( componentFlatList[ii].m_NumRef >= 0 ) if( componentFlatList[ii].m_NumRef >= 0 )
tmp << componentFlatList[ii].m_NumRef; tmp << componentFlatList[ii].m_NumRef;
...@@ -584,7 +584,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) ...@@ -584,7 +584,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
error++; error++;
} }
/* Error if values are different between units, for the same reference */ // Error if values are different between units, for the same reference
int next = ii + 1; int next = ii + 1;
if( componentFlatList[ii].CompareValue( componentFlatList[next] ) != 0 ) if( componentFlatList[ii].CompareValue( componentFlatList[next] ) != 0 )
...@@ -592,12 +592,12 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) ...@@ -592,12 +592,12 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
msg.Printf( _( "Different values for %s%d%s (%s) and %s%d%s (%s)" ), msg.Printf( _( "Different values for %s%d%s (%s) and %s%d%s (%s)" ),
GetChars( componentFlatList[ii].GetRef() ), GetChars( componentFlatList[ii].GetRef() ),
componentFlatList[ii].m_NumRef, componentFlatList[ii].m_NumRef,
GetChars( LIB_COMPONENT::SubReference( GetChars( LIB_PART::SubReference(
componentFlatList[ii].m_Unit ) ), componentFlatList[ii].m_Unit ) ),
GetChars( componentFlatList[ii].m_Value->GetText() ), GetChars( componentFlatList[ii].m_Value->GetText() ),
GetChars( componentFlatList[next].GetRef() ), GetChars( componentFlatList[next].GetRef() ),
componentFlatList[next].m_NumRef, componentFlatList[next].m_NumRef,
GetChars( LIB_COMPONENT::SubReference( GetChars( LIB_PART::SubReference(
componentFlatList[next].m_Unit ) ), componentFlatList[next].m_Unit ) ),
GetChars( componentFlatList[next].m_Value->GetText() ) ); GetChars( componentFlatList[next].m_Value->GetText() ) );
...@@ -617,7 +617,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) ...@@ -617,7 +617,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
|| ( componentFlatList[ii].GetSheetPath() != componentFlatList[ii + 1].GetSheetPath() ) ) || ( componentFlatList[ii].GetSheetPath() != componentFlatList[ii + 1].GetSheetPath() ) )
continue; continue;
/* Same time stamp found. */ // Same time stamp found.
wxString full_path; wxString full_path;
full_path.Printf( wxT( "%s%8.8X" ), full_path.Printf( wxT( "%s%8.8X" ),
...@@ -640,7 +640,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList ) ...@@ -640,7 +640,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
} }
SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_COMPONENT* aLibComponent, SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent,
SCH_SHEET_PATH& aSheetPath ) SCH_SHEET_PATH& aSheetPath )
{ {
wxASSERT( aComponent != NULL && aLibComponent != NULL ); wxASSERT( aComponent != NULL && aLibComponent != NULL );
...@@ -694,7 +694,7 @@ void SCH_REFERENCE::Split() ...@@ -694,7 +694,7 @@ void SCH_REFERENCE::Split()
{ {
m_IsNew = true; m_IsNew = true;
if( !IsPartsLocked() ) if( !IsUnitsLocked() )
m_Unit = 0x7FFFFFFF; m_Unit = 0x7FFFFFFF;
refText.erase( ll ); // delete last char refText.erase( ll ); // delete last char
...@@ -705,7 +705,7 @@ void SCH_REFERENCE::Split() ...@@ -705,7 +705,7 @@ void SCH_REFERENCE::Split()
{ {
m_IsNew = true; m_IsNew = true;
if( !IsPartsLocked() ) if( !IsUnitsLocked() )
m_Unit = 0x7FFFFFFF; m_Unit = 0x7FFFFFFF;
} }
else else
......
...@@ -98,8 +98,11 @@ bool COMPONENT_TREE_SEARCH_CONTAINER::scoreComparator( const TREE_NODE* a1, cons ...@@ -98,8 +98,11 @@ bool COMPONENT_TREE_SEARCH_CONTAINER::scoreComparator( const TREE_NODE* a1, cons
} }
COMPONENT_TREE_SEARCH_CONTAINER::COMPONENT_TREE_SEARCH_CONTAINER() COMPONENT_TREE_SEARCH_CONTAINER::COMPONENT_TREE_SEARCH_CONTAINER( PART_LIBS* aLibs ) :
: tree( NULL ), libraries_added( 0 ), preselect_unit_number( -1 ) tree( NULL ),
libraries_added( 0 ),
preselect_unit_number( -1 ),
m_libs( aLibs )
{ {
} }
...@@ -127,7 +130,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::SetTree( wxTreeCtrl* aTree ) ...@@ -127,7 +130,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::SetTree( wxTreeCtrl* aTree )
} }
void COMPONENT_TREE_SEARCH_CONTAINER::AddLibrary( CMP_LIBRARY& aLib ) void COMPONENT_TREE_SEARCH_CONTAINER::AddLibrary( PART_LIB& aLib )
{ {
wxArrayString all_aliases; wxArrayString all_aliases;
...@@ -139,7 +142,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddLibrary( CMP_LIBRARY& aLib ) ...@@ -139,7 +142,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddLibrary( CMP_LIBRARY& aLib )
void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName, void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName,
const wxArrayString& aAliasNameList, const wxArrayString& aAliasNameList,
CMP_LIBRARY* aOptionalLib ) PART_LIB* aOptionalLib )
{ {
TREE_NODE* const lib_node = new TREE_NODE( TREE_NODE::TYPE_LIB, NULL, NULL, TREE_NODE* const lib_node = new TREE_NODE( TREE_NODE::TYPE_LIB, NULL, NULL,
aNodeName, wxEmptyString, wxEmptyString ); aNodeName, wxEmptyString, wxEmptyString );
...@@ -152,7 +155,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName, ...@@ -152,7 +155,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName,
if( aOptionalLib ) if( aOptionalLib )
a = aOptionalLib->FindAlias( aName ); a = aOptionalLib->FindAlias( aName );
else else
a = CMP_LIBRARY::FindLibraryEntry( aName, wxEmptyString ); a = m_libs->FindLibraryEntry( aName, wxEmptyString );
if( a == NULL ) if( a == NULL )
continue; continue;
...@@ -186,12 +189,12 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName, ...@@ -186,12 +189,12 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName,
a, a->GetName(), display_info, search_text ); a, a->GetName(), display_info, search_text );
nodes.push_back( alias_node ); nodes.push_back( alias_node );
if( a->GetComponent()->IsMulti() ) // Add all units as sub-nodes. if( a->GetPart()->IsMulti() ) // Add all units as sub-nodes.
{ {
for( int u = 1; u <= a->GetComponent()->GetPartCount(); ++u ) for( int u = 1; u <= a->GetPart()->GetUnitCount(); ++u )
{ {
wxString unitName = _("Unit"); wxString unitName = _("Unit");
unitName += wxT( " " ) + LIB_COMPONENT::SubReference( u, false ); unitName += wxT( " " ) + LIB_PART::SubReference( u, false );
TREE_NODE* unit_node = new TREE_NODE( TREE_NODE::TYPE_UNIT, TREE_NODE* unit_node = new TREE_NODE( TREE_NODE::TYPE_UNIT,
alias_node, a, alias_node, a,
unitName, unitName,
......
...@@ -28,13 +28,14 @@ ...@@ -28,13 +28,14 @@
#include <wx/string.h> #include <wx/string.h>
class LIB_ALIAS; class LIB_ALIAS;
class CMP_LIBRARY; class PART_LIB;
class PART_LIBS;
class wxTreeCtrl; class wxTreeCtrl;
class wxArrayString; class wxArrayString;
// class COMPONENT_TREE_SEARCH_CONTAINER // class COMPONENT_TREE_SEARCH_CONTAINER
// A container for components that allows to search them matching their name, keywords // A container for components that allows to search them matching their name, keywords
// and descripotions, updating a wxTreeCtrl with the results (toplevel nodes: // and descriptions, updating a wxTreeCtrl with the results (toplevel nodes:
// libraries, leafs: components), scored by relevance. // libraries, leafs: components), scored by relevance.
// //
// The scored result list is adpated on each update on the search-term: this allows // The scored result list is adpated on each update on the search-term: this allows
...@@ -42,7 +43,7 @@ class wxArrayString; ...@@ -42,7 +43,7 @@ class wxArrayString;
class COMPONENT_TREE_SEARCH_CONTAINER class COMPONENT_TREE_SEARCH_CONTAINER
{ {
public: public:
COMPONENT_TREE_SEARCH_CONTAINER(); COMPONENT_TREE_SEARCH_CONTAINER( PART_LIBS* aLibs );
~COMPONENT_TREE_SEARCH_CONTAINER(); ~COMPONENT_TREE_SEARCH_CONTAINER();
/** Function AddLibrary /** Function AddLibrary
...@@ -51,7 +52,7 @@ public: ...@@ -51,7 +52,7 @@ public:
* *
* @param aLib containting all the components to be added. * @param aLib containting all the components to be added.
*/ */
void AddLibrary( CMP_LIBRARY& aLib ); void AddLibrary( PART_LIB& aLib );
/** Function AddComponentList /** Function AddComponentList
* Add the given list of components, given by name, to be searched. * Add the given list of components, given by name, to be searched.
...@@ -62,7 +63,7 @@ public: ...@@ -62,7 +63,7 @@ public:
* @param aOptionalLib Library to look up the component names (if NULL: global lookup) * @param aOptionalLib Library to look up the component names (if NULL: global lookup)
*/ */
void AddAliasList( const wxString& aNodeName, const wxArrayString& aAliasNameList, void AddAliasList( const wxString& aNodeName, const wxArrayString& aAliasNameList,
CMP_LIBRARY* aOptionalLib ); PART_LIB* aOptionalLib );
/** Function SetPreselectNode /** Function SetPreselectNode
* Set the component name to be selected in absence of any search-result. * Set the component name to be selected in absence of any search-result.
...@@ -111,6 +112,8 @@ private: ...@@ -111,6 +112,8 @@ private:
wxString preselect_node_name; wxString preselect_node_name;
int preselect_unit_number; int preselect_unit_number;
PART_LIBS* m_libs; // no ownership
}; };
#endif /* COMPONENT_TREE_SEARCH_CONTAINER_H */ #endif /* COMPONENT_TREE_SEARCH_CONTAINER_H */
...@@ -38,25 +38,27 @@ ...@@ -38,25 +38,27 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
extern void DisplayCmpDocAndKeywords( wxString& Name );
// Used in DataBaseGetName: this is a callback function for EDA_LIST_DIALOG // Used in DataBaseGetName: this is a callback function for EDA_LIST_DIALOG
// to display keywords and description of a component // to display keywords and description of a component
void DisplayCmpDocAndKeywords( wxString& Name ) void DisplayCmpDocAndKeywords( wxString& aName, void* aData )
{ {
LIB_ALIAS* CmpEntry = NULL; PART_LIBS* libs = (PART_LIBS*) aData;
wxASSERT( libs );
CmpEntry = CMP_LIBRARY::FindLibraryEntry( Name ); LIB_ALIAS* part = libs->FindLibraryEntry( aName );
if( CmpEntry == NULL ) if( !part )
return; return;
Name = wxT( "Description: " ) + CmpEntry->GetDescription(); aName = wxT( "Description: " ) + part->GetDescription();
Name += wxT( "\nKey Words: " ) + CmpEntry->GetKeyWords(); aName += wxT( "\nKey Words: " ) + part->GetKeyWords();
} }
#if 0 // not used, should be wxFrame member for KIWAY and PROJECT access.
/* /*
* Displays a list of filtered components found in libraries for selection, * Displays a list of filtered components found in libraries for selection,
* Keys is a list of keywords to filter components which do not match these keywords * Keys is a list of keywords to filter components which do not match these keywords
...@@ -75,7 +77,7 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa ...@@ -75,7 +77,7 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
Keys.MakeUpper(); Keys.MakeUpper();
/* Review the list of libraries for counting. */ /* Review the list of libraries for counting. */
BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() ) BOOST_FOREACH( PART_LIB& lib, PART_LIB::GetLibraryList() )
{ {
lib.SearchEntryNames( nameList, BufName, Keys ); lib.SearchEntryNames( nameList, BufName, Keys );
} }
...@@ -119,6 +121,7 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa ...@@ -119,6 +121,7 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
// Show candidate list: // Show candidate list:
wxString cmpname; wxString cmpname;
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), headers, nameList, cmpname, EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), headers, nameList, cmpname,
DisplayCmpDocAndKeywords, true ); DisplayCmpDocAndKeywords, true );
...@@ -128,3 +131,4 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa ...@@ -128,3 +131,4 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
cmpname = dlg.GetTextSelection(); cmpname = dlg.GetTextSelection();
return cmpname; return cmpname;
} }
#endif
...@@ -302,7 +302,7 @@ void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event ) ...@@ -302,7 +302,7 @@ void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event )
fn = g_RootSheet->GetScreen()->GetFileName(); fn = g_RootSheet->GetScreen()->GetFileName();
if( fn.GetPath().IsEmpty() ) if( fn.GetPath().IsEmpty() )
fn.SetPath( wxGetCwd() ); fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
fn.ClearExt(); fn.ClearExt();
wxString fullfilename = fn.GetFullPath(); wxString fullfilename = fn.GetFullPath();
......
...@@ -251,13 +251,13 @@ void DIALOG_CHOOSE_COMPONENT::OnHandlePreviewRepaint( wxPaintEvent& aRepaintEven ...@@ -251,13 +251,13 @@ void DIALOG_CHOOSE_COMPONENT::OnHandlePreviewRepaint( wxPaintEvent& aRepaintEven
int unit = 0; int unit = 0;
LIB_ALIAS* selection = m_search_container->GetSelectedAlias( &unit ); LIB_ALIAS* selection = m_search_container->GetSelectedAlias( &unit );
renderPreview( selection ? selection->GetComponent() : NULL, unit ); renderPreview( selection ? selection->GetPart() : NULL, unit );
} }
// Render the preview in our m_componentView. If this gets more complicated, we should // Render the preview in our m_componentView. If this gets more complicated, we should
// probably have a derived class from wxPanel; but this keeps things local. // probably have a derived class from wxPanel; but this keeps things local.
void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_COMPONENT* aComponent, int aUnit ) void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUnit )
{ {
wxPaintDC dc( m_componentView ); wxPaintDC dc( m_componentView );
dc.SetBackground( *wxWHITE_BRUSH ); dc.SetBackground( *wxWHITE_BRUSH );
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
class COMPONENT_TREE_SEARCH_CONTAINER; class COMPONENT_TREE_SEARCH_CONTAINER;
class LIB_ALIAS; class LIB_ALIAS;
class LIB_COMPONENT; class LIB_PART;
class wxTreeItemId; class wxTreeItemId;
class DIALOG_CHOOSE_COMPONENT : public DIALOG_CHOOSE_COMPONENT_BASE class DIALOG_CHOOSE_COMPONENT : public DIALOG_CHOOSE_COMPONENT_BASE
...@@ -79,7 +79,7 @@ protected: ...@@ -79,7 +79,7 @@ protected:
private: private:
bool updateSelection(); bool updateSelection();
void selectIfValid( const wxTreeItemId& aTreeId ); void selectIfValid( const wxTreeItemId& aTreeId );
void renderPreview( LIB_COMPONENT* aComponent, int aUnit ); void renderPreview( LIB_PART* aComponent, int aUnit );
COMPONENT_TREE_SEARCH_CONTAINER* const m_search_container; COMPONENT_TREE_SEARCH_CONTAINER* const m_search_container;
const int m_deMorganConvert; const int m_deMorganConvert;
......
...@@ -64,7 +64,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() ...@@ -64,7 +64,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg()
{ {
m_AliasLocation = -1; m_AliasLocation = -1;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* component = m_Parent->GetCurPart();
if( component == NULL ) if( component == NULL )
{ {
...@@ -125,7 +125,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnCancelClick( wxCommandEvent& event ) ...@@ -125,7 +125,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnCancelClick( wxCommandEvent& event )
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc() void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
{ {
LIB_ALIAS* alias; LIB_ALIAS* alias;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* component = m_Parent->GetCurPart();
if( component == NULL ) if( component == NULL )
return; return;
...@@ -151,7 +151,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc() ...@@ -151,7 +151,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
*/ */
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
{ {
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* component = m_Parent->GetCurPart();
if( m_Parent->GetShowDeMorgan() ) if( m_Parent->GetShowDeMorgan() )
m_AsConvertButt->SetValue( true ); m_AsConvertButt->SetValue( true );
...@@ -172,10 +172,10 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() ...@@ -172,10 +172,10 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
m_ShowPinNumButt->SetValue( component->ShowPinNumbers() ); m_ShowPinNumButt->SetValue( component->ShowPinNumbers() );
m_ShowPinNameButt->SetValue( component->ShowPinNames() ); m_ShowPinNameButt->SetValue( component->ShowPinNames() );
m_PinsNameInsideButt->SetValue( component->GetPinNameOffset() != 0 ); m_PinsNameInsideButt->SetValue( component->GetPinNameOffset() != 0 );
m_SelNumberOfUnits->SetValue( component->GetPartCount() ); m_SelNumberOfUnits->SetValue( component->GetUnitCount() );
m_SetSkew->SetValue( component->GetPinNameOffset() ); m_SetSkew->SetValue( component->GetPinNameOffset() );
m_OptionPower->SetValue( component->IsPower() ); m_OptionPower->SetValue( component->IsPower() );
m_OptionPartsLocked->SetValue( component->UnitsLocked() && component->GetPartCount() > 1 ); m_OptionPartsLocked->SetValue( component->UnitsLocked() && component->GetUnitCount() > 1 );
} }
...@@ -184,7 +184,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -184,7 +184,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
/* Update the doc, keyword and doc filename strings */ /* Update the doc, keyword and doc filename strings */
int index; int index;
LIB_ALIAS* alias; LIB_ALIAS* alias;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* component = m_Parent->GetCurPart();
if( component == NULL ) if( component == NULL )
{ {
...@@ -248,7 +248,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) ...@@ -248,7 +248,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
* Obviously, cannot be true if there is only one part */ * Obviously, cannot be true if there is only one part */
component->LockUnits( m_OptionPartsLocked->GetValue() ); component->LockUnits( m_OptionPartsLocked->GetValue() );
if( component->GetPartCount() <= 1 ) if( component->GetUnitCount() <= 1 )
component->LockUnits( false ); component->LockUnits( false );
/* Update the footprint filter list */ /* Update the footprint filter list */
...@@ -265,7 +265,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocFromRootToAlias( wxCommandEvent& e ...@@ -265,7 +265,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocFromRootToAlias( wxCommandEvent& e
return; return;
LIB_ALIAS* parent_alias; LIB_ALIAS* parent_alias;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* component = m_Parent->GetCurPart();
if( component == NULL ) if( component == NULL )
return; return;
...@@ -309,8 +309,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& eve ...@@ -309,8 +309,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& eve
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event )
{ {
wxString aliasname; wxString aliasname;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* component = m_Parent->GetCurPart();
CMP_LIBRARY* library = m_Parent->GetLibrary(); PART_LIB* library = m_Parent->GetCurLib();
if( component == NULL ) if( component == NULL )
return; return;
...@@ -371,7 +371,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event ...@@ -371,7 +371,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event
} }
m_PartAliasListCtrl->Delete( m_PartAliasListCtrl->GetSelection() ); m_PartAliasListCtrl->Delete( m_PartAliasListCtrl->GetSelection() );
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* component = m_Parent->GetCurPart();
if( component ) if( component )
component->RemoveAlias( aliasname ); component->RemoveAlias( aliasname );
...@@ -389,16 +389,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event ...@@ -389,16 +389,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event
*/ */
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit ) bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
{ {
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* part = m_Parent->GetCurPart();
if( component == NULL || component->GetPartCount() == MaxUnit || MaxUnit < 1 ) if( !part || part->GetUnitCount() == MaxUnit || MaxUnit < 1 )
return false; return false;
if( MaxUnit < component->GetPartCount() if( MaxUnit < part->GetUnitCount()
&& !IsOK( this, _( "Delete extra parts from component?" ) ) ) && !IsOK( this, _( "Delete extra parts from component?" ) ) )
return false; return false;
component->SetPartCount( MaxUnit ); part->SetUnitCount( MaxUnit );
return true; return true;
} }
...@@ -408,7 +408,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit ) ...@@ -408,7 +408,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
*/ */
bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert() bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
{ {
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* component = m_Parent->GetCurPart();
if( component == NULL || ( m_Parent->GetShowDeMorgan() == component->HasConversion() ) ) if( component == NULL || ( m_Parent->GetShowDeMorgan() == component->HasConversion() ) )
return false; return false;
...@@ -437,13 +437,13 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert() ...@@ -437,13 +437,13 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& event )
{ {
PROJECT& prj = Prj(); PROJECT& prj = Prj();
SEARCH_STACK& search = prj.SchSearchS(); SEARCH_STACK* search = prj.SchSearchS();
wxString mask = wxT( "*" ); wxString mask = wxT( "*" );
wxString docpath = prj.GetRString( PROJECT::DOC_PATH ); wxString docpath = prj.GetRString( PROJECT::DOC_PATH );
if( !docpath ) if( !docpath )
docpath = search.LastVisitedPath( wxT( "doc" ) ); docpath = search->LastVisitedPath( wxT( "doc" ) );
wxString fullFileName = EDA_FileSelector( _( "Doc Files" ), wxString fullFileName = EDA_FileSelector( _( "Doc Files" ),
docpath, docpath,
...@@ -468,7 +468,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& e ...@@ -468,7 +468,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& e
prj.SetRString( PROJECT::DOC_PATH, fn.GetPath() ); prj.SetRString( PROJECT::DOC_PATH, fn.GetPath() );
wxString filename = search.FilenameWithRelativePathInSearchList( fullFileName ); wxString filename = search->FilenameWithRelativePathInSearchList(
fullFileName, wxPathOnly( Prj().GetProjectFullName() ) );
// Filenames are always stored in unix like mode, ie separator "\" is stored as "/" // Filenames are always stored in unix like mode, ie separator "\" is stored as "/"
// to ensure files are identical under unices and windows // to ensure files are identical under unices and windows
...@@ -496,7 +497,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent& ...@@ -496,7 +497,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent&
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& event )
{ {
wxString Line; wxString Line;
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* component = m_Parent->GetCurPart();
if( component == NULL ) if( component == NULL )
return; return;
...@@ -531,7 +532,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& event ...@@ -531,7 +532,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& event
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteOneFootprintFilter( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteOneFootprintFilter( wxCommandEvent& event )
{ {
LIB_COMPONENT* component = m_Parent->GetComponent(); LIB_PART* component = m_Parent->GetCurPart();
int ii = m_FootprintFilterListBox->GetSelection(); int ii = m_FootprintFilterListBox->GetSelection();
m_FootprintFilterListBox->Delete( ii ); m_FootprintFilterListBox->Delete( ii );
......
...@@ -70,7 +70,7 @@ private: ...@@ -70,7 +70,7 @@ private:
SCH_EDIT_FRAME* m_Parent; SCH_EDIT_FRAME* m_Parent;
SCH_COMPONENT* m_Cmp; SCH_COMPONENT* m_Cmp;
LIB_COMPONENT* m_LibEntry; LIB_PART* m_part;
bool m_skipCopyFromPanel; bool m_skipCopyFromPanel;
static int s_SelectedRow; static int s_SelectedRow;
...@@ -161,7 +161,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow ...@@ -161,7 +161,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
{ {
m_Parent = (SCH_EDIT_FRAME*) parent; m_Parent = (SCH_EDIT_FRAME*) parent;
m_LibEntry = NULL; m_part = NULL;
m_skipCopyFromPanel = false; m_skipCopyFromPanel = false;
wxListItem columnLabel; wxListItem columnLabel;
...@@ -225,23 +225,27 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions() ...@@ -225,23 +225,27 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
#ifndef KICAD_KEEPCASE #ifndef KICAD_KEEPCASE
newname.MakeUpper(); newname.MakeUpper();
#endif #endif
newname.Replace( wxT( " " ), wxT( "_" ) ); newname.Replace( wxT( " " ), wxT( "_" ) );
if( newname.IsEmpty() ) if( newname.IsEmpty() )
{ {
DisplayError( NULL, _( "No Component Name!" ) ); DisplayError( NULL, _( "No Component Name!" ) );
} }
else if( newname.CmpNoCase( m_Cmp->m_ChipName ) ) else if( Cmp_KEEPCASE( newname, m_Cmp->m_part_name ) )
{ {
if( CMP_LIBRARY::FindLibraryEntry( newname ) == NULL ) PART_LIBS* libs = Prj().SchLibs();
if( libs->FindLibraryEntry( newname ) == NULL )
{ {
wxString message; wxString msg = wxString::Format( _(
message.Printf( _( "Component [%s] not found!" ), GetChars( newname ) ); "Component '%s' not found!" ),
DisplayError( NULL, message ); GetChars( newname ) );
DisplayError( this, msg );
} }
else // Change component from lib! else // Change component from lib!
{ {
m_Cmp->m_ChipName = newname; m_Cmp->SetPartName( newname, libs );
} }
} }
...@@ -256,6 +260,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions() ...@@ -256,6 +260,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
{ {
int unit_selection = unitChoice->GetCurrentSelection() + 1; int unit_selection = unitChoice->GetCurrentSelection() + 1;
STATUS_FLAGS flags = m_Cmp->GetFlags(); STATUS_FLAGS flags = m_Cmp->GetFlags();
m_Cmp->SetUnitSelection( &m_Parent->GetCurrentSheet(), unit_selection ); m_Cmp->SetUnitSelection( &m_Parent->GetCurrentSheet(), unit_selection );
m_Cmp->SetUnit( unit_selection ); m_Cmp->SetUnit( unit_selection );
m_Cmp->ClearFlags(); m_Cmp->ClearFlags();
...@@ -362,10 +367,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event ...@@ -362,10 +367,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() + m_Cmp->m_Pos ); m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() + m_Cmp->m_Pos );
} }
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName ); LIB_PART* entry = Prj().SchLibs()->FindLibPart( m_Cmp->m_part_name );
if( entry && entry->IsPower() ) if( entry && entry->IsPower() )
m_FieldsBuf[VALUE].SetText( m_Cmp->m_ChipName ); m_FieldsBuf[VALUE].SetText( m_Cmp->m_part_name );
// copy all the fields back, and change the length of m_Fields. // copy all the fields back, and change the length of m_Fields.
m_Cmp->SetFields( m_FieldsBuf ); m_Cmp->SetFields( m_FieldsBuf );
...@@ -553,7 +558,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent ...@@ -553,7 +558,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
which came from the component. which came from the component.
*/ */
m_LibEntry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName ); m_part = Prj().SchLibs()->FindLibPart( m_Cmp->m_part_name );
#if 0 && defined(DEBUG) #if 0 && defined(DEBUG)
for( int i = 0; i<aComponent->GetFieldCount(); ++i ) for( int i = 0; i<aComponent->GetFieldCount(); ++i )
...@@ -765,7 +770,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() ...@@ -765,7 +770,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
// For power symbols, the value is NOR editable, because value and pin // For power symbols, the value is NOR editable, because value and pin
// name must be same and can be edited only in library editor // name must be same and can be edited only in library editor
if( fieldNdx == VALUE && m_LibEntry && m_LibEntry->IsPower() ) if( fieldNdx == VALUE && m_part && m_part->IsPower() )
fieldValueTextCtrl->Enable( false ); fieldValueTextCtrl->Enable( false );
else else
fieldValueTextCtrl->Enable( true ); fieldValueTextCtrl->Enable( true );
...@@ -869,7 +874,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -869,7 +874,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
int choiceCount = unitChoice->GetCount(); int choiceCount = unitChoice->GetCount();
// Remove non existing choices (choiceCount must be <= number for parts) // Remove non existing choices (choiceCount must be <= number for parts)
int unitcount = m_LibEntry ? m_LibEntry->GetPartCount() : 1; int unitcount = m_part ? m_part->GetUnitCount() : 1;
if( unitcount < 1 ) if( unitcount < 1 )
unitcount = 1; unitcount = 1;
...@@ -899,7 +904,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -899,7 +904,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
else else
{ {
// Show the "Units are not interchangeable" message option? // Show the "Units are not interchangeable" message option?
if( !m_LibEntry || !m_LibEntry->UnitsLocked() ) if( !m_part || !m_part->UnitsLocked() )
unitsInterchageableLabel->SetLabel( _("Yes") ); unitsInterchageableLabel->SetLabel( _("Yes") );
else else
unitsInterchageableLabel->SetLabel( _("No") ); unitsInterchageableLabel->SetLabel( _("No") );
...@@ -937,11 +942,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -937,11 +942,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
if( m_Cmp->GetConvert() > 1 ) if( m_Cmp->GetConvert() > 1 )
convertCheckBox->SetValue( true ); convertCheckBox->SetValue( true );
if( m_LibEntry == NULL || !m_LibEntry->HasConversion() ) if( m_part == NULL || !m_part->HasConversion() )
convertCheckBox->Enable( false ); convertCheckBox->Enable( false );
// Set the component's library name. // Set the component's library name.
chipnameTextCtrl->SetValue( m_Cmp->m_ChipName ); chipnameTextCtrl->SetValue( m_Cmp->m_part_name );
// Set the component's unique ID time stamp. // Set the component's unique ID time stamp.
m_textCtrlTimeStamp->SetValue( wxString::Format( wxT("%8.8lX"), m_textCtrlTimeStamp->SetValue( wxString::Format( wxT("%8.8lX"),
...@@ -955,16 +960,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel() ...@@ -955,16 +960,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
*/ */
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
{ {
LIB_COMPONENT* entry; if( !m_Cmp )
if( m_Cmp == NULL )
return;
entry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
if( entry == NULL )
return; return;
if( LIB_PART* part = Prj().SchLibs()->FindLibPart( m_Cmp->m_part_name ) )
{
// save old cmp in undo list if not already in edit, or moving ... // save old cmp in undo list if not already in edit, or moving ...
if( m_Cmp->m_Flags == 0 ) if( m_Cmp->m_Flags == 0 )
m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED ); m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
...@@ -976,22 +976,26 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) ...@@ -976,22 +976,26 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
// Note: the field texts are not modified because they are set in schematic, // Note: the field texts are not modified because they are set in schematic,
// the text from libraries is most of time a dummy text // the text from libraries is most of time a dummy text
// Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized // Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
LIB_FIELD& refField = entry->GetReferenceField(); LIB_FIELD& refField = part->GetReferenceField();
m_Cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_Cmp->m_Pos ); m_Cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( REFERENCE )->ImportValues( refField ); m_Cmp->GetField( REFERENCE )->ImportValues( refField );
LIB_FIELD& valField = entry->GetValueField(); LIB_FIELD& valField = part->GetValueField();
m_Cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_Cmp->m_Pos ); m_Cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( VALUE )->ImportValues( valField ); m_Cmp->GetField( VALUE )->ImportValues( valField );
LIB_FIELD* field = entry->GetField(FOOTPRINT); LIB_FIELD* field = part->GetField(FOOTPRINT);
if( field && m_Cmp->GetField( FOOTPRINT ) ) if( field && m_Cmp->GetField( FOOTPRINT ) )
{ {
m_Cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos ); m_Cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
m_Cmp->GetField( FOOTPRINT )->ImportValues( *field ); m_Cmp->GetField( FOOTPRINT )->ImportValues( *field );
} }
field = entry->GetField(DATASHEET); field = part->GetField(DATASHEET);
if( field && m_Cmp->GetField( DATASHEET ) ) if( field && m_Cmp->GetField( DATASHEET ) )
{ {
m_Cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos ); m_Cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
...@@ -1003,5 +1007,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) ...@@ -1003,5 +1007,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
m_Parent->OnModify(); m_Parent->OnModify();
m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
EndQuasiModal( 1 ); EndQuasiModal( 1 );
}
} }
...@@ -54,7 +54,7 @@ static int s_SelectedRow; ...@@ -54,7 +54,7 @@ static int s_SelectedRow;
class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
{ {
public: public:
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( LIB_EDIT_FRAME* aParent, LIB_COMPONENT* aLibEntry ); DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( LIB_EDIT_FRAME* aParent, LIB_PART* aLibEntry );
//~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB() {} //~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB() {}
private: private:
...@@ -125,7 +125,7 @@ private: ...@@ -125,7 +125,7 @@ private:
} }
LIB_EDIT_FRAME* m_parent; LIB_EDIT_FRAME* m_parent;
LIB_COMPONENT* m_libEntry; LIB_PART* m_libEntry;
bool m_skipCopyFromPanel; bool m_skipCopyFromPanel;
/// a copy of the edited component's LIB_FIELDs /// a copy of the edited component's LIB_FIELDs
...@@ -135,12 +135,12 @@ private: ...@@ -135,12 +135,12 @@ private:
void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event ) void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event )
{ {
if( m_component == NULL ) if( !GetCurLib() )
return; return;
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB dlg( this, m_component ); DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB dlg( this, GetCurPart() );
int abort = dlg.ShowQuasiModal(); int abort = dlg.ShowQuasiModal();
...@@ -156,7 +156,7 @@ void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event ) ...@@ -156,7 +156,7 @@ void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event )
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB(
LIB_EDIT_FRAME* aParent, LIB_EDIT_FRAME* aParent,
LIB_COMPONENT* aLibEntry ) : LIB_PART* aLibEntry ) :
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent ) DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent )
{ {
m_parent = aParent; m_parent = aParent;
......
This diff is collapsed.
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <class_sch_screen.h> #include <class_sch_screen.h>
#include <wxEeschemaStruct.h> #include <wxEeschemaStruct.h>
#include <invoke_sch_dialog.h> #include <invoke_sch_dialog.h>
#include <project.h>
#include <netlist.h> #include <netlist.h>
#include <class_netlist_object.h> #include <class_netlist_object.h>
...@@ -134,14 +135,12 @@ void DIALOG_ERC::OnCloseErcDialog( wxCloseEvent& event ) ...@@ -134,14 +135,12 @@ void DIALOG_ERC::OnCloseErcDialog( wxCloseEvent& event )
} }
/* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RESET_MATRIX */
void DIALOG_ERC::OnResetMatrixClick( wxCommandEvent& event ) void DIALOG_ERC::OnResetMatrixClick( wxCommandEvent& event )
{ {
ResetDefaultERCDiag( event ); ResetDefaultERCDiag( event );
} }
/* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERC_CMP */
void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event ) void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
{ {
wxBusyCursor(); wxBusyCursor();
...@@ -155,7 +154,6 @@ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event ) ...@@ -155,7 +154,6 @@ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
m_MessagesList->AppendText( messageList[ii] ); m_MessagesList->AppendText( messageList[ii] );
} }
// Single click on a marker info:
void DIALOG_ERC::OnLeftClickMarkersList( wxCommandEvent& event ) void DIALOG_ERC::OnLeftClickMarkersList( wxCommandEvent& event )
{ {
m_lastMarkerFound = NULL; m_lastMarkerFound = NULL;
...@@ -209,8 +207,7 @@ void DIALOG_ERC::OnLeftClickMarkersList( wxCommandEvent& event ) ...@@ -209,8 +207,7 @@ void DIALOG_ERC::OnLeftClickMarkersList( wxCommandEvent& event )
m_parent->RedrawScreen( marker->m_Pos, false); m_parent->RedrawScreen( marker->m_Pos, false);
} }
// Double click on a marker info:
// Close the dialog and jump to the selected marker
void DIALOG_ERC::OnLeftDblClickMarkersList( wxCommandEvent& event ) void DIALOG_ERC::OnLeftDblClickMarkersList( wxCommandEvent& event )
{ {
// Remember: OnLeftClickMarkersList was called just berfore // Remember: OnLeftClickMarkersList was called just berfore
...@@ -231,8 +228,6 @@ void DIALOG_ERC::OnLeftDblClickMarkersList( wxCommandEvent& event ) ...@@ -231,8 +228,6 @@ void DIALOG_ERC::OnLeftDblClickMarkersList( wxCommandEvent& event )
} }
/* Build or rebuild the panel showing the ERC conflict matrix
*/
void DIALOG_ERC::ReBuildMatrixPanel() void DIALOG_ERC::ReBuildMatrixPanel()
{ {
// Try to know the size of bitmap button used in drc matrix // Try to know the size of bitmap button used in drc matrix
...@@ -325,10 +320,6 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -325,10 +320,6 @@ void DIALOG_ERC::ReBuildMatrixPanel()
} }
/*
* Function DisplayERC_MarkersList
* read the schematic and display the list of ERC markers
*/
void DIALOG_ERC::DisplayERC_MarkersList() void DIALOG_ERC::DisplayERC_MarkersList()
{ {
SCH_SHEET_LIST sheetList; SCH_SHEET_LIST sheetList;
...@@ -358,8 +349,6 @@ void DIALOG_ERC::DisplayERC_MarkersList() ...@@ -358,8 +349,6 @@ void DIALOG_ERC::DisplayERC_MarkersList()
} }
/* Resets the default values of the ERC matrix.
*/
void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event ) void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
{ {
memcpy( DiagErc, DefaultDiagErc, sizeof(DiagErc) ); memcpy( DiagErc, DefaultDiagErc, sizeof(DiagErc) );
...@@ -367,8 +356,6 @@ void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event ) ...@@ -367,8 +356,6 @@ void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
} }
/* Change the error level for the pressed button, on the matrix table
*/
void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event ) void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
{ {
int id, level, ii, x, y; int id, level, ii, x, y;
...@@ -426,9 +413,9 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -426,9 +413,9 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
m_writeErcFile = m_WriteResultOpt->GetValue(); m_writeErcFile = m_WriteResultOpt->GetValue();
/* Build the whole sheet list in hierarchy (sheet, not screen) */ // Build the whole sheet list in hierarchy (sheet, not screen)
SCH_SHEET_LIST sheets; SCH_SHEET_LIST sheets;
sheets.AnnotatePowerSymbols(); sheets.AnnotatePowerSymbols( Prj().SchLibs() );
if( m_parent->CheckAnnotate( aMessagesList, false ) ) if( m_parent->CheckAnnotate( aMessagesList, false ) )
{ {
......
...@@ -48,7 +48,7 @@ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event ) ...@@ -48,7 +48,7 @@ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event )
// In fact m_dummyPin should not have a parent, but draw functions need a parent // In fact m_dummyPin should not have a parent, but draw functions need a parent
// to know some options, about pin texts // to know some options, about pin texts
LIB_EDIT_FRAME* libframe = (LIB_EDIT_FRAME*) GetParent(); LIB_EDIT_FRAME* libframe = (LIB_EDIT_FRAME*) GetParent();
m_dummyPin->SetParent( libframe->GetComponent() ); m_dummyPin->SetParent( libframe->GetCurPart() );
// Calculate a suitable scale to fit the available draw area // Calculate a suitable scale to fit the available draw area
EDA_RECT bBox = m_dummyPin->GetBoundingBox(); EDA_RECT bBox = m_dummyPin->GetBoundingBox();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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