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.
This commit is contained in:
parent
c63459653a
commit
7e483f69bd
23
TODO.txt
23
TODO.txt
|
@ -64,18 +64,13 @@ PCBNew
|
|||
|
||||
Dick's Final TODO List:
|
||||
======================
|
||||
*) Milestone B of Modular KiCad Blueprint:
|
||||
* Put SEARCH_STACK::LastVisitedPath() out of its misery.
|
||||
* Combine CVPCB into PCBNEW.
|
||||
|
||||
*) Milestone C of Modular KiCad Blueprint
|
||||
* 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.
|
||||
|
||||
*) DLL-ization of pcbnew & eeschema
|
||||
http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/
|
||||
https://blueprints.launchpad.net/kicad/+spec/modular-kicad
|
||||
|
||||
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.
|
||||
* Clear the FP_LIB_TABLE when the last KIWAY_PLAYER using it is closed.
|
||||
|
||||
|
||||
Fix export gencad
|
|
@ -40,6 +40,40 @@
|
|||
#include <boost/foreach.hpp>
|
||||
|
||||
|
||||
void wxConfigLoadParams( wxConfigBase* aCfg,
|
||||
const PARAM_CFG_ARRAY& aList, const wxString& aGroup )
|
||||
{
|
||||
wxASSERT( aCfg );
|
||||
|
||||
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
|
||||
{
|
||||
if( !!param.m_Group )
|
||||
aCfg->SetPath( param.m_Group );
|
||||
else
|
||||
aCfg->SetPath( aGroup );
|
||||
|
||||
if( param.m_Setup )
|
||||
continue;
|
||||
|
||||
param.ReadParam( aCfg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
|
||||
{
|
||||
wxASSERT( aCfg );
|
||||
|
||||
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
|
||||
{
|
||||
if( !param.m_Setup )
|
||||
continue;
|
||||
|
||||
param.ReadParam( aCfg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxConfigSaveParams( wxConfigBase* aCfg,
|
||||
const PARAM_CFG_ARRAY& aList, const wxString& aGroup )
|
||||
{
|
||||
|
@ -68,26 +102,6 @@ void wxConfigSaveParams( wxConfigBase* aCfg,
|
|||
}
|
||||
|
||||
|
||||
void wxConfigLoadParams( wxConfigBase* aCfg,
|
||||
const PARAM_CFG_ARRAY& aList, const wxString& aGroup )
|
||||
{
|
||||
wxASSERT( aCfg );
|
||||
|
||||
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
|
||||
{
|
||||
if( !!param.m_Group )
|
||||
aCfg->SetPath( param.m_Group );
|
||||
else
|
||||
aCfg->SetPath( aGroup );
|
||||
|
||||
if( param.m_Setup )
|
||||
continue;
|
||||
|
||||
param.ReadParam( aCfg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
|
||||
{
|
||||
wxASSERT( aCfg );
|
||||
|
@ -110,21 +124,6 @@ void wxConfigSaveSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
|
|||
}
|
||||
|
||||
|
||||
void wxConfigLoadSetups( wxConfigBase* aCfg, const PARAM_CFG_ARRAY& aList )
|
||||
{
|
||||
wxASSERT( aCfg );
|
||||
|
||||
BOOST_FOREACH( const PARAM_CFG_BASE& param, aList )
|
||||
{
|
||||
if( !param.m_Setup )
|
||||
continue;
|
||||
|
||||
param.ReadParam( aCfg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue )
|
||||
{
|
||||
// Use a single strategy, regardless of wx version.
|
||||
|
|
|
@ -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.
|
||||
KIWAY_HOLDER* h = dynamic_cast<KIWAY_HOLDER*>( aParent );
|
||||
|
||||
wxASSERT_MSG( h,
|
||||
wxT( "DIALOG_SHIM's parent is NULL or not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) );
|
||||
// wxASSERT_MSG( h, wxT( "DIALOG_SHIM's parent is NULL or not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) );
|
||||
|
||||
if( h )
|
||||
SetKiway( this, &h->Kiway() );
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <macros.h> // DIM()
|
||||
#include <common.h>
|
||||
#include <project.h>
|
||||
#include <confirm.h>
|
||||
#include <gr_basic.h>
|
||||
#include <base_struct.h>
|
||||
|
@ -781,9 +782,11 @@ void DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog()
|
|||
// Called on .kicad_wks file description selection change
|
||||
void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
|
||||
{
|
||||
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
|
||||
|
||||
// Display a file picker dialog
|
||||
wxFileDialog fileDialog( this, _( "Select Page Layout Descr File" ),
|
||||
wxGetCwd(), GetWksFileName(),
|
||||
pro_dir, GetWksFileName(),
|
||||
PageLayoutDescrFileWildcard,
|
||||
wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
|
||||
|
||||
|
@ -800,11 +803,14 @@ void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
|
|||
// For Win/Linux/macOS compatibility, a relative path is a good idea
|
||||
if( fn.IsAbsolute() && fileName != GetWksFileName() )
|
||||
{
|
||||
fn.MakeRelativeTo( wxGetCwd() );
|
||||
wxString msg;
|
||||
msg.Printf( _( "The page layout descr filename has changed\n"
|
||||
"Do you want to use the relative path:\n%s"),
|
||||
fn.GetFullPath().GetData() );
|
||||
fn.MakeRelativeTo( pro_dir );
|
||||
|
||||
wxString msg = wxString::Format( _(
|
||||
"The page layout descr filename has changed.\n"
|
||||
"Do you want to use the relative path:\n"
|
||||
"'%s'" ),
|
||||
GetChars( fn.GetFullPath() )
|
||||
);
|
||||
if( IsOK( this, msg ) )
|
||||
shortFileName = fn.GetFullPath();
|
||||
}
|
||||
|
|
|
@ -37,12 +37,14 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
|
|||
const wxArrayString& aItemHeaders,
|
||||
const std::vector<wxArrayString>& aItemList,
|
||||
const wxString& aSelection,
|
||||
void( *aCallBackFunction )( wxString& ),
|
||||
void( *aCallBackFunction )( wxString&, void* ),
|
||||
void* aCallBackFunctionData,
|
||||
bool aSortList ) :
|
||||
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle )
|
||||
{
|
||||
m_sortList = aSortList;
|
||||
m_callBackFct = aCallBackFunction;
|
||||
m_cb_func = aCallBackFunction;
|
||||
m_cb_data = aCallBackFunctionData;
|
||||
m_itemsListCp = &aItemList;
|
||||
|
||||
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
|
|||
|
||||
InsertItems( aItemList, 0 );
|
||||
|
||||
if( m_callBackFct == NULL )
|
||||
if( m_cb_func == NULL )
|
||||
{
|
||||
m_messages->Show( false );
|
||||
m_staticTextMsg->Show( false );
|
||||
|
@ -231,12 +233,11 @@ void EDA_LIST_DIALOG::onCancelClick( wxCommandEvent& event )
|
|||
|
||||
void EDA_LIST_DIALOG::onListItemSelected( wxListEvent& event )
|
||||
{
|
||||
|
||||
if( m_callBackFct )
|
||||
if( m_cb_func )
|
||||
{
|
||||
m_messages->Clear();
|
||||
wxString text = GetTextSelection();
|
||||
m_callBackFct( text );
|
||||
m_cb_func( text, m_cb_data );
|
||||
m_messages->WriteText( text );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 )
|
||||
return;
|
||||
|
|
|
@ -41,100 +41,6 @@
|
|||
#include <wx/filename.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 )
|
||||
{
|
||||
|
|
|
@ -676,16 +676,17 @@ void ParseHotkeyConfig( const wxString& data,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 )
|
||||
void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList )
|
||||
{
|
||||
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
|
||||
wxString mask = wxT( "*." ) + ext;
|
||||
|
||||
#if 0 // pass in the project dir as an argument
|
||||
wxString path = wxPathOnly( Prj().GetProjectFullName() );
|
||||
#else
|
||||
wxString path = wxGetCwd();
|
||||
#endif
|
||||
|
||||
wxString filename = Kiface().Name() + wxT( '.' ) + ext;
|
||||
|
||||
filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ),
|
||||
|
@ -704,16 +705,17 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDesc
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 )
|
||||
void EDA_BASE_FRAME::ExportHotkeyConfigToFile( EDA_HOTKEY_CONFIG* aDescList )
|
||||
{
|
||||
wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
|
||||
wxString mask = wxT( "*." ) + ext;
|
||||
|
||||
#if 0
|
||||
wxString path = wxPathOnly( Prj().GetProjectFullName() );
|
||||
#else
|
||||
wxString path = wxGetCwd();
|
||||
#endif
|
||||
|
||||
wxString filename = Kiface().Name() + wxT( "." ) + ext;
|
||||
|
||||
filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ),
|
||||
|
|
|
@ -364,6 +364,8 @@ bool PGM_BASE::initPgm()
|
|||
{
|
||||
wxFileName pgm_name( App().argv[0] );
|
||||
|
||||
wxConfigBase::DontCreateOnDemand();
|
||||
|
||||
wxInitAllImageHandlers();
|
||||
|
||||
m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) + wxGetUserId() );
|
||||
|
@ -536,7 +538,9 @@ void PGM_BASE::saveCommonSettings()
|
|||
// process startup: initPgm(), so test before using:
|
||||
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()
|
|||
|
||||
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
|
||||
// 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];
|
||||
m_elems[i] = NULL;
|
||||
SetElem( ELEM_T( i ), NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,23 +64,27 @@ PROJECT::~PROJECT()
|
|||
|
||||
void PROJECT::SetProjectFullName( const wxString& aFullPathAndName )
|
||||
{
|
||||
m_project_name = aFullPathAndName;
|
||||
|
||||
wxASSERT( m_project_name.GetName() == NAMELESS_PROJECT || m_project_name.IsAbsolute() );
|
||||
#if 0
|
||||
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
|
||||
// the project pointer.
|
||||
// Edge transitions only. This is what clears the project
|
||||
// data using the Clear() function.
|
||||
if( m_project_name != aFullPathAndName )
|
||||
{
|
||||
wxString path = m_project_name.GetPath();
|
||||
Clear(); // clear the data when the project changes.
|
||||
|
||||
// wxLogDebug( wxT( "Setting env %s to '%s'." ), PROJECT_VAR_NAME, GetChars( path ) );
|
||||
DBG(printf( "%s: old:'%s' new:'%s'\n", __func__, TO_UTF8( GetProjectFullName() ), TO_UTF8( aFullPathAndName ) );)
|
||||
|
||||
wxSetEnv( PROJECT_VAR_NAME, path );
|
||||
m_project_name = aFullPathAndName;
|
||||
|
||||
wxASSERT( m_project_name.IsAbsolute() );
|
||||
|
||||
wxASSERT( m_project_name.GetExt() == ProjectFileExtension );
|
||||
|
||||
// until multiple projects are in play, set an environment variable for the
|
||||
// the project pointer.
|
||||
{
|
||||
wxString path = m_project_name.GetPath();
|
||||
|
||||
wxSetEnv( PROJECT_VAR_NAME, path );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,90 +190,63 @@ void PROJECT::SetElem( ELEM_T aIndex, _ELEM* aElem )
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// non-member so it can be moved easily, and kept REALLY private.
|
||||
// Do NOT Clear() in here.
|
||||
static void add_search_paths( SEARCH_STACK* aDst, wxConfigBase* aCfg, int aIndex )
|
||||
static bool copy_pro_file_template( const SEARCH_STACK& aSearchS, const wxString& aDestination )
|
||||
{
|
||||
for( int i=1; true; ++i )
|
||||
wxString templateFile = wxT( "kicad." ) + ProjectFileExtension;
|
||||
|
||||
wxString kicad_pro_template = aSearchS.FindValidPath( templateFile );
|
||||
|
||||
if( !kicad_pro_template )
|
||||
{
|
||||
wxString key = wxString::Format( wxT( "LibraryPath%d" ), i );
|
||||
wxString upath = aCfg->Read( key, wxEmptyString );
|
||||
DBG( printf( "%s: template file '%s' not found using search paths.\n", __func__, TO_UTF8( templateFile ) );)
|
||||
|
||||
if( !upath )
|
||||
break;
|
||||
wxFileName templ( wxStandardPaths::Get().GetDocumentsDir(),
|
||||
wxT( "kicad" ), ProjectFileExtension );
|
||||
|
||||
aDst->AddPaths( upath, aIndex );
|
||||
if( !templ.IsFileReadable() )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Unable to find '%s' template config file." ),
|
||||
GetChars( templateFile ) );
|
||||
|
||||
DisplayError( NULL, msg );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
kicad_pro_template = templ.GetFullPath();
|
||||
}
|
||||
}
|
||||
|
||||
DBG( printf( "%s: using template file '%s' as project file.\n", __func__, TO_UTF8( kicad_pro_template ) );)
|
||||
|
||||
// non-member so it can be moved easily, and kept REALLY private.
|
||||
// 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;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString& aFileName,
|
||||
const wxString& aGroupName, bool aForceUseLocalConfig )
|
||||
wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList,
|
||||
const wxString& aGroupName, const wxString& aFileName )
|
||||
{
|
||||
wxConfigBase* cfg = 0;
|
||||
wxString cur_pro_fn = !aFileName ? GetProjectFullName() : aFileName;
|
||||
|
||||
wxFileName fn = aFileName;
|
||||
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() )
|
||||
if( wxFileName( cur_pro_fn ).IsFileReadable() )
|
||||
{
|
||||
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
|
||||
* project file.
|
||||
*
|
||||
|
@ -286,12 +264,11 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString&
|
|||
if( version > 0 )
|
||||
{
|
||||
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
|
||||
SetProjectFullName( cur_pro_fn );
|
||||
return cfg;
|
||||
}
|
||||
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;
|
||||
cfg = 0;
|
||||
}
|
||||
|
@ -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.
|
||||
// Use the template kicad.pro file. Find it by using caller's SEARCH_STACK.
|
||||
wxString templateFile = wxT( "kicad." ) + ProjectFileExtension;
|
||||
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 ) );
|
||||
copy_pro_file_template( aSList, cur_pro_fn );
|
||||
|
||||
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString );
|
||||
|
||||
cfg->DontCreateOnDemand();
|
||||
|
||||
SetProjectFullName( cur_pro_fn );
|
||||
return cfg;
|
||||
}
|
||||
|
||||
|
||||
void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aFileName,
|
||||
const wxString& aGroupName, const PARAM_CFG_ARRAY& aParams )
|
||||
void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aGroupName,
|
||||
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() )
|
||||
{
|
||||
|
@ -373,11 +319,10 @@ void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aFileName
|
|||
}
|
||||
|
||||
|
||||
bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName,
|
||||
const wxString& aGroupName, const PARAM_CFG_ARRAY& aParams,
|
||||
bool doLoadOnlyIfNew )
|
||||
bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aGroupName,
|
||||
const PARAM_CFG_ARRAY& aParams, const wxString& aForeignProjectFileName )
|
||||
{
|
||||
std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aFileName, aGroupName, false ) );
|
||||
std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aGroupName, aForeignProjectFileName ) );
|
||||
|
||||
if( !cfg.get() )
|
||||
{
|
||||
|
@ -389,11 +334,6 @@ bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName,
|
|||
|
||||
wxString timestamp = cfg->Read( wxT( "update" ) );
|
||||
|
||||
if( doLoadOnlyIfNew && timestamp.size() && timestamp == m_pro_date_and_time )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pro_date_and_time = timestamp;
|
||||
|
||||
wxConfigLoadParams( cfg.get(), aParams, aGroupName );
|
||||
|
@ -401,3 +341,17 @@ bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName,
|
|||
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 @@
|
|||
#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;
|
||||
wxString filename = aFullFilename;
|
||||
|
||||
|
@ -33,7 +55,7 @@ wxString SEARCH_STACK::FilenameWithRelativePathInSearchList( const wxString& aFu
|
|||
fn = aFullFilename;
|
||||
|
||||
// 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
|
||||
continue;
|
||||
|
@ -52,13 +74,16 @@ wxString SEARCH_STACK::FilenameWithRelativePathInSearchList( const wxString& aFu
|
|||
|
||||
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 );
|
||||
}
|
||||
|
@ -68,15 +93,17 @@ void SEARCH_STACK::RemovePaths( const wxString& aPaths )
|
|||
|
||||
void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
|
||||
{
|
||||
bool isCS = wxFileName::IsCaseSensitive();
|
||||
wxStringTokenizer tokenizer( aPaths, PATH_SEPS, wxTOKEN_STRTOK );
|
||||
bool isCS = wxFileName::IsCaseSensitive();
|
||||
wxArrayString paths;
|
||||
|
||||
Split( &paths, aPaths );
|
||||
|
||||
// appending all of them, on large or negative aIndex
|
||||
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 )
|
||||
&& Index( path, isCS ) == wxNOT_FOUND )
|
||||
|
@ -89,9 +116,9 @@ void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
|
|||
// inserting all of them:
|
||||
else
|
||||
{
|
||||
while( tokenizer.HasMoreTokens() )
|
||||
for( unsigned i=0; i<paths.GetCount(); ++i )
|
||||
{
|
||||
wxString path = tokenizer.GetNextToken();
|
||||
wxString path = paths[i];
|
||||
|
||||
if( wxFileName::IsDirReadable( path )
|
||||
&& Index( path, isCS ) == wxNOT_FOUND )
|
||||
|
@ -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 )
|
||||
{
|
||||
wxString path;
|
||||
|
@ -142,6 +171,7 @@ const wxString SEARCH_STACK::LastVisitedPath( const wxString& aSubPathToSearch )
|
|||
|
||||
return path;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
|
|
@ -270,20 +270,6 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
|
|||
argv1.MakeAbsolute();
|
||||
|
||||
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:
|
||||
|
@ -298,24 +284,6 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
|
|||
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();
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <common.h>
|
||||
#include <kiface_i.h>
|
||||
#include <project.h>
|
||||
#include <confirm.h>
|
||||
#include <gestfich.h>
|
||||
|
@ -91,7 +92,8 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
|
|||
char Line[1024];
|
||||
FILE* file;
|
||||
size_t ii;
|
||||
SEARCH_STACK& search = Prj().SchSearchS();
|
||||
|
||||
SEARCH_STACK& search = Kiface().KifaceSearch();
|
||||
|
||||
if( m_netlist.IsEmpty() )
|
||||
return;
|
||||
|
|
|
@ -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_AliasLibNames.Clear();
|
||||
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
// 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() )
|
||||
m_NetlistFileExtension = wxT( "net" );
|
||||
|
||||
// Force FP_LIB_TABLE to be loaded on demand.
|
||||
prj.ElemClear( PROJECT::ELEM_FPTBL );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
|
||||
{
|
||||
wxFileName fn = m_NetlistFileName;
|
||||
PROJECT& prj = Prj();
|
||||
wxFileName fn = prj.AbsolutePath( m_NetlistFileName.GetFullPath() );
|
||||
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
|
@ -103,11 +98,8 @@ void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
|
|||
if( !IsWritable( fn ) )
|
||||
return;
|
||||
|
||||
// was:
|
||||
// Pgm().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
|
||||
wxString pro_name = fn.GetFullPath();
|
||||
|
||||
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:
|
|||
* Function LoadProjectFile
|
||||
* reads the configuration parameter from the project (.pro) file \a aFileName
|
||||
*/
|
||||
void LoadProjectFile( const wxString& aFileName );
|
||||
void LoadProjectFile();
|
||||
|
||||
void LoadSettings( wxConfigBase* aCfg ); // override virtual
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
|
|||
if( m_compListBox == NULL )
|
||||
return false;
|
||||
|
||||
LoadProjectFile( m_NetlistFileName.GetFullPath() );
|
||||
LoadProjectFile();
|
||||
LoadFootprintFiles();
|
||||
|
||||
BuildFOOTPRINTS_LISTBOX();
|
||||
|
|
|
@ -95,18 +95,18 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
|
|||
// Set sheet number and number of sheets.
|
||||
SetSheetNumberAndCount();
|
||||
|
||||
/* Build component list */
|
||||
// Build component list
|
||||
if( aAnnotateSchematic )
|
||||
{
|
||||
sheets.GetComponents( references );
|
||||
sheets.GetComponents( Prj().SchLibs(), references );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CurrentSheet->GetComponents( references );
|
||||
m_CurrentSheet->GetComponents( Prj().SchLibs(), references );
|
||||
}
|
||||
|
||||
/* Break full components reference in name (prefix) and number:
|
||||
* example: IC1 become IC, and 1 */
|
||||
// Break full components reference in name (prefix) and number:
|
||||
// example: IC1 become IC, and 1
|
||||
references.SplitReferences();
|
||||
|
||||
switch( aSortOption )
|
||||
|
@ -172,15 +172,15 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
|
|||
|
||||
int SCH_EDIT_FRAME::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly )
|
||||
{
|
||||
/* build the screen list */
|
||||
// build the screen list
|
||||
SCH_SHEET_LIST SheetList;
|
||||
SCH_REFERENCE_LIST ComponentsList;
|
||||
|
||||
/* Build the list of components */
|
||||
// Build the list of components
|
||||
if( !aOneSheetOnly )
|
||||
SheetList.GetComponents( ComponentsList );
|
||||
SheetList.GetComponents( Prj().SchLibs(), ComponentsList );
|
||||
else
|
||||
m_CurrentSheet->GetComponents( ComponentsList );
|
||||
m_CurrentSheet->GetComponents( Prj().SchLibs(), ComponentsList );
|
||||
|
||||
return ComponentsList.CheckAnnotation( aMessageList );
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef
|
|||
SCH_SHEET_LIST sheets;
|
||||
bool isChanged = false;
|
||||
|
||||
sheets.GetComponents( refs, false );
|
||||
sheets.GetComponents( Prj().SchLibs(), refs, false );
|
||||
|
||||
DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) );
|
||||
PTREE doc;
|
||||
|
@ -98,7 +98,7 @@ void SCH_EDIT_FRAME::backAnnotateFootprints( const std::string& aChangedSetOfRef
|
|||
// We have found a candidate.
|
||||
// Note: it can be not unique (multiple parts per package)
|
||||
// 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 );
|
||||
const wxString& oldfp = fpfield->GetText();
|
||||
|
||||
|
@ -133,9 +133,9 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
|
|||
{
|
||||
// Build a flat list of components in schematic:
|
||||
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" ) );
|
||||
if( cmpFile == NULL )
|
||||
|
@ -196,9 +196,9 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
|
|||
if( Cmp_KEEPCASE( reference, referencesList[ii].GetRef() ) == 0 )
|
||||
{
|
||||
// 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
|
||||
SCH_COMPONENT* component = referencesList[ii].GetComponent();
|
||||
SCH_COMPONENT* component = referencesList[ii].GetComp();
|
||||
SCH_FIELD* fpfield = component->GetField( FOOTPRINT );
|
||||
|
||||
fpfield->SetText( footprint );
|
||||
|
@ -218,7 +218,7 @@ bool SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile( const wxString& aFullFilenam
|
|||
|
||||
bool SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile()
|
||||
{
|
||||
wxString path = wxGetCwd();
|
||||
wxString path = wxPathOnly( Prj().GetProjectFullName() );
|
||||
|
||||
wxFileDialog dlg( this, _( "Load Component-Footprint Link File" ),
|
||||
path, wxEmptyString,
|
||||
|
|
|
@ -109,12 +109,12 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
|
||||
break;
|
||||
|
||||
case BLOCK_DRAG:
|
||||
case BLOCK_DRAG: // Drag
|
||||
case BLOCK_DRAG_ITEM:
|
||||
case BLOCK_MOVE:
|
||||
case BLOCK_COPY:
|
||||
if ( m_component )
|
||||
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
|
||||
case BLOCK_MOVE: // Move
|
||||
case BLOCK_COPY: // Copy
|
||||
if( GetCurPart() )
|
||||
ItemCount = GetCurPart()->SelectItems( GetScreen()->m_BlockLocate,
|
||||
m_unit, m_convert,
|
||||
m_editPinsPerPartOrConvert );
|
||||
if( ItemCount )
|
||||
|
@ -139,57 +139,56 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
|
||||
break;
|
||||
|
||||
case BLOCK_DELETE: /* Delete */
|
||||
if ( m_component )
|
||||
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
|
||||
case BLOCK_DELETE: // Delete
|
||||
if( GetCurPart() )
|
||||
ItemCount = GetCurPart()->SelectItems( GetScreen()->m_BlockLocate,
|
||||
m_unit, m_convert,
|
||||
m_editPinsPerPartOrConvert );
|
||||
if( ItemCount )
|
||||
SaveCopyInUndoList( m_component );
|
||||
SaveCopyInUndoList( GetCurPart() );
|
||||
|
||||
if ( m_component )
|
||||
if( GetCurPart() )
|
||||
{
|
||||
m_component->DeleteSelectedItems();
|
||||
GetCurPart()->DeleteSelectedItems();
|
||||
OnModify();
|
||||
}
|
||||
break;
|
||||
|
||||
case BLOCK_SAVE: /* Save */
|
||||
case BLOCK_SAVE: // Save
|
||||
case BLOCK_PASTE:
|
||||
case BLOCK_FLIP:
|
||||
break;
|
||||
|
||||
|
||||
case BLOCK_ROTATE:
|
||||
case BLOCK_MIRROR_X:
|
||||
case BLOCK_MIRROR_Y:
|
||||
if ( m_component )
|
||||
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
|
||||
if( GetCurPart() )
|
||||
ItemCount = GetCurPart()->SelectItems( GetScreen()->m_BlockLocate,
|
||||
m_unit, m_convert,
|
||||
m_editPinsPerPartOrConvert );
|
||||
if( ItemCount )
|
||||
SaveCopyInUndoList( m_component );
|
||||
SaveCopyInUndoList( GetCurPart() );
|
||||
|
||||
pt = GetScreen()->m_BlockLocate.Centre();
|
||||
pt = GetNearestGridPosition( pt );
|
||||
NEGATE( pt.y );
|
||||
|
||||
if ( m_component )
|
||||
if( GetCurPart() )
|
||||
{
|
||||
OnModify();
|
||||
int block_cmd = GetScreen()->m_BlockLocate.GetCommand();
|
||||
|
||||
if( block_cmd == BLOCK_MIRROR_Y)
|
||||
m_component->MirrorSelectedItemsH( pt );
|
||||
GetCurPart()->MirrorSelectedItemsH( pt );
|
||||
else if( block_cmd == BLOCK_MIRROR_X)
|
||||
m_component->MirrorSelectedItemsV( pt );
|
||||
GetCurPart()->MirrorSelectedItemsV( pt );
|
||||
else if( block_cmd == BLOCK_ROTATE )
|
||||
m_component->RotateSelectedItems( pt );
|
||||
GetCurPart()->RotateSelectedItems( pt );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case BLOCK_ZOOM: /* Window Zoom */
|
||||
case BLOCK_ZOOM: // Window Zoom
|
||||
Window_Zoom( GetScreen()->m_BlockLocate );
|
||||
break;
|
||||
|
||||
|
@ -200,10 +199,10 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|||
break;
|
||||
}
|
||||
|
||||
if( ! nextCmd )
|
||||
if( !nextCmd )
|
||||
{
|
||||
if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY && m_component )
|
||||
m_component->ClearSelectedItems();
|
||||
if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY && GetCurPart() )
|
||||
GetCurPart()->ClearSelectedItems();
|
||||
|
||||
GetScreen()->m_BlockLocate.SetState( STATE_NO_BLOCK );
|
||||
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
|
||||
|
@ -233,62 +232,62 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
case BLOCK_IDLE:
|
||||
break;
|
||||
|
||||
case BLOCK_DRAG:
|
||||
case BLOCK_DRAG: // Drag
|
||||
case BLOCK_DRAG_ITEM:
|
||||
case BLOCK_MOVE:
|
||||
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
||||
case BLOCK_MOVE: // Move
|
||||
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
||||
GetScreen()->m_BlockLocate.ClearItemsList();
|
||||
|
||||
if ( m_component )
|
||||
SaveCopyInUndoList( m_component );
|
||||
if( GetCurPart() )
|
||||
SaveCopyInUndoList( GetCurPart() );
|
||||
|
||||
pt = GetScreen()->m_BlockLocate.GetMoveVector();
|
||||
pt.y *= -1;
|
||||
|
||||
if ( m_component )
|
||||
m_component->MoveSelectedItems( pt );
|
||||
if( GetCurPart() )
|
||||
GetCurPart()->MoveSelectedItems( pt );
|
||||
|
||||
m_canvas->Refresh( true );
|
||||
break;
|
||||
|
||||
case BLOCK_COPY: /* Copy */
|
||||
case BLOCK_COPY: // Copy
|
||||
GetScreen()->m_BlockLocate.ClearItemsList();
|
||||
|
||||
if ( m_component )
|
||||
SaveCopyInUndoList( m_component );
|
||||
if( GetCurPart() )
|
||||
SaveCopyInUndoList( GetCurPart() );
|
||||
|
||||
pt = GetScreen()->m_BlockLocate.GetMoveVector();
|
||||
NEGATE( pt.y );
|
||||
|
||||
if ( m_component )
|
||||
m_component->CopySelectedItems( pt );
|
||||
if( GetCurPart() )
|
||||
GetCurPart()->CopySelectedItems( pt );
|
||||
|
||||
break;
|
||||
|
||||
case BLOCK_PASTE: /* Paste (recopy the last block saved) */
|
||||
case BLOCK_PASTE: // Paste (recopy the last block saved)
|
||||
GetScreen()->m_BlockLocate.ClearItemsList();
|
||||
break;
|
||||
|
||||
case BLOCK_ROTATE: // 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
|
||||
if ( m_component )
|
||||
SaveCopyInUndoList( m_component );
|
||||
if( GetCurPart() )
|
||||
SaveCopyInUndoList( GetCurPart() );
|
||||
|
||||
pt = GetScreen()->m_BlockLocate.Centre();
|
||||
pt = GetNearestGridPosition( pt );
|
||||
NEGATE( pt.y );
|
||||
|
||||
if ( m_component )
|
||||
if( GetCurPart() )
|
||||
{
|
||||
int block_cmd = GetScreen()->m_BlockLocate.GetCommand();
|
||||
|
||||
if( block_cmd == BLOCK_MIRROR_Y)
|
||||
m_component->MirrorSelectedItemsH( pt );
|
||||
GetCurPart()->MirrorSelectedItemsH( pt );
|
||||
else if( block_cmd == BLOCK_MIRROR_X)
|
||||
m_component->MirrorSelectedItemsV( pt );
|
||||
GetCurPart()->MirrorSelectedItemsV( pt );
|
||||
else if( block_cmd == BLOCK_ROTATE )
|
||||
m_component->RotateSelectedItems( pt );
|
||||
GetCurPart()->RotateSelectedItems( pt );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -326,7 +325,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
|
|||
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
|
||||
wxASSERT( parent != NULL );
|
||||
|
||||
LIB_COMPONENT* component = parent->GetComponent();
|
||||
LIB_PART* component = parent->GetCurPart();
|
||||
|
||||
if( component == NULL )
|
||||
return;
|
||||
|
|
|
@ -51,36 +51,30 @@
|
|||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
// Set this to 1 to print debugging output in alias and component destructors to verify
|
||||
// objects get cleaned up properly.
|
||||
#if defined( TRACE_DESTRUCTOR )
|
||||
#undef TRACE_DESTRUCTOR
|
||||
#endif
|
||||
|
||||
#define TRACE_DESTRUCTOR 0
|
||||
|
||||
// the separator char between the subpart id and the reference
|
||||
// 0 (no separator) or '.' or some other character
|
||||
int LIB_COMPONENT::m_subpartIdSeparator = 0;
|
||||
int LIB_PART::m_subpartIdSeparator = 0;
|
||||
|
||||
// the ascii char value to calculate the subpart symbol id from the part number:
|
||||
// 'A' or '1' usually. (to print U1.A or U1.1)
|
||||
// if this a a digit, a number is used as id symbol
|
||||
int LIB_COMPONENT::m_subpartFirstId = 'A';
|
||||
int LIB_PART::m_subpartFirstId = 'A';
|
||||
|
||||
|
||||
LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent ):
|
||||
EDA_ITEM( LIB_ALIAS_T )
|
||||
LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_PART* aRootPart ):
|
||||
EDA_ITEM( LIB_ALIAS_T ),
|
||||
shared( aRootPart )
|
||||
{
|
||||
root = aRootComponent;
|
||||
name = aName;
|
||||
}
|
||||
|
||||
|
||||
LIB_ALIAS::LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent ) :
|
||||
EDA_ITEM( aAlias )
|
||||
LIB_ALIAS::LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_PART* aRootPart ) :
|
||||
EDA_ITEM( aAlias ),
|
||||
shared( aRootPart )
|
||||
{
|
||||
name = aAlias.name;
|
||||
root = aRootComponent;
|
||||
name = aAlias.name;
|
||||
|
||||
description = aAlias.description;
|
||||
keyWords = aAlias.keyWords;
|
||||
docFileName = aAlias.docFileName;
|
||||
|
@ -89,17 +83,24 @@ LIB_ALIAS::LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent ) :
|
|||
|
||||
LIB_ALIAS::~LIB_ALIAS()
|
||||
{
|
||||
#if TRACE_DESTRUCTOR
|
||||
wxLogDebug( wxT( "Destroying alias \"%s\" of component \"%s\" with alias list count %d." ),
|
||||
GetChars( name ), GetChars( root->GetName() ), root->m_aliases.size() );
|
||||
wxASSERT_MSG( shared, wxT( "~LIB_ALIAS() without a LIB_PART" ) );
|
||||
|
||||
#if defined(DEBUG) && 1
|
||||
printf( "%s: destroying alias:'%s' of part:'%s' alias count:%zd.\n",
|
||||
__func__, TO_UTF8( name ), TO_UTF8( shared->GetName() ), shared->m_aliases.size() );
|
||||
#endif
|
||||
|
||||
if( shared )
|
||||
shared->RemoveAlias( this );
|
||||
}
|
||||
|
||||
|
||||
wxString LIB_ALIAS::GetLibraryName()
|
||||
const wxString LIB_ALIAS::GetLibraryName()
|
||||
{
|
||||
if( GetComponent() )
|
||||
return GetComponent()->GetLibraryName();
|
||||
wxASSERT_MSG( shared, wxT( "LIB_ALIAS without a LIB_PART" ) );
|
||||
|
||||
if( shared )
|
||||
return shared->GetLibraryName();
|
||||
|
||||
return wxString( _( "none" ) );
|
||||
}
|
||||
|
@ -107,12 +108,13 @@ wxString LIB_ALIAS::GetLibraryName()
|
|||
|
||||
bool LIB_ALIAS::IsRoot() const
|
||||
{
|
||||
return name.CmpNoCase( root->GetName() ) == 0;
|
||||
return Cmp_KEEPCASE( name, shared->GetName() ) == 0;
|
||||
}
|
||||
|
||||
CMP_LIBRARY* LIB_ALIAS::GetLibrary()
|
||||
|
||||
PART_LIB* LIB_ALIAS::GetLib()
|
||||
{
|
||||
return root->GetLibrary();
|
||||
return shared->GetLib();
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,24 +149,34 @@ bool LIB_ALIAS::SaveDoc( OUTPUTFORMATTER& aFormatter )
|
|||
|
||||
bool LIB_ALIAS::operator==( const wxChar* aName ) const
|
||||
{
|
||||
return name.CmpNoCase( aName ) == 0;
|
||||
return Cmp_KEEPCASE( name, aName ) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool operator<( const LIB_ALIAS& aItem1, const LIB_ALIAS& aItem2 )
|
||||
{
|
||||
return aItem1.GetName().CmpNoCase( aItem2.GetName() ) < 0;
|
||||
return Cmp_KEEPCASE( aItem1.GetName(), aItem2.GetName() ) < 0;
|
||||
}
|
||||
|
||||
|
||||
int LibraryEntryCompare( const LIB_ALIAS* aItem1, const LIB_ALIAS* aItem2 )
|
||||
{
|
||||
return aItem1->GetName().CmpNoCase( aItem2->GetName() );
|
||||
return Cmp_KEEPCASE( aItem1->GetName(), aItem2->GetName() );
|
||||
}
|
||||
|
||||
|
||||
LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) :
|
||||
EDA_ITEM( LIB_COMPONENT_T )
|
||||
/// http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
|
||||
struct null_deleter
|
||||
{
|
||||
void operator()(void const *) const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
LIB_PART::LIB_PART( const wxString& aName, PART_LIB* aLibrary ) :
|
||||
EDA_ITEM( LIB_PART_T ),
|
||||
m_me( this, null_deleter() )
|
||||
{
|
||||
m_name = aName;
|
||||
m_library = aLibrary;
|
||||
|
@ -192,23 +204,24 @@ LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) :
|
|||
}
|
||||
|
||||
|
||||
LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary ) :
|
||||
EDA_ITEM( aComponent )
|
||||
LIB_PART::LIB_PART( LIB_PART& aPart, PART_LIB* aLibrary ) :
|
||||
EDA_ITEM( aPart ),
|
||||
m_me( this, null_deleter() )
|
||||
{
|
||||
LIB_ITEM* newItem;
|
||||
|
||||
m_library = aLibrary;
|
||||
m_name = aComponent.m_name;
|
||||
m_FootprintList = aComponent.m_FootprintList;
|
||||
m_unitCount = aComponent.m_unitCount;
|
||||
m_unitsLocked = aComponent.m_unitsLocked;
|
||||
m_pinNameOffset = aComponent.m_pinNameOffset;
|
||||
m_showPinNumbers = aComponent.m_showPinNumbers;
|
||||
m_showPinNames = aComponent.m_showPinNames;
|
||||
m_dateModified = aComponent.m_dateModified;
|
||||
m_options = aComponent.m_options;
|
||||
m_name = aPart.m_name;
|
||||
m_FootprintList = aPart.m_FootprintList;
|
||||
m_unitCount = aPart.m_unitCount;
|
||||
m_unitsLocked = aPart.m_unitsLocked;
|
||||
m_pinNameOffset = aPart.m_pinNameOffset;
|
||||
m_showPinNumbers = aPart.m_showPinNumbers;
|
||||
m_showPinNames = aPart.m_showPinNames;
|
||||
m_dateModified = aPart.m_dateModified;
|
||||
m_options = aPart.m_options;
|
||||
|
||||
BOOST_FOREACH( LIB_ITEM& oldItem, aComponent.GetDrawItemList() )
|
||||
BOOST_FOREACH( LIB_ITEM& oldItem, aPart.GetDrawItemList() )
|
||||
{
|
||||
if( oldItem.IsNew() )
|
||||
continue;
|
||||
|
@ -218,47 +231,49 @@ LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary )
|
|||
drawings.push_back( newItem );
|
||||
}
|
||||
|
||||
for( size_t i = 0; i < aComponent.m_aliases.size(); i++ )
|
||||
for( size_t i = 0; i < aPart.m_aliases.size(); i++ )
|
||||
{
|
||||
LIB_ALIAS* alias = new LIB_ALIAS( *aComponent.m_aliases[i], this );
|
||||
LIB_ALIAS* alias = new LIB_ALIAS( *aPart.m_aliases[i], this );
|
||||
m_aliases.push_back( alias );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LIB_COMPONENT::~LIB_COMPONENT()
|
||||
LIB_PART::~LIB_PART()
|
||||
{
|
||||
#if TRACE_DESTRUCTOR
|
||||
wxLogDebug( wxT( "Destroying component <%s> with alias list count of %d" ),
|
||||
GetChars( GetName() ), m_aliases.size() );
|
||||
#if defined(DEBUG) && 1
|
||||
|
||||
if( m_aliases.size() )
|
||||
{
|
||||
int breakhere = 1;
|
||||
(void) breakhere;
|
||||
}
|
||||
|
||||
printf( "%s: destroying part '%s' with alias list count of %zd\n",
|
||||
__func__, TO_UTF8( GetName() ), m_aliases.size() );
|
||||
#endif
|
||||
|
||||
// If the component is being delete directly rather than trough the library, free all
|
||||
// of the memory allocated by the aliases.
|
||||
if( !m_aliases.empty() )
|
||||
// If the part is being deleted directly rather than through the library,
|
||||
// delete all of the aliases.
|
||||
while( m_aliases.size() )
|
||||
{
|
||||
LIB_ALIAS* alias;
|
||||
|
||||
while( !m_aliases.empty() )
|
||||
{
|
||||
alias = m_aliases.back();
|
||||
m_aliases.pop_back();
|
||||
delete alias;
|
||||
}
|
||||
LIB_ALIAS* alias = m_aliases.back();
|
||||
m_aliases.pop_back();
|
||||
delete alias;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxString LIB_COMPONENT::GetLibraryName()
|
||||
const wxString LIB_PART::GetLibraryName()
|
||||
{
|
||||
if( m_library != NULL )
|
||||
if( m_library )
|
||||
return m_library->GetName();
|
||||
|
||||
return wxString( _( "none" ) );
|
||||
}
|
||||
|
||||
|
||||
wxString LIB_COMPONENT::SubReference( int aUnit, bool aAddSeparator )
|
||||
wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator )
|
||||
{
|
||||
wxString subRef;
|
||||
|
||||
|
@ -274,7 +289,7 @@ wxString LIB_COMPONENT::SubReference( int aUnit, bool aAddSeparator )
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::SetName( const wxString& aName )
|
||||
void LIB_PART::SetName( const wxString& aName )
|
||||
{
|
||||
m_name = aName;
|
||||
GetValueField().SetText( aName );
|
||||
|
@ -282,7 +297,7 @@ void LIB_COMPONENT::SetName( const wxString& aName )
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, int aMulti,
|
||||
void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, int aMulti,
|
||||
int aConvert, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor, const TRANSFORM& aTransform,
|
||||
bool aShowPinText, bool aDrawFields, bool aOnlySelected )
|
||||
{
|
||||
|
@ -390,7 +405,7 @@ void LIB_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOff
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
|
||||
void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
|
||||
const wxPoint& aOffset, const TRANSFORM& aTransform )
|
||||
{
|
||||
wxASSERT( aPlotter != NULL );
|
||||
|
@ -415,7 +430,7 @@ void LIB_COMPONENT::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
|
|||
}
|
||||
}
|
||||
|
||||
void LIB_COMPONENT::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
|
||||
void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
|
||||
const wxPoint& aOffset, const TRANSFORM& aTransform )
|
||||
{
|
||||
wxASSERT( aPlotter != NULL );
|
||||
|
@ -449,7 +464,7 @@ void LIB_COMPONENT::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc )
|
||||
void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc )
|
||||
{
|
||||
wxASSERT( aItem != NULL );
|
||||
|
||||
|
@ -461,10 +476,10 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxD
|
|||
|
||||
if( field->GetId() < MANDATORY_FIELDS )
|
||||
{
|
||||
wxLogWarning( _( "An attempt was made to remove the %s field \
|
||||
from component %s in library %s." ),
|
||||
GetChars( field->GetName() ), GetChars( GetName() ),
|
||||
GetChars( GetLibraryName() ) );
|
||||
wxLogWarning( _(
|
||||
"An attempt was made to remove the %s field from component %s in library %s." ),
|
||||
GetChars( field->GetName() ), GetChars( GetName() ),
|
||||
GetChars( GetLibraryName() ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -486,7 +501,7 @@ from component %s in library %s." ),
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::AddDrawItem( LIB_ITEM* aItem )
|
||||
void LIB_PART::AddDrawItem( LIB_ITEM* aItem )
|
||||
{
|
||||
wxASSERT( aItem != NULL );
|
||||
|
||||
|
@ -495,7 +510,7 @@ void LIB_COMPONENT::AddDrawItem( LIB_ITEM* aItem )
|
|||
}
|
||||
|
||||
|
||||
LIB_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_ITEM* aItem, KICAD_T aType )
|
||||
LIB_ITEM* LIB_PART::GetNextDrawItem( LIB_ITEM* aItem, KICAD_T aType )
|
||||
{
|
||||
/* Return the next draw object pointer.
|
||||
* If item is NULL return the first item of type in the list.
|
||||
|
@ -532,7 +547,7 @@ LIB_ITEM* LIB_COMPONENT::GetNextDrawItem( LIB_ITEM* aItem, KICAD_T aType )
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
|
||||
void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
|
||||
{
|
||||
/* Notes:
|
||||
* when aUnit == 0: no unit filtering
|
||||
|
@ -558,7 +573,7 @@ void LIB_COMPONENT::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
|
|||
}
|
||||
|
||||
|
||||
LIB_PIN* LIB_COMPONENT::GetPin( const wxString& aNumber, int aUnit, int aConvert )
|
||||
LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert )
|
||||
{
|
||||
wxString pNumber;
|
||||
LIB_PINS pinList;
|
||||
|
@ -579,7 +594,7 @@ LIB_PIN* LIB_COMPONENT::GetPin( const wxString& aNumber, int aUnit, int aConvert
|
|||
}
|
||||
|
||||
|
||||
bool LIB_COMPONENT::Save( OUTPUTFORMATTER& aFormatter )
|
||||
bool LIB_PART::Save( OUTPUTFORMATTER& aFormatter )
|
||||
{
|
||||
LIB_FIELD& value = GetValueField();
|
||||
|
||||
|
@ -714,7 +729,7 @@ bool LIB_COMPONENT::Save( OUTPUTFORMATTER& aFormatter )
|
|||
}
|
||||
|
||||
|
||||
bool LIB_COMPONENT::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
|
||||
bool LIB_PART::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
|
||||
{
|
||||
int unused;
|
||||
char* p;
|
||||
|
@ -866,7 +881,7 @@ ok:
|
|||
}
|
||||
|
||||
|
||||
bool LIB_COMPONENT::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorMsg )
|
||||
bool LIB_PART::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorMsg )
|
||||
{
|
||||
char* line;
|
||||
LIB_ITEM* newEntry = NULL;
|
||||
|
@ -914,8 +929,8 @@ bool LIB_COMPONENT::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorM
|
|||
newEntry = ( LIB_ITEM* ) new LIB_BEZIER( this );
|
||||
break;
|
||||
|
||||
case '#': // Comment
|
||||
continue;
|
||||
case '#': // Comment
|
||||
continue;
|
||||
|
||||
default:
|
||||
aErrorMsg.Printf( wxT( "undefined DRAW command %c" ), line[0] );
|
||||
|
@ -924,7 +939,7 @@ bool LIB_COMPONENT::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorM
|
|||
|
||||
if( !newEntry->Load( aLineReader, aErrorMsg ) )
|
||||
{
|
||||
aErrorMsg.Printf( wxT( "error <%s> in DRAW command %c" ),
|
||||
aErrorMsg.Printf( wxT( "error '%s' in DRAW command %c" ),
|
||||
GetChars( aErrorMsg ), line[0] );
|
||||
delete newEntry;
|
||||
|
||||
|
@ -951,7 +966,7 @@ bool LIB_COMPONENT::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorM
|
|||
}
|
||||
|
||||
|
||||
bool LIB_COMPONENT::LoadAliases( char* aLine, wxString& aErrorMsg )
|
||||
bool LIB_PART::LoadAliases( char* aLine, wxString& aErrorMsg )
|
||||
{
|
||||
char* text = strtok( aLine, " \t\r\n" );
|
||||
|
||||
|
@ -965,7 +980,7 @@ bool LIB_COMPONENT::LoadAliases( char* aLine, wxString& aErrorMsg )
|
|||
}
|
||||
|
||||
|
||||
bool LIB_COMPONENT::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg )
|
||||
bool LIB_PART::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg )
|
||||
{
|
||||
LIB_FIELD* field = new LIB_FIELD( this );
|
||||
|
||||
|
@ -1000,7 +1015,7 @@ bool LIB_COMPONENT::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg )
|
|||
}
|
||||
|
||||
|
||||
bool LIB_COMPONENT::LoadFootprints( LINE_READER& aLineReader, wxString& aErrorMsg )
|
||||
bool LIB_PART::LoadFootprints( LINE_READER& aLineReader, wxString& aErrorMsg )
|
||||
{
|
||||
char* line;
|
||||
char* p;
|
||||
|
@ -1025,7 +1040,7 @@ bool LIB_COMPONENT::LoadFootprints( LINE_READER& aLineReader, wxString& aErrorMs
|
|||
}
|
||||
|
||||
|
||||
EDA_RECT LIB_COMPONENT::GetBoundingBox( int aUnit, int aConvert ) const
|
||||
EDA_RECT LIB_PART::GetBoundingBox( int aUnit, int aConvert ) const
|
||||
{
|
||||
EDA_RECT bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
|
||||
|
||||
|
@ -1050,7 +1065,7 @@ EDA_RECT LIB_COMPONENT::GetBoundingBox( int aUnit, int aConvert ) const
|
|||
}
|
||||
|
||||
|
||||
EDA_RECT LIB_COMPONENT::GetBodyBoundingBox( int aUnit, int aConvert ) const
|
||||
EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
|
||||
{
|
||||
EDA_RECT bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
|
||||
|
||||
|
@ -1075,7 +1090,7 @@ EDA_RECT LIB_COMPONENT::GetBodyBoundingBox( int aUnit, int aConvert ) const
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::deleteAllFields()
|
||||
void LIB_PART::deleteAllFields()
|
||||
{
|
||||
LIB_ITEMS::iterator it;
|
||||
|
||||
|
@ -1093,7 +1108,7 @@ void LIB_COMPONENT::deleteAllFields()
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::SetFields( const std::vector <LIB_FIELD>& aFields )
|
||||
void LIB_PART::SetFields( const std::vector <LIB_FIELD>& aFields )
|
||||
{
|
||||
deleteAllFields();
|
||||
|
||||
|
@ -1111,7 +1126,7 @@ void LIB_COMPONENT::SetFields( const std::vector <LIB_FIELD>& aFields )
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::GetFields( LIB_FIELDS& aList )
|
||||
void LIB_PART::GetFields( LIB_FIELDS& aList )
|
||||
{
|
||||
LIB_FIELD* field;
|
||||
|
||||
|
@ -1146,7 +1161,7 @@ void LIB_COMPONENT::GetFields( LIB_FIELDS& aList )
|
|||
}
|
||||
|
||||
|
||||
LIB_FIELD* LIB_COMPONENT::GetField( int aId )
|
||||
LIB_FIELD* LIB_PART::GetField( int aId )
|
||||
{
|
||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||
{
|
||||
|
@ -1163,7 +1178,7 @@ LIB_FIELD* LIB_COMPONENT::GetField( int aId )
|
|||
}
|
||||
|
||||
|
||||
LIB_FIELD* LIB_COMPONENT::FindField( const wxString& aFieldName )
|
||||
LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName )
|
||||
{
|
||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||
{
|
||||
|
@ -1180,7 +1195,7 @@ LIB_FIELD* LIB_COMPONENT::FindField( const wxString& aFieldName )
|
|||
}
|
||||
|
||||
|
||||
LIB_FIELD& LIB_COMPONENT::GetValueField()
|
||||
LIB_FIELD& LIB_PART::GetValueField()
|
||||
{
|
||||
LIB_FIELD* field = GetField( VALUE );
|
||||
wxASSERT( field != NULL );
|
||||
|
@ -1188,7 +1203,7 @@ LIB_FIELD& LIB_COMPONENT::GetValueField()
|
|||
}
|
||||
|
||||
|
||||
LIB_FIELD& LIB_COMPONENT::GetReferenceField()
|
||||
LIB_FIELD& LIB_PART::GetReferenceField()
|
||||
{
|
||||
LIB_FIELD* field = GetField( REFERENCE );
|
||||
wxASSERT( field != NULL );
|
||||
|
@ -1196,7 +1211,7 @@ LIB_FIELD& LIB_COMPONENT::GetReferenceField()
|
|||
}
|
||||
|
||||
|
||||
bool LIB_COMPONENT::SaveDateAndTime( OUTPUTFORMATTER& aFormatter )
|
||||
bool LIB_PART::SaveDateAndTime( OUTPUTFORMATTER& aFormatter )
|
||||
{
|
||||
int year, mon, day, hour, min, sec;
|
||||
|
||||
|
@ -1216,7 +1231,7 @@ bool LIB_COMPONENT::SaveDateAndTime( OUTPUTFORMATTER& aFormatter )
|
|||
}
|
||||
|
||||
|
||||
bool LIB_COMPONENT::LoadDateAndTime( char* aLine )
|
||||
bool LIB_PART::LoadDateAndTime( char* aLine )
|
||||
{
|
||||
int year, mon, day, hour, min, sec;
|
||||
|
||||
|
@ -1235,7 +1250,7 @@ bool LIB_COMPONENT::LoadDateAndTime( char* aLine )
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::SetOffset( const wxPoint& aOffset )
|
||||
void LIB_PART::SetOffset( const wxPoint& aOffset )
|
||||
{
|
||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||
{
|
||||
|
@ -1244,13 +1259,13 @@ void LIB_COMPONENT::SetOffset( const wxPoint& aOffset )
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::RemoveDuplicateDrawItems()
|
||||
void LIB_PART::RemoveDuplicateDrawItems()
|
||||
{
|
||||
drawings.unique();
|
||||
}
|
||||
|
||||
|
||||
bool LIB_COMPONENT::HasConversion() const
|
||||
bool LIB_PART::HasConversion() const
|
||||
{
|
||||
for( unsigned ii = 0; ii < drawings.size(); ii++ )
|
||||
{
|
||||
|
@ -1263,7 +1278,7 @@ bool LIB_COMPONENT::HasConversion() const
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::ClearStatus()
|
||||
void LIB_PART::ClearStatus()
|
||||
{
|
||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||
{
|
||||
|
@ -1272,7 +1287,7 @@ void LIB_COMPONENT::ClearStatus()
|
|||
}
|
||||
|
||||
|
||||
int LIB_COMPONENT::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aEditPinByPin )
|
||||
int LIB_PART::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aEditPinByPin )
|
||||
{
|
||||
int itemCount = 0;
|
||||
|
||||
|
@ -1303,7 +1318,7 @@ int LIB_COMPONENT::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool a
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::MoveSelectedItems( const wxPoint& aOffset )
|
||||
void LIB_PART::MoveSelectedItems( const wxPoint& aOffset )
|
||||
{
|
||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||
{
|
||||
|
@ -1318,7 +1333,7 @@ void LIB_COMPONENT::MoveSelectedItems( const wxPoint& aOffset )
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::ClearSelectedItems()
|
||||
void LIB_PART::ClearSelectedItems()
|
||||
{
|
||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||
{
|
||||
|
@ -1327,7 +1342,7 @@ void LIB_COMPONENT::ClearSelectedItems()
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::DeleteSelectedItems()
|
||||
void LIB_PART::DeleteSelectedItems()
|
||||
{
|
||||
LIB_ITEMS::iterator item = drawings.begin();
|
||||
|
||||
|
@ -1357,7 +1372,7 @@ void LIB_COMPONENT::DeleteSelectedItems()
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::CopySelectedItems( const wxPoint& aOffset )
|
||||
void LIB_PART::CopySelectedItems( const wxPoint& aOffset )
|
||||
{
|
||||
/* *do not* use iterators here, because new items
|
||||
* are added to drawings that is a boost::ptr_vector.
|
||||
|
@ -1390,7 +1405,7 @@ void LIB_COMPONENT::CopySelectedItems( const wxPoint& aOffset )
|
|||
|
||||
|
||||
|
||||
void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& aCenter )
|
||||
void LIB_PART::MirrorSelectedItemsH( const wxPoint& aCenter )
|
||||
{
|
||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||
{
|
||||
|
@ -1404,7 +1419,7 @@ void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& aCenter )
|
|||
drawings.sort();
|
||||
}
|
||||
|
||||
void LIB_COMPONENT::MirrorSelectedItemsV( const wxPoint& aCenter )
|
||||
void LIB_PART::MirrorSelectedItemsV( const wxPoint& aCenter )
|
||||
{
|
||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||
{
|
||||
|
@ -1418,7 +1433,7 @@ void LIB_COMPONENT::MirrorSelectedItemsV( const wxPoint& aCenter )
|
|||
drawings.sort();
|
||||
}
|
||||
|
||||
void LIB_COMPONENT::RotateSelectedItems( const wxPoint& aCenter )
|
||||
void LIB_PART::RotateSelectedItems( const wxPoint& aCenter )
|
||||
{
|
||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||
{
|
||||
|
@ -1434,7 +1449,7 @@ void LIB_COMPONENT::RotateSelectedItems( const wxPoint& aCenter )
|
|||
|
||||
|
||||
|
||||
LIB_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert,
|
||||
LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert,
|
||||
KICAD_T aType, const wxPoint& aPoint )
|
||||
{
|
||||
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
||||
|
@ -1452,7 +1467,7 @@ LIB_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert,
|
|||
}
|
||||
|
||||
|
||||
LIB_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
|
||||
LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
|
||||
const wxPoint& aPoint, const TRANSFORM& aTransform )
|
||||
{
|
||||
/* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const
|
||||
|
@ -1473,7 +1488,7 @@ LIB_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::SetPartCount( int aCount )
|
||||
void LIB_PART::SetUnitCount( int aCount )
|
||||
{
|
||||
if( m_unitCount == aCount )
|
||||
return;
|
||||
|
@ -1520,7 +1535,7 @@ void LIB_COMPONENT::SetPartCount( int aCount )
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::SetConversion( bool aSetConvert )
|
||||
void LIB_PART::SetConversion( bool aSetConvert )
|
||||
{
|
||||
if( aSetConvert == HasConversion() )
|
||||
return;
|
||||
|
@ -1559,7 +1574,7 @@ void LIB_COMPONENT::SetConversion( bool aSetConvert )
|
|||
}
|
||||
|
||||
|
||||
wxArrayString LIB_COMPONENT::GetAliasNames( bool aIncludeRoot ) const
|
||||
wxArrayString LIB_PART::GetAliasNames( bool aIncludeRoot ) const
|
||||
{
|
||||
wxArrayString names;
|
||||
|
||||
|
@ -1577,14 +1592,14 @@ wxArrayString LIB_COMPONENT::GetAliasNames( bool aIncludeRoot ) const
|
|||
}
|
||||
|
||||
|
||||
bool LIB_COMPONENT::HasAlias( const wxString& aName ) const
|
||||
bool LIB_PART::HasAlias( const wxString& aName ) const
|
||||
{
|
||||
wxCHECK2_MSG( !aName.IsEmpty(), return false,
|
||||
wxT( "Cannot get alias with an empty name, bad programmer." ) );
|
||||
|
||||
for( size_t i = 0; i < m_aliases.size(); i++ )
|
||||
{
|
||||
if( aName.CmpNoCase( m_aliases[i]->GetName() ) == 0 )
|
||||
if( Cmp_KEEPCASE( aName, m_aliases[i]->GetName() ) == 0 )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1592,10 +1607,10 @@ bool LIB_COMPONENT::HasAlias( const wxString& aName ) const
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::SetAliases( const wxArrayString& aAliasList )
|
||||
void LIB_PART::SetAliases( const wxArrayString& aAliasList )
|
||||
{
|
||||
wxCHECK_RET( m_library == NULL,
|
||||
wxT( "Component aliases cannot be changed when they are owned by a library." ) );
|
||||
wxCHECK_RET( !m_library,
|
||||
wxT( "Part aliases cannot be changed when they are owned by a library." ) );
|
||||
|
||||
if( aAliasList == GetAliasNames() )
|
||||
return;
|
||||
|
@ -1624,17 +1639,19 @@ void LIB_COMPONENT::SetAliases( const wxArrayString& aAliasList )
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::RemoveAlias( const wxString& aName )
|
||||
#if 0 // this version looked suspect to me, it did not rename a deleted root
|
||||
|
||||
void LIB_PART::RemoveAlias( const wxString& aName )
|
||||
{
|
||||
wxCHECK_RET( m_library == NULL,
|
||||
wxT( "Component aliases cannot be changed when they are owned by a library." ) );
|
||||
wxT( "Part aliases cannot be changed when they are owned by a library." ) );
|
||||
wxCHECK_RET( !aName.IsEmpty(), wxT( "Cannot get alias with an empty name." ) );
|
||||
|
||||
LIB_ALIASES::iterator it;
|
||||
|
||||
for( it = m_aliases.begin(); it < m_aliases.end(); it++ )
|
||||
{
|
||||
if( aName.CmpNoCase( (*it)->GetName() ) == 0 )
|
||||
if( Cmp_KEEPCASE( aName, (*it)->GetName() ) == 0 )
|
||||
{
|
||||
m_aliases.erase( it );
|
||||
break;
|
||||
|
@ -1642,39 +1659,53 @@ void LIB_COMPONENT::RemoveAlias( const wxString& aName )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
LIB_ALIAS* LIB_COMPONENT::RemoveAlias( LIB_ALIAS* aAlias )
|
||||
#else
|
||||
void LIB_PART::RemoveAlias( const wxString& aName )
|
||||
{
|
||||
wxCHECK_MSG( aAlias != NULL, NULL, wxT( "Cannot remove alias by NULL pointer." ) );
|
||||
LIB_ALIAS* a = GetAlias( aName );
|
||||
|
||||
if( a )
|
||||
RemoveAlias( a );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
LIB_ALIAS* LIB_PART::RemoveAlias( LIB_ALIAS* aAlias )
|
||||
{
|
||||
wxCHECK_MSG( aAlias, NULL, wxT( "Cannot remove alias by NULL pointer." ) );
|
||||
|
||||
LIB_ALIAS* nextAlias = NULL;
|
||||
|
||||
LIB_ALIASES::iterator it = find( m_aliases.begin(), m_aliases.end(), aAlias );
|
||||
|
||||
if( it != m_aliases.end() )
|
||||
{
|
||||
bool rename = aAlias->IsRoot();
|
||||
|
||||
DBG( printf( "%s: part:'%s' alias:'%s'\n", __func__,
|
||||
TO_UTF8( m_name ),
|
||||
TO_UTF8( aAlias->GetName() )
|
||||
);)
|
||||
|
||||
it = m_aliases.erase( it );
|
||||
delete aAlias;
|
||||
|
||||
if( !m_aliases.empty() )
|
||||
{
|
||||
if( it == m_aliases.end() )
|
||||
it = m_aliases.begin();
|
||||
|
||||
nextAlias = (*it);
|
||||
nextAlias = *it;
|
||||
|
||||
if( rename )
|
||||
SetName( nextAlias->GetName() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nextAlias;
|
||||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::RemoveAllAliases()
|
||||
void LIB_PART::RemoveAllAliases()
|
||||
{
|
||||
// Remove all of the aliases except the root alias.
|
||||
while( m_aliases.size() > 1 )
|
||||
|
@ -1682,14 +1713,14 @@ void LIB_COMPONENT::RemoveAllAliases()
|
|||
}
|
||||
|
||||
|
||||
LIB_ALIAS* LIB_COMPONENT::GetAlias( const wxString& aName )
|
||||
LIB_ALIAS* LIB_PART::GetAlias( const wxString& aName )
|
||||
{
|
||||
wxCHECK2_MSG( !aName.IsEmpty(), return NULL,
|
||||
wxT( "Cannot get alias with an empty name. Bad programmer!" ) );
|
||||
|
||||
for( size_t i = 0; i < m_aliases.size(); i++ )
|
||||
{
|
||||
if( aName.CmpNoCase( m_aliases[i]->GetName() ) == 0 )
|
||||
if( Cmp_KEEPCASE( aName, m_aliases[i]->GetName() ) == 0 )
|
||||
return m_aliases[i];
|
||||
}
|
||||
|
||||
|
@ -1697,7 +1728,7 @@ LIB_ALIAS* LIB_COMPONENT::GetAlias( const wxString& aName )
|
|||
}
|
||||
|
||||
|
||||
LIB_ALIAS* LIB_COMPONENT::GetAlias( size_t aIndex )
|
||||
LIB_ALIAS* LIB_PART::GetAlias( size_t aIndex )
|
||||
{
|
||||
wxCHECK2_MSG( aIndex < m_aliases.size(), return NULL,
|
||||
wxT( "Illegal alias list index, bad programmer." ) );
|
||||
|
@ -1706,10 +1737,10 @@ LIB_ALIAS* LIB_COMPONENT::GetAlias( size_t aIndex )
|
|||
}
|
||||
|
||||
|
||||
void LIB_COMPONENT::AddAlias( const wxString& aName )
|
||||
void LIB_PART::AddAlias( const wxString& aName )
|
||||
{
|
||||
wxCHECK_RET( !HasAlias( aName ),
|
||||
wxT( "Component <" ) + GetName() + wxT( "> already has an alias <" ) +
|
||||
wxT( "Part <" ) + GetName() + wxT( "> already has an alias <" ) +
|
||||
aName + wxT( ">. Bad programmer." ) );
|
||||
|
||||
m_aliases.push_back( new LIB_ALIAS( aName, this ) );
|
||||
|
@ -1725,7 +1756,7 @@ void LIB_COMPONENT::AddAlias( const wxString& aName )
|
|||
* @param aSep = the separator symbol (0 (no separator) or '.' , '-' and '_')
|
||||
* @param aFirstId = the Id of the first part ('A' or '1')
|
||||
*/
|
||||
void LIB_COMPONENT::SetSubpartIdNotation( int aSep, int aFirstId )
|
||||
void LIB_PART::SetSubpartIdNotation( int aSep, int aFirstId )
|
||||
{
|
||||
m_subpartFirstId = 'A';
|
||||
m_subpartIdSeparator = 0;
|
||||
|
|
|
@ -33,15 +33,13 @@
|
|||
#include <general.h>
|
||||
#include <lib_draw_item.h>
|
||||
#include <lib_field.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
class LINE_READER;
|
||||
class OUTPUTFORMATTER;
|
||||
class CMP_LIBRARY;
|
||||
class PART_LIB;
|
||||
class LIB_ALIAS;
|
||||
class LIB_COMPONENT;
|
||||
class LIB_PART;
|
||||
class LIB_FIELD;
|
||||
|
||||
|
||||
|
@ -58,65 +56,50 @@ inline int Cmp_KEEPCASE( const wxString& aString1, const wxString& aString2 )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* LIB_ALIAS map sorting.
|
||||
*/
|
||||
struct AliasMapSort
|
||||
{
|
||||
bool operator() ( const wxString& aItem1, const wxString& aItem2 ) const
|
||||
{
|
||||
return Cmp_KEEPCASE( aItem1, aItem2 ) < 0;
|
||||
}
|
||||
};
|
||||
typedef std::vector<LIB_ALIAS*> LIB_ALIASES;
|
||||
typedef boost::shared_ptr<LIB_PART> PART_SPTR; ///< shared pointer to LIB_PART
|
||||
typedef boost::weak_ptr<LIB_PART> PART_REF; ///< weak pointer to LIB_PART
|
||||
|
||||
|
||||
/**
|
||||
* Alias map used by component library object.
|
||||
*/
|
||||
typedef std::map< wxString, LIB_ALIAS*, AliasMapSort > LIB_ALIAS_MAP;
|
||||
|
||||
typedef std::vector< LIB_ALIAS* > LIB_ALIASES;
|
||||
|
||||
/* values for member .m_options */
|
||||
enum LibrEntryOptions
|
||||
{
|
||||
ENTRY_NORMAL, // Libentry is a standard component (real or alias)
|
||||
ENTRY_NORMAL, // Libentry is a standard part (real or alias)
|
||||
ENTRY_POWER // Libentry is a power symbol
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Component library alias object definition.
|
||||
* Part library alias object definition.
|
||||
*
|
||||
* Component aliases are not really components. An alias uses the component definition
|
||||
* Part aliases are not really parts. An alias uses the part definition
|
||||
* (graphic, pins...) but has its own name, keywords and documentation. Therefore, when
|
||||
* the component is modified, alias of this component are modified. This is a simple
|
||||
* method to create components that have the same physical layout with different names
|
||||
* the part is modified, alias of this part are modified. This is a simple
|
||||
* method to create parts that have the same physical layout with different names
|
||||
* such as 74LS00, 74HC00 ... and many op amps.
|
||||
*/
|
||||
class LIB_ALIAS : public EDA_ITEM
|
||||
{
|
||||
/**
|
||||
* The actual component of the alias.
|
||||
* Actual LIB_PART referenced by [multiple] aliases.
|
||||
*
|
||||
* @note - Do not delete the root component. The root component is actually shared by
|
||||
* all of the aliases associated with it. The component pointer will be delete
|
||||
* in the destructor of the last alias that shares this component is deleted.
|
||||
* Deleting the root component will likely cause Eeschema to crash.
|
||||
* @note - Do not delete the shared part. The shared part is shared by
|
||||
* all of the aliases associated with it. A shared LIB_PART will
|
||||
* be deleted when all LIB_ALIASes pointing to it are deleted.
|
||||
*/
|
||||
LIB_COMPONENT* root;
|
||||
LIB_PART* shared;
|
||||
|
||||
friend class LIB_COMPONENT;
|
||||
friend class LIB_PART;
|
||||
|
||||
protected:
|
||||
wxString name;
|
||||
wxString description; ///< documentation for info
|
||||
wxString keyWords; ///< keyword list (used for search for components by keyword)
|
||||
wxString docFileName; ///< Associate doc file name
|
||||
wxString name;
|
||||
wxString description; ///< documentation for info
|
||||
wxString keyWords; ///< keyword list (used for search for parts by keyword)
|
||||
wxString docFileName; ///< Associate doc file name
|
||||
|
||||
public:
|
||||
LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent );
|
||||
LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent = NULL );
|
||||
LIB_ALIAS( const wxString& aName, LIB_PART* aRootComponent );
|
||||
LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_PART* aRootComponent = NULL );
|
||||
|
||||
virtual ~LIB_ALIAS();
|
||||
|
||||
|
@ -126,22 +109,26 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the alias root component.
|
||||
* Function GetPart
|
||||
* gets the shared LIB_PART.
|
||||
*
|
||||
* @return LIB_PART* - the LIB_PART shared by
|
||||
* this LIB_ALIAS with possibly other LIB_ALIASes.
|
||||
*/
|
||||
LIB_COMPONENT* GetComponent() const
|
||||
LIB_PART* GetPart() const
|
||||
{
|
||||
return root;
|
||||
return shared;
|
||||
}
|
||||
|
||||
virtual wxString GetLibraryName();
|
||||
const wxString GetLibraryName();
|
||||
|
||||
bool IsRoot() const;
|
||||
|
||||
CMP_LIBRARY* GetLibrary();
|
||||
PART_LIB* GetLib();
|
||||
|
||||
virtual const wxString& GetName() const { return name; }
|
||||
const wxString& GetName() const { return name; }
|
||||
|
||||
virtual void SetName( const wxString& aName ) { name = aName; }
|
||||
void SetName( const wxString& aName ) { name = aName; }
|
||||
|
||||
void SetDescription( const wxString& aDescription )
|
||||
{
|
||||
|
@ -174,7 +161,7 @@ public:
|
|||
bool SaveDoc( OUTPUTFORMATTER& aFormatter );
|
||||
|
||||
/**
|
||||
* Case insensitive comparison of the component entry name.
|
||||
* KEEPCASE sensitive comparison of the part entry name.
|
||||
*/
|
||||
bool operator==( const wxChar* aName ) const;
|
||||
bool operator!=( const wxChar* aName ) const
|
||||
|
@ -195,66 +182,75 @@ extern int LibraryEntryCompare( const LIB_ALIAS* aItem1, const LIB_ALIAS* aItem2
|
|||
|
||||
|
||||
/**
|
||||
* Class LIB_COMPONENT
|
||||
* defines a library component object.
|
||||
* Class LIB_PART
|
||||
* defines a library part object.
|
||||
*
|
||||
* A library component object is typically saved and loaded in a component library file (.lib).
|
||||
* Library components are different from schematic components.
|
||||
* A library part object is typically saved and loaded in a part library file (.lib).
|
||||
* Library parts are different from schematic components.
|
||||
*/
|
||||
class LIB_COMPONENT : public EDA_ITEM
|
||||
class LIB_PART : public EDA_ITEM
|
||||
{
|
||||
friend class CMP_LIBRARY;
|
||||
friend class PART_LIB;
|
||||
friend class LIB_ALIAS;
|
||||
|
||||
wxString m_name;
|
||||
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to 0
|
||||
///< to draw the pin name above the pin.
|
||||
bool m_unitsLocked; ///< True if component has multiple parts and changing
|
||||
///< one part does not automatically change another part.
|
||||
bool m_showPinNames; ///< Determines if component pin names are visible.
|
||||
bool m_showPinNumbers; ///< Determines if component pin numbers are visible.
|
||||
long m_dateModified; ///< Date the component was last modified.
|
||||
LibrEntryOptions m_options; ///< Special component features such as POWER or NORMAL.)
|
||||
int m_unitCount; ///< Number of units (parts) per package.
|
||||
LIB_ITEMS drawings; ///< How to draw this part.
|
||||
wxArrayString m_FootprintList; /**< List of suitable footprint names for the
|
||||
component (wild card names accepted). */
|
||||
LIB_ALIASES m_aliases; ///< List of alias object pointers associated with the
|
||||
///< component.
|
||||
CMP_LIBRARY* m_library; ///< Library the component belongs to if any.
|
||||
PART_SPTR m_me; ///< http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
|
||||
wxString m_name;
|
||||
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to 0
|
||||
///< to draw the pin name above the pin.
|
||||
bool m_unitsLocked; ///< True if part has multiple units and changing
|
||||
///< one unit does not automatically change another unit.
|
||||
bool m_showPinNames; ///< Determines if part pin names are visible.
|
||||
bool m_showPinNumbers; ///< Determines if part pin numbers are visible.
|
||||
long m_dateModified; ///< Date the part was last modified.
|
||||
LibrEntryOptions m_options; ///< Special part features such as POWER or NORMAL.)
|
||||
int m_unitCount; ///< Number of units (parts) per package.
|
||||
LIB_ITEMS drawings; ///< How to draw this part.
|
||||
wxArrayString m_FootprintList; /**< List of suitable footprint names for the
|
||||
part (wild card names accepted). */
|
||||
LIB_ALIASES m_aliases; ///< List of alias object pointers associated with the
|
||||
///< part.
|
||||
PART_LIB* m_library; ///< Library the part belongs to if any.
|
||||
|
||||
static int m_subpartIdSeparator; ///< the separator char between
|
||||
///< the subpart id and the reference
|
||||
///< like U1A ( m_subpartIdSeparator = 0 ) or U1.A or U1-A
|
||||
static int m_subpartFirstId; ///< the ascii char value to calculate the subpart symbol id
|
||||
///< from the part number: only 'A', 'a' or '1' can be used,
|
||||
///< other values have no sense.
|
||||
static int m_subpartIdSeparator; ///< the separator char between
|
||||
///< the subpart id and the reference
|
||||
///< like U1A ( m_subpartIdSeparator = 0 ) or U1.A or U1-A
|
||||
static int m_subpartFirstId; ///< the ascii char value to calculate the subpart symbol id
|
||||
///< from the part number: only 'A', 'a' or '1' can be used,
|
||||
///< other values have no sense.
|
||||
private:
|
||||
void deleteAllFields();
|
||||
|
||||
public:
|
||||
LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary = NULL );
|
||||
LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary = NULL );
|
||||
// LIB_PART() { } // not legal
|
||||
|
||||
virtual ~LIB_COMPONENT();
|
||||
public:
|
||||
|
||||
LIB_PART( const wxString& aName, PART_LIB* aLibrary = NULL );
|
||||
LIB_PART( LIB_PART& aPart, PART_LIB* aLibrary = NULL );
|
||||
|
||||
virtual ~LIB_PART();
|
||||
|
||||
PART_SPTR SharedPtr()
|
||||
{
|
||||
// clone a shared pointer
|
||||
return m_me;
|
||||
}
|
||||
|
||||
virtual wxString GetClass() const
|
||||
{
|
||||
return wxT( "LIB_COMPONENT" );
|
||||
return wxT( "LIB_PART" );
|
||||
}
|
||||
|
||||
|
||||
virtual void SetName( const wxString& aName );
|
||||
|
||||
wxString GetName() { return m_name; }
|
||||
const wxString& GetName() { return m_name; }
|
||||
|
||||
wxString GetLibraryName();
|
||||
const wxString GetLibraryName();
|
||||
|
||||
CMP_LIBRARY* GetLibrary() { return m_library; }
|
||||
PART_LIB* GetLib() { return m_library; }
|
||||
|
||||
wxArrayString GetAliasNames( bool aIncludeRoot = true ) const;
|
||||
|
||||
size_t GetAliasCount() const { return m_aliases.size(); }
|
||||
size_t GetAliasCount() const { return m_aliases.size(); }
|
||||
|
||||
LIB_ALIAS* GetAlias( size_t aIndex );
|
||||
|
||||
|
@ -263,7 +259,7 @@ public:
|
|||
/**
|
||||
* Function AddAlias
|
||||
*
|
||||
* Add an alias \a aName to the component.
|
||||
* Add an alias \a aName to the part.
|
||||
*
|
||||
* Duplicate alias names are not added to the alias list. Debug builds will raise an
|
||||
* assertion. Release builds will fail silently.
|
||||
|
@ -273,7 +269,7 @@ public:
|
|||
void AddAlias( const wxString& aName );
|
||||
|
||||
/**
|
||||
* Test if alias \a aName is in component alias list.
|
||||
* Test if alias \a aName is in part alias list.
|
||||
*
|
||||
* Alias name comparisons are case insensitive.
|
||||
*
|
||||
|
@ -285,7 +281,6 @@ public:
|
|||
void SetAliases( const wxArrayString& aAliasList );
|
||||
|
||||
void RemoveAlias( const wxString& aName );
|
||||
|
||||
LIB_ALIAS* RemoveAlias( LIB_ALIAS* aAlias );
|
||||
|
||||
void RemoveAllAliases();
|
||||
|
@ -294,7 +289,7 @@ public:
|
|||
|
||||
/**
|
||||
* Function GetBoundingBox
|
||||
* @return the component boundary box ( in user coordinates )
|
||||
* @return the part bounding box ( in user coordinates )
|
||||
* @param aUnit = unit selection = 0, or 1..n
|
||||
* @param aConvert = 0, 1 or 2
|
||||
* If aUnit == 0, unit is not used
|
||||
|
@ -305,7 +300,7 @@ public:
|
|||
|
||||
/**
|
||||
* Function GetBodyBoundingBox
|
||||
* @return the component boundary box ( in user coordinates ) without fields
|
||||
* @return the part bounding box ( in user coordinates ) without fields
|
||||
* @param aUnit = unit selection = 0, or 1..n
|
||||
* @param aConvert = 0, 1 or 2
|
||||
* If aUnit == 0, unit is not used
|
||||
|
@ -316,7 +311,7 @@ public:
|
|||
|
||||
/**
|
||||
* Function SaveDateAndTime
|
||||
* write the date and time of component to \a aFile in the format:
|
||||
* write the date and time of part to \a aFile in the format:
|
||||
* "Ti yy/mm/jj hh:mm:ss"
|
||||
*
|
||||
* @param aFormatter A reference to an #OUTPUTFORMATTER object containing the
|
||||
|
@ -329,7 +324,7 @@ public:
|
|||
|
||||
/**
|
||||
* Function Save
|
||||
* writes the data structures out to \a aFormatter in the component library "*.lib"
|
||||
* writes the data structures out to \a aFormatter in the part library "*.lib"
|
||||
* format.
|
||||
*
|
||||
* @param aFormatter A reference to an OUTPUTFORMATTER to write to.
|
||||
|
@ -338,7 +333,7 @@ public:
|
|||
bool Save( OUTPUTFORMATTER& aFormatter );
|
||||
|
||||
/**
|
||||
* Load component definition from \a aReader.
|
||||
* Load part definition from \a aReader.
|
||||
*
|
||||
* @param aReader A LINE_READER object to load file from.
|
||||
* @param aErrorMsg - Description of error on load failure.
|
||||
|
@ -350,20 +345,20 @@ public:
|
|||
bool LoadAliases( char* aLine, wxString& aErrorMsg );
|
||||
bool LoadFootprints( LINE_READER& aReader, wxString& aErrorMsg );
|
||||
|
||||
bool IsPower() { return m_options == ENTRY_POWER; }
|
||||
bool IsNormal() { return m_options == ENTRY_NORMAL; }
|
||||
bool IsPower() { return m_options == ENTRY_POWER; }
|
||||
bool IsNormal() { return m_options == ENTRY_NORMAL; }
|
||||
|
||||
void SetPower() { m_options = ENTRY_POWER; }
|
||||
void SetNormal() { m_options = ENTRY_NORMAL; }
|
||||
void SetPower() { m_options = ENTRY_POWER; }
|
||||
void SetNormal() { m_options = ENTRY_NORMAL; }
|
||||
|
||||
void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
|
||||
bool UnitsLocked() { return m_unitsLocked; }
|
||||
bool UnitsLocked() { return m_unitsLocked; }
|
||||
|
||||
/**
|
||||
* Function SetFields
|
||||
* overwrites all the existing in this component with fields supplied
|
||||
* overwrites all the existing in this part with fields supplied
|
||||
* in \a aFieldsList. The only known caller of this function is the
|
||||
* library component field editor, and it establishes needed behavior.
|
||||
* library part field editor, and it establishes needed behavior.
|
||||
*
|
||||
` * @param aFieldsList is a set of fields to import, removing all previous fields.
|
||||
*/
|
||||
|
@ -371,8 +366,8 @@ public:
|
|||
|
||||
/**
|
||||
* Function GetFields
|
||||
* returns a list of fields withing this component. The only known caller of
|
||||
* this function is the library component field editor, and it establishes
|
||||
* returns a list of fields withing this part. The only known caller of
|
||||
* this function is the library part field editor, and it establishes
|
||||
* needed behavior.
|
||||
*
|
||||
* @param aList - List to add fields to
|
||||
|
@ -381,7 +376,7 @@ public:
|
|||
|
||||
/**
|
||||
* Function FindField
|
||||
* finds a field within this component matching \a aFieldName and returns
|
||||
* finds a field within this part matching \a aFieldName and returns
|
||||
* it or NULL if not found.
|
||||
*/
|
||||
LIB_FIELD* FindField( const wxString& aFieldName );
|
||||
|
@ -401,21 +396,21 @@ public:
|
|||
LIB_FIELD& GetReferenceField();
|
||||
|
||||
/**
|
||||
* Draw component.
|
||||
* Draw part.
|
||||
*
|
||||
* @param aPanel - Window to draw on. Can be NULL if not available.
|
||||
* @param aDc - Device context to draw on.
|
||||
* @param aOffset - Position to component.
|
||||
* @param aMulti - Component unit if multiple parts per component.
|
||||
* @param aOffset - Position of part.
|
||||
* @param aMulti - unit if multiple units per part.
|
||||
* @param aConvert - Component conversion (DeMorgan) if available.
|
||||
* @param aDrawMode - Device context drawing mode, see wxDC.
|
||||
* @param aColor - Color to draw component.
|
||||
* @param aColor - Color to draw part.
|
||||
* @param aTransform - Coordinate adjustment settings.
|
||||
* @param aShowPinText - Show pin text if true.
|
||||
* @param aDrawFields - Draw field text if true otherwise just draw
|
||||
* body items (useful to draw a body in schematic,
|
||||
* because fields of schematic components replace
|
||||
* the lib component fields).
|
||||
* the lib part fields).
|
||||
* @param aOnlySelected - Draws only the body items that are selected.
|
||||
* Used for block move redraws.
|
||||
*/
|
||||
|
@ -427,7 +422,7 @@ public:
|
|||
bool aOnlySelected = false );
|
||||
|
||||
/**
|
||||
* Plot lib component to plotter.
|
||||
* Plot lib part to plotter.
|
||||
* Lib Fields not are plotted here, because this plot function
|
||||
* is used to plot schematic items, which have they own fields
|
||||
*
|
||||
|
@ -441,8 +436,8 @@ public:
|
|||
const TRANSFORM& aTransform );
|
||||
|
||||
/**
|
||||
* Plot Lib Fields only of the component to plotter.
|
||||
* is used to plot the full lib component, outside the schematic
|
||||
* Plot Lib Fields only of the part to plotter.
|
||||
* is used to plot the full lib part, outside the schematic
|
||||
*
|
||||
* @param aPlotter - Plotter object to plot to.
|
||||
* @param aUnit - Component part to plot.
|
||||
|
@ -456,7 +451,7 @@ public:
|
|||
/**
|
||||
* Add a new draw \a aItem to the draw object list.
|
||||
*
|
||||
* @param aItem - New draw object to add to component.
|
||||
* @param aItem - New draw object to add to part.
|
||||
*/
|
||||
void AddDrawItem( LIB_ITEM* aItem );
|
||||
|
||||
|
@ -498,15 +493,15 @@ public:
|
|||
/**
|
||||
* Return a list of pin object pointers from the draw item list.
|
||||
*
|
||||
* Note pin objects are owned by the draw list of the component.
|
||||
* Note pin objects are owned by the draw list of the part.
|
||||
* Deleting any of the objects will leave list in a unstable state
|
||||
* and will likely segfault when the list is destroyed.
|
||||
*
|
||||
* @param aList - Pin list to place pin object pointers into.
|
||||
* @param aUnit - Unit number of pin to add to list. Set to 0 to
|
||||
* get pins from any component part.
|
||||
* get pins from any part unit.
|
||||
* @param aConvert - Convert number of pin to add to list. Set to 0 to
|
||||
* get pins from any convert of component.
|
||||
* get pins from any convert of part.
|
||||
*/
|
||||
void GetPins( LIB_PINS& aList, int aUnit = 0, int aConvert = 0 );
|
||||
|
||||
|
@ -514,7 +509,7 @@ public:
|
|||
* Return pin object with the requested pin \a aNumber.
|
||||
*
|
||||
* @param aNumber - Number of the pin to find.
|
||||
* @param aUnit - Unit of the component to find. Set to 0 if a specific
|
||||
* @param aUnit - Unit of the part to find. Set to 0 if a specific
|
||||
* unit number is not required.
|
||||
* @param aConvert - Alternate body style filter (DeMorgan). Set to 0 if
|
||||
* no alternate body style is required.
|
||||
|
@ -523,7 +518,7 @@ public:
|
|||
LIB_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aConvert = 0 );
|
||||
|
||||
/**
|
||||
* Move the component \a aOffset.
|
||||
* Move the part \a aOffset.
|
||||
*
|
||||
* @param aOffset - Offset displacement.
|
||||
*/
|
||||
|
@ -535,19 +530,19 @@ public:
|
|||
void RemoveDuplicateDrawItems();
|
||||
|
||||
/**
|
||||
* Test if component has more than one body conversion type (DeMorgan).
|
||||
* Test if part has more than one body conversion type (DeMorgan).
|
||||
*
|
||||
* @return True if component has more than one conversion.
|
||||
* @return True if part has more than one conversion.
|
||||
*/
|
||||
bool HasConversion() const;
|
||||
|
||||
/**
|
||||
* Clears the status flag all draw objects in this component.
|
||||
* Clears the status flag all draw objects in this part.
|
||||
*/
|
||||
void ClearStatus();
|
||||
|
||||
/**
|
||||
* Checks all draw objects of component to see if they are with block.
|
||||
* Checks all draw objects of part to see if they are with block.
|
||||
*
|
||||
* Use this method to mark draw objects as selected during block
|
||||
* functions.
|
||||
|
@ -571,7 +566,7 @@ public:
|
|||
* Deletes the select draw items marked by a block select.
|
||||
*
|
||||
* The name and reference field will not be deleted. They are the
|
||||
* minimum drawing items required for any component. Their properties
|
||||
* minimum drawing items required for any part. Their properties
|
||||
* can be changed but the cannot be removed.
|
||||
*/
|
||||
void DeleteSelectedItems();
|
||||
|
@ -584,7 +579,7 @@ public:
|
|||
/**
|
||||
* Make a copy of the selected draw items marked by a block select.
|
||||
*
|
||||
* Fields are not copied. Only component body items are copied.
|
||||
* Fields are not copied. Only part body items are copied.
|
||||
* Copying fields would result in duplicate fields which does not
|
||||
* make sense in this context.
|
||||
*/
|
||||
|
@ -643,29 +638,29 @@ public:
|
|||
LIB_ITEMS& GetDrawItemList() { return drawings; }
|
||||
|
||||
/**
|
||||
* Set the part per package count.
|
||||
* Set the units per part count.
|
||||
*
|
||||
* If the count is greater than the current count, then the all of the
|
||||
* current draw items are duplicated for each additional part. If the
|
||||
* count is less than the current count, all draw objects for parts
|
||||
* greater that count are removed from the component.
|
||||
* count is less than the current count, all draw objects for units
|
||||
* greater that count are removed from the part.
|
||||
*
|
||||
* @param count - Number of parts per package.
|
||||
* @param count - Number of units per package.
|
||||
*/
|
||||
void SetPartCount( int count );
|
||||
void SetUnitCount( int count );
|
||||
|
||||
int GetPartCount() const { return m_unitCount; }
|
||||
int GetUnitCount() const { return m_unitCount; }
|
||||
|
||||
/**
|
||||
* Function IsMulti
|
||||
* @return true if the component has multiple parts per package.
|
||||
* @return true if the part has multiple units per part.
|
||||
* When happens, the reference has a sub reference ti identify part
|
||||
*/
|
||||
bool IsMulti() const { return m_unitCount > 1; }
|
||||
|
||||
/**
|
||||
* Function SubReference
|
||||
* @return the sub reference for component having multiple parts per package.
|
||||
* @return the sub reference for part having multiple units per part.
|
||||
* The sub reference identify the part (or unit)
|
||||
* @param aUnit = the part identifier ( 1 to max count)
|
||||
* @param aAddSeparator = true (default) to prpebd the sub ref
|
||||
|
@ -700,15 +695,15 @@ public:
|
|||
static void SetSubpartIdNotation( int aSep, int aFirstId );
|
||||
|
||||
/**
|
||||
* Set or clear the alternate body style (DeMorgan) for the component.
|
||||
* Set or clear the alternate body style (DeMorgan) for the part.
|
||||
*
|
||||
* If the component already has an alternate body style set and a
|
||||
* If the part already has an alternate body style set and a
|
||||
* asConvert if false, all of the existing draw items for the alternate
|
||||
* body style are remove. If the alternate body style is not set and
|
||||
* asConvert is true, than the base draw items are duplicated and
|
||||
* added to the component.
|
||||
* added to the part.
|
||||
*
|
||||
* @param aSetConvert - Set or clear the component alternate body style.
|
||||
* @param aSetConvert - Set or clear the part alternate body style.
|
||||
*/
|
||||
void SetConversion( bool aSetConvert );
|
||||
|
||||
|
@ -726,7 +721,7 @@ public:
|
|||
/**
|
||||
* Set or clear the pin name visibility flag.
|
||||
*
|
||||
* @param aShow - True to make the component pin names visible.
|
||||
* @param aShow - True to make the part pin names visible.
|
||||
*/
|
||||
void SetShowPinNames( bool aShow ) { m_showPinNames = aShow; }
|
||||
|
||||
|
@ -735,13 +730,13 @@ public:
|
|||
/**
|
||||
* Set or clear the pin number visibility flag.
|
||||
*
|
||||
* @param aShow - True to make the component pin numbers visible.
|
||||
* @param aShow - True to make the part pin numbers visible.
|
||||
*/
|
||||
void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }
|
||||
|
||||
bool ShowPinNumbers() { return m_showPinNumbers; }
|
||||
|
||||
bool operator==( const LIB_COMPONENT* aComponent ) const { return this == aComponent; }
|
||||
bool operator==( const LIB_PART* aPart ) const { return this == aPart; }
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,7 +25,7 @@
|
|||
|
||||
/**
|
||||
* @file class_library.h
|
||||
* @brief Definition for component library class.
|
||||
* @brief Definition for part library class.
|
||||
*/
|
||||
|
||||
#ifndef CLASS_LIBRARY_H
|
||||
|
@ -35,18 +35,19 @@
|
|||
|
||||
#include <class_libentry.h>
|
||||
|
||||
#include <project.h>
|
||||
|
||||
class LINE_READER;
|
||||
class OUTPUTFORMATTER;
|
||||
|
||||
|
||||
/*
|
||||
* Component Library version and file header macros.
|
||||
* Part Library version and file header macros.
|
||||
*/
|
||||
#define LIB_VERSION_MAJOR 2
|
||||
#define LIB_VERSION_MINOR 3
|
||||
|
||||
/* Must be the first line of component library (.lib) files. */
|
||||
/* Must be the first line of part library (.lib) files. */
|
||||
#define LIBFILE_IDENT "EESchema-LIBRARY Version"
|
||||
|
||||
#define LIB_VERSION( major, minor ) ( major * 100 + minor )
|
||||
|
@ -59,59 +60,212 @@ class OUTPUTFORMATTER;
|
|||
|
||||
/*
|
||||
* Library versions 2.3 and lower use the old separate library (.lib) and
|
||||
* document (.dcm) files. Component libraries after 2.3 merged the library
|
||||
* document (.dcm) files. Part libraries after 2.3 merged the library
|
||||
* and document files into a single library file. This macro checks if the
|
||||
* library version supports the old format
|
||||
*/
|
||||
#define USE_OLD_DOC_FILE_FORMAT( major, minor ) \
|
||||
( LIB_VERSION( major, minor ) <= LIB_VERSION( 2, 3 ) )
|
||||
|
||||
/* Must be the first line of component library document (.dcm) files. */
|
||||
/* Must be the first line of part library document (.dcm) files. */
|
||||
#define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0"
|
||||
|
||||
#define DOC_EXT wxT( "dcm" )
|
||||
|
||||
|
||||
/* Helpers for creating a list of component libraries. */
|
||||
class CMP_LIBRARY;
|
||||
/* Helpers for creating a list of part libraries. */
|
||||
class PART_LIB;
|
||||
class wxRegEx;
|
||||
|
||||
/**
|
||||
* LIB_ALIAS map sorting.
|
||||
*/
|
||||
struct AliasMapSort
|
||||
{
|
||||
bool operator() ( const wxString& aItem1, const wxString& aItem2 ) const
|
||||
{
|
||||
return Cmp_KEEPCASE( aItem1, aItem2 ) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
typedef boost::ptr_vector< CMP_LIBRARY > CMP_LIBRARY_LIST;
|
||||
/// Alias map used by part library object.
|
||||
|
||||
extern bool operator<( const CMP_LIBRARY& item1, const CMP_LIBRARY& item2 );
|
||||
typedef std::map< wxString, LIB_ALIAS*, AliasMapSort > LIB_ALIAS_MAP;
|
||||
typedef std::vector< LIB_ALIAS* > LIB_ALIASES;
|
||||
typedef boost::ptr_vector< PART_LIB > PART_LIBS_BASE;
|
||||
|
||||
|
||||
/**
|
||||
* Class CMP_LIBRARY
|
||||
* is used to load, save, search, and otherwise manipulate
|
||||
* component library files.
|
||||
* Class PART_LIBS
|
||||
* is a collection of PART_LIBs. It extends from PROJECT::_ELEM so it can be
|
||||
* hung in the PROJECT. It does not use any UI calls, but rather simply throws
|
||||
* an IO_ERROR when there is a problem.
|
||||
*/
|
||||
class CMP_LIBRARY
|
||||
class PART_LIBS : public PART_LIBS_BASE, public PROJECT::_ELEM
|
||||
{
|
||||
int type; ///< Library type indicator.
|
||||
wxFileName fileName; ///< Library file name.
|
||||
wxDateTime timeStamp; ///< Library save time and date.
|
||||
int versionMajor; ///< Library major version number.
|
||||
int versionMinor; ///< Library minor version number.
|
||||
bool isCache; /**< False for the "standard" libraries,
|
||||
True for the library cache */
|
||||
wxString header; ///< first line of loaded library.
|
||||
bool isModified; ///< Library modification status.
|
||||
LIB_ALIAS_MAP aliases; ///< Map of aliases objects associated with the library.
|
||||
|
||||
static CMP_LIBRARY_LIST libraryList;
|
||||
static wxArrayString libraryListSortOrder;
|
||||
|
||||
friend class LIB_COMPONENT;
|
||||
static wxArrayString s_libraryListSortOrder;
|
||||
|
||||
public:
|
||||
CMP_LIBRARY( int aType, const wxFileName& aFileName );
|
||||
CMP_LIBRARY( int aType, const wxString& aFileName )
|
||||
|
||||
static int s_modify_generation; ///< helper for GetModifyHash()
|
||||
|
||||
PART_LIBS()
|
||||
{
|
||||
CMP_LIBRARY( aType, wxFileName( aFileName ) );
|
||||
++s_modify_generation;
|
||||
}
|
||||
~CMP_LIBRARY();
|
||||
|
||||
/// Return the modification hash for all libraries. The value returned
|
||||
/// changes on every library modification.
|
||||
int GetModifyHash();
|
||||
|
||||
/**
|
||||
* Function AddLibrary
|
||||
* allocates and adds a part library to the library list.
|
||||
*
|
||||
* @param aFileName - File name object of part library.
|
||||
* @param aErrorMsg - Error message if the part library failed to load.
|
||||
* @return PART_LIB* - the new PART_LIB, which remains owned by this PART_LIBS container.
|
||||
* @throw IO_ERROR if there's any problem loading.
|
||||
*/
|
||||
PART_LIB* AddLibrary( const wxString& aFileName ) throw( IO_ERROR );
|
||||
|
||||
/**
|
||||
* Function AddLibrary
|
||||
* inserts a part library into the library list.
|
||||
*
|
||||
* @param aFileName - File name object of part library.
|
||||
* @param aIterator - Iterator to insert library in front of.
|
||||
* @return PART_LIB* - the new PART_LIB, which remains owned by this PART_LIBS container.
|
||||
* @throw IO_ERROR if there's any problem loading.
|
||||
*/
|
||||
PART_LIB* AddLibrary( const wxString& aFileName, PART_LIBS::iterator& aIterator ) throw( IO_ERROR );
|
||||
|
||||
/**
|
||||
* Function RemoveLibrary
|
||||
* removes a part library from the library list.
|
||||
*
|
||||
* @param aName - Name of part library to remove.
|
||||
*/
|
||||
void RemoveLibrary( const wxString& aName );
|
||||
|
||||
void RemoveAllLibraries() { clear(); }
|
||||
|
||||
/**
|
||||
* Function LoadAllLibraries
|
||||
* loads all of the project's libraries into this container, which should
|
||||
* be cleared before calling it.
|
||||
*/
|
||||
void LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR );
|
||||
|
||||
/**
|
||||
* Function LibNamesAndPaths
|
||||
* either saves or loads the names of the currently configured part libraries
|
||||
* (without paths).
|
||||
*/
|
||||
static void LibNamesAndPaths( PROJECT* aProject, bool doSave,
|
||||
wxString* aPaths, wxArrayString* aNames=NULL ) throw( IO_ERROR );
|
||||
|
||||
/**
|
||||
* Function cacheName
|
||||
* returns the name of the cache library after potentially fixing it from
|
||||
* an older naming scheme. That is, the old file is renamed if needed.
|
||||
* @param aFullProjectFilename - the *.pro filename with absolute path.
|
||||
*/
|
||||
static const wxString CacheName( const wxString& aFullProjectFilename );
|
||||
|
||||
/**
|
||||
* Function FindLibrary
|
||||
* finds a part library by \a aName.
|
||||
*
|
||||
* @param aName - Library file name without path or extension to find.
|
||||
* @return Part library if found, otherwise NULL.
|
||||
*/
|
||||
PART_LIB* FindLibrary( const wxString& aName );
|
||||
|
||||
/**
|
||||
* Function GetLibraryNames
|
||||
* returns the list of part library file names without path and extension.
|
||||
*
|
||||
* @param aSorted - Sort the list of name if true. Otherwise use the
|
||||
* library load order.
|
||||
* @return The list of library names.
|
||||
*/
|
||||
wxArrayString GetLibraryNames( bool aSorted = true );
|
||||
|
||||
/**
|
||||
* Function FindLibPart
|
||||
* searches all libraries in the list for a part.
|
||||
*
|
||||
* A part object will always be returned. If the entry found
|
||||
* is an alias. The root part will be found and returned.
|
||||
*
|
||||
* @param aPartName - Name of part to search for.
|
||||
* @param aLibraryName - Name of the library to search for part.
|
||||
* @return LIB_PART* - The part object if found, otherwise NULL.
|
||||
*/
|
||||
LIB_PART* FindLibPart( const wxString& aPartName, const wxString& aLibraryName = wxEmptyString );
|
||||
|
||||
/**
|
||||
* Function FindLibraryEntry
|
||||
* searches all libraries in the list for an entry.
|
||||
*
|
||||
* The object can be either a part or an alias.
|
||||
*
|
||||
* @param aEntryName - Name of entry to search for.
|
||||
* @param aLibraryName - Name of the library to search.
|
||||
* @return The entry object if found, otherwise NULL.
|
||||
*/
|
||||
LIB_ALIAS* FindLibraryEntry( const wxString& aEntryName,
|
||||
const wxString& aLibraryName = wxEmptyString );
|
||||
|
||||
/**
|
||||
* Function RemoveCacheLibrary
|
||||
* removes all cache libraries from library list.
|
||||
*/
|
||||
//void RemoveCacheLibrary();
|
||||
|
||||
int GetLibraryCount() { return size(); }
|
||||
|
||||
static void SetSortOrder( const wxArrayString& aSortOrder )
|
||||
{
|
||||
s_libraryListSortOrder = aSortOrder;
|
||||
}
|
||||
|
||||
static wxArrayString& GetSortOrder()
|
||||
{
|
||||
return s_libraryListSortOrder;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bool operator<( const PART_LIB& item1, const PART_LIB& item2 );
|
||||
|
||||
|
||||
/**
|
||||
* Class PART_LIB
|
||||
* is used to load, save, search, and otherwise manipulate
|
||||
* part library files.
|
||||
*/
|
||||
class PART_LIB
|
||||
{
|
||||
int type; ///< Library type indicator.
|
||||
wxFileName fileName; ///< Library file name.
|
||||
wxDateTime timeStamp; ///< Library save time and date.
|
||||
int versionMajor; ///< Library major version number.
|
||||
int versionMinor; ///< Library minor version number.
|
||||
bool isCache; /**< False for the "standard" libraries,
|
||||
True for the library cache */
|
||||
wxString header; ///< first line of loaded library.
|
||||
bool isModified; ///< Library modification status.
|
||||
LIB_ALIAS_MAP m_amap; ///< Map of alias objects associated with the library.
|
||||
int m_mod_hash; ///< incremented each time library is changed.
|
||||
|
||||
friend class LIB_PART;
|
||||
friend class PART_LIBS;
|
||||
|
||||
public:
|
||||
PART_LIB( int aType, const wxString& aFileName );
|
||||
~PART_LIB();
|
||||
|
||||
/**
|
||||
* Function Save
|
||||
|
@ -145,7 +299,7 @@ private:
|
|||
bool SaveHeader( OUTPUTFORMATTER& aFormatter );
|
||||
|
||||
bool LoadHeader( LINE_READER& aLineReader );
|
||||
void LoadAliases( LIB_COMPONENT* aComponent );
|
||||
void LoadAliases( LIB_PART* aPart );
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -155,18 +309,18 @@ public:
|
|||
*/
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return aliases.empty();
|
||||
return m_amap.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetCount
|
||||
* returns the number of entries in the library.
|
||||
*
|
||||
* @return The number of component and alias entries.
|
||||
* @return The number of part and alias entries.
|
||||
*/
|
||||
int GetCount() const
|
||||
{
|
||||
return aliases.size();
|
||||
return m_amap.size();
|
||||
}
|
||||
|
||||
bool IsModified() const
|
||||
|
@ -218,21 +372,21 @@ public:
|
|||
bool aSort = true );
|
||||
|
||||
/**
|
||||
* Find components in library by key word regular expression search.
|
||||
* Find parts in library by key word regular expression search.
|
||||
*
|
||||
* @param aNames - String array to place found component names into.
|
||||
* @param aRe - Regular expression used to search component key words.
|
||||
* @param aSort - Sort component name list.
|
||||
* @param aNames - String array to place found part names into.
|
||||
* @param aRe - Regular expression used to search part key words.
|
||||
* @param aSort - Sort part name list.
|
||||
*/
|
||||
void SearchEntryNames( wxArrayString& aNames, const wxRegEx& aRe, bool aSort = true );
|
||||
|
||||
/**
|
||||
* Checks \a aComponent for name conflict in the library.
|
||||
* Checks \a aPart for name conflict in the library.
|
||||
*
|
||||
* @param aComponent - The component to check.
|
||||
* @param aPart - The part to check.
|
||||
* @return True if a conflict exists. Otherwise false.
|
||||
*/
|
||||
bool Conflicts( LIB_COMPONENT* aComponent );
|
||||
bool Conflicts( LIB_PART* aPart );
|
||||
|
||||
/**
|
||||
* Find entry by name.
|
||||
|
@ -243,22 +397,19 @@ public:
|
|||
LIB_ALIAS* FindEntry( const wxString& aName );
|
||||
|
||||
/**
|
||||
* Find component by \a aName.
|
||||
* Find part by \a aName.
|
||||
*
|
||||
* This is a helper for FindEntry so casting a LIB_ALIAS pointer to
|
||||
* a LIB_COMPONENT pointer is not required.
|
||||
* a LIB_PART pointer is not required.
|
||||
*
|
||||
* @param aName - Name of component, case insensitive.
|
||||
* @return Component if found. NULL if not found.
|
||||
* @param aName - Name of part, case insensitive.
|
||||
* @return LIB_PART* - part if found, else NULL.
|
||||
*/
|
||||
LIB_COMPONENT* FindComponent( const wxString& aName );
|
||||
LIB_PART* FindPart( const wxString& aName );
|
||||
|
||||
/**
|
||||
* Find alias by \a nName.
|
||||
*
|
||||
* This is a helper for FindEntry so casting a LIB_ALIAS pointer to
|
||||
* a LIB_ALIAS pointer is not required.
|
||||
*
|
||||
* @param aName - Name of alias, case insensitive.
|
||||
* @return Alias if found. NULL if not found.
|
||||
*/
|
||||
|
@ -270,7 +421,7 @@ public:
|
|||
/**
|
||||
* Add a new \a aAlias entry to the library.
|
||||
*
|
||||
* First check if a component or alias with the same name already exists
|
||||
* First check if a part or alias with the same name already exists
|
||||
* in the library and add alias if no conflict occurs. Once the alias
|
||||
* is added to the library it is owned by the library. Deleting the
|
||||
* alias pointer will render the library unstable. Use RemoveEntry to
|
||||
|
@ -282,23 +433,24 @@ public:
|
|||
bool AddAlias( LIB_ALIAS* aAlias );
|
||||
|
||||
/**
|
||||
* Add \a aComponent entry to library.
|
||||
* Note a component can have an alias list,
|
||||
* Add \a aPart entry to library.
|
||||
* Note a part can have an alias list,
|
||||
* so these alias will be added in library.
|
||||
* Conflicts can happen if aliases are already existing.
|
||||
* User is asked to choose what alias is removed (existing, or new)
|
||||
* @param aComponent - Component to add.
|
||||
* @return Added component if successful.
|
||||
*
|
||||
* @param aPart - Part to add, caller retains ownership, a clone is added.
|
||||
* @return bool - true iff successful.
|
||||
*/
|
||||
LIB_COMPONENT* AddComponent( LIB_COMPONENT* aComponent );
|
||||
bool AddPart( LIB_PART* aPart );
|
||||
|
||||
/**
|
||||
* Safely remove \a aEntry from the library and return the next entry.
|
||||
*
|
||||
* The next entry returned depends on the entry being removed. If the entry being
|
||||
* remove also removes the component, then the next entry from the list is returned.
|
||||
* If the entry being used only removes an alias from a component, then the next alias
|
||||
* of the component is returned.
|
||||
* remove also removes the part, then the next entry from the list is returned.
|
||||
* If the entry being used only removes an alias from a part, then the next alias
|
||||
* of the part is returned.
|
||||
*
|
||||
* @param aEntry - Entry to remove from library.
|
||||
* @return The next entry in the library or NULL if the library is empty.
|
||||
|
@ -306,14 +458,13 @@ public:
|
|||
LIB_ALIAS* RemoveEntry( LIB_ALIAS* aEntry );
|
||||
|
||||
/**
|
||||
* Replace an existing component entry in the library.
|
||||
* Note a component can have an alias list,
|
||||
* Replace an existing part entry in the library.
|
||||
* Note a part can have an alias list,
|
||||
* so these alias will be added in library (and previously existing alias removed)
|
||||
* @param aOldComponent - The component to replace.
|
||||
* @param aNewComponent - The new component.
|
||||
* @param aOldPart - The part to replace.
|
||||
* @param aNewPart - The new part.
|
||||
*/
|
||||
LIB_COMPONENT* ReplaceComponent( LIB_COMPONENT* aOldComponent,
|
||||
LIB_COMPONENT* aNewComponent );
|
||||
LIB_PART* ReplacePart( LIB_PART* aOldPart, LIB_PART* aNewPart );
|
||||
|
||||
/**
|
||||
* Return the first entry in the library.
|
||||
|
@ -333,7 +484,6 @@ public:
|
|||
*/
|
||||
LIB_ALIAS* GetNextEntry( const wxString& aName );
|
||||
|
||||
|
||||
/**
|
||||
* Find previous library entry by \a aName.
|
||||
*
|
||||
|
@ -350,7 +500,7 @@ public:
|
|||
*
|
||||
* @return Name of library file.
|
||||
*/
|
||||
wxString GetName() const { return fileName.GetName(); }
|
||||
const wxString GetName() const { return fileName.GetName(); }
|
||||
|
||||
/**
|
||||
* Function GetFullFileName
|
||||
|
@ -358,14 +508,14 @@ public:
|
|||
*
|
||||
* @return wxString - Full library file name with path and extension.
|
||||
*/
|
||||
wxString GetFullFileName() { return fileName.GetFullPath(); }
|
||||
wxString GetFullFileName() { return fileName.GetFullPath(); }
|
||||
|
||||
/**
|
||||
* Function GetLogicalName
|
||||
* returns the logical name of the library.
|
||||
* @return wxString - The logical name of this library.
|
||||
*/
|
||||
wxString GetLogicalName()
|
||||
const wxString GetLogicalName()
|
||||
{
|
||||
/* for now is the filename without path or extension.
|
||||
|
||||
|
@ -381,151 +531,33 @@ public:
|
|||
|
||||
/**
|
||||
* Function SetFileName
|
||||
* sets the component library file name.
|
||||
* sets the part library file name.
|
||||
*
|
||||
* @param aFileName - New library file name.
|
||||
*/
|
||||
void SetFileName( const wxFileName aFileName )
|
||||
void SetFileName( const wxString& aFileName )
|
||||
{
|
||||
if( aFileName != fileName )
|
||||
if( aFileName != fileName.GetFullName() )
|
||||
fileName = aFileName;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following static methods are for manipulating the list of
|
||||
* component libraries. This eliminates the need for yet another
|
||||
* global variable ( formerly g_LibraryList ) and gives some measure
|
||||
* of safety from abusing the library list.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function LibraryExists
|
||||
* tests for existence of a library.
|
||||
*
|
||||
* @param aLibptr - aLibptr.
|
||||
* @return bool - true if exists, else false
|
||||
*/
|
||||
|
||||
static bool LibraryExists( const CMP_LIBRARY* aLibptr );
|
||||
|
||||
/**
|
||||
* Function LoadLibrary
|
||||
* loads a component library file.
|
||||
* allocates and loads a part library file.
|
||||
*
|
||||
* @param aFileName - File name of the component library to load.
|
||||
* @param aErrorMsg - Error message if the component library failed to load.
|
||||
* @return Library object if library file loaded successfully,
|
||||
* otherwise NULL.
|
||||
* @param aFileName - File name of the part library to load.
|
||||
* @return PART_LIB* - the allocated and loaded PART_LIB, which is owned by
|
||||
* the caller.
|
||||
* @throw IO_ERROR if there's any problem loading the library.
|
||||
*/
|
||||
static CMP_LIBRARY* LoadLibrary( const wxFileName& aFileName, wxString& aErrorMsg );
|
||||
|
||||
/**
|
||||
* Function AddLibrary
|
||||
* adds a component library to the library list.
|
||||
*
|
||||
* @param aFileName - File name object of component library.
|
||||
* @param aErrorMsg - Error message if the component library failed to load.
|
||||
* @return True if library loaded properly otherwise false.
|
||||
*/
|
||||
static bool AddLibrary( const wxFileName& aFileName, wxString& aErrorMsg );
|
||||
|
||||
/**
|
||||
* Function AddLibrary
|
||||
* inserts a component library into the library list.
|
||||
*
|
||||
* @param aFileName - File name object of component library.
|
||||
* @param aErrorMsg - Error message if the component library failed to load.
|
||||
* @param aIterator - Iterator to insert library in front of.
|
||||
* @return True if library loaded properly otherwise false.
|
||||
*/
|
||||
static bool AddLibrary( const wxFileName& aFileName, wxString& aErrorMsg,
|
||||
CMP_LIBRARY_LIST::iterator& aIterator );
|
||||
|
||||
/**
|
||||
* Function RemoveLibrary
|
||||
* removes a component library from the library list.
|
||||
*
|
||||
* @param aName - Name of component library to remove.
|
||||
*/
|
||||
static void RemoveLibrary( const wxString& aName );
|
||||
|
||||
static void RemoveAllLibraries() { libraryList.clear(); }
|
||||
|
||||
/**
|
||||
* Function FindLibrary
|
||||
* finds a component library by \a aName.
|
||||
*
|
||||
* @param aName - Library file name without path or extension to find.
|
||||
* @return Component library if found, otherwise NULL.
|
||||
*/
|
||||
static CMP_LIBRARY* FindLibrary( const wxString& aName );
|
||||
|
||||
/**
|
||||
* Function GetLibraryNames
|
||||
* returns the list of component library file names without path and extension.
|
||||
*
|
||||
* @param aSorted - Sort the list of name if true. Otherwise use the
|
||||
* library load order.
|
||||
* @return The list of library names.
|
||||
*/
|
||||
static wxArrayString GetLibraryNames( bool aSorted = true );
|
||||
|
||||
/**
|
||||
* Function FindLibraryComponent
|
||||
* searches all libraries in the list for a component.
|
||||
*
|
||||
* A component object will always be returned. If the entry found
|
||||
* is an alias. The root component will be found and returned.
|
||||
*
|
||||
* @param aComponentName - Name of component to search for.
|
||||
* @param aLibraryName - Name of the library to search for component.
|
||||
* @return The component object if found, otherwise NULL.
|
||||
*/
|
||||
static LIB_COMPONENT* FindLibraryComponent( const wxString& aComponentName,
|
||||
const wxString& aLibraryName = wxEmptyString );
|
||||
|
||||
/**
|
||||
* Function FindLibraryEntry
|
||||
* searches all libraries in the list for an entry.
|
||||
*
|
||||
* The object can be either a component or an alias.
|
||||
*
|
||||
* @param aEntryName - Name of entry to search for.
|
||||
* @param aLibraryName - Name of the library to search.
|
||||
* @return The entry object if found, otherwise NULL.
|
||||
*/
|
||||
static LIB_ALIAS* FindLibraryEntry( const wxString& aEntryName,
|
||||
const wxString& aLibraryName = wxEmptyString );
|
||||
|
||||
/**
|
||||
* Function RemoveCacheLibrary
|
||||
* removes all cache libraries from library list.
|
||||
*/
|
||||
static void RemoveCacheLibrary();
|
||||
|
||||
static int GetLibraryCount() { return libraryList.size(); }
|
||||
|
||||
static CMP_LIBRARY_LIST& GetLibraryList()
|
||||
{
|
||||
return libraryList;
|
||||
}
|
||||
|
||||
static void SetSortOrder( const wxArrayString& aSortOrder )
|
||||
{
|
||||
libraryListSortOrder = aSortOrder;
|
||||
}
|
||||
|
||||
static wxArrayString& GetSortOrder( void )
|
||||
{
|
||||
return libraryListSortOrder;
|
||||
}
|
||||
static PART_LIB* LoadLibrary( const wxString& aFileName ) throw( IO_ERROR );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Case insensitive library name comparison.
|
||||
*/
|
||||
extern bool operator==( const CMP_LIBRARY& aLibrary, const wxString& aName );
|
||||
extern bool operator!=( const CMP_LIBRARY& aLibrary, const wxString& aName );
|
||||
bool operator==( const PART_LIB& aLibrary, const wxString& aName );
|
||||
bool operator!=( const PART_LIB& aLibrary, const wxString& aName );
|
||||
|
||||
#endif // CLASS_LIBRARY_H
|
||||
|
|
|
@ -291,7 +291,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
|
|||
int LastReferenceNumber = 0;
|
||||
int NumberOfUnits, Unit;
|
||||
|
||||
/* Components with an invisible reference (power...) always are re-annotated. */
|
||||
// Components with an invisible reference (power...) always are re-annotated.
|
||||
ResetHiddenReferences();
|
||||
|
||||
/* calculate index of the first component with the same reference prefix
|
||||
|
@ -301,7 +301,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
|
|||
*/
|
||||
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
|
||||
int minRefId = 0;
|
||||
|
||||
|
@ -330,7 +330,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
|
|||
if( ( componentFlatList[first].CompareRef( componentFlatList[ii] ) != 0 )
|
||||
|| ( 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;
|
||||
#ifdef USE_OLD_ALGO
|
||||
minRefId = 0;
|
||||
|
@ -352,7 +352,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
|
|||
}
|
||||
|
||||
// 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 )
|
||||
{
|
||||
|
@ -370,8 +370,8 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
|
|||
continue;
|
||||
}
|
||||
|
||||
/* Annotation of multi-part components ( n parts per package ) (complex case) */
|
||||
NumberOfUnits = componentFlatList[ii].GetLibComponent()->GetPartCount();
|
||||
// Annotation of multi-unit parts ( n units per part ) (complex case)
|
||||
NumberOfUnits = componentFlatList[ii].GetLibComponent()->GetUnitCount();
|
||||
|
||||
if( componentFlatList[ii].m_IsNew )
|
||||
{
|
||||
|
@ -382,7 +382,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
|
|||
#endif
|
||||
componentFlatList[ii].m_NumRef = LastReferenceNumber;
|
||||
|
||||
if( !componentFlatList[ii].IsPartsLocked() )
|
||||
if( !componentFlatList[ii].IsUnitsLocked() )
|
||||
componentFlatList[ii].m_Unit = 1;
|
||||
|
||||
componentFlatList[ii].m_Flag = 1;
|
||||
|
@ -400,9 +400,9 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
|
|||
int found = FindUnit( ii, Unit );
|
||||
|
||||
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++ )
|
||||
{
|
||||
if( componentFlatList[jj].m_Flag ) // already tested
|
||||
|
@ -420,8 +420,8 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
|
|||
if( !componentFlatList[jj].m_IsNew )
|
||||
continue;
|
||||
|
||||
/* Component without reference number found, annotate it if possible */
|
||||
if( !componentFlatList[jj].IsPartsLocked()
|
||||
// Component without reference number found, annotate it if possible
|
||||
if( !componentFlatList[jj].IsUnitsLocked()
|
||||
|| ( componentFlatList[jj].m_Unit == Unit ) )
|
||||
{
|
||||
componentFlatList[jj].m_NumRef = componentFlatList[ii].m_NumRef;
|
||||
|
@ -486,7 +486,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
|
|||
// 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
|
||||
// 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 )
|
||||
{
|
||||
if( componentFlatList[ii].m_NumRef >= 0 )
|
||||
|
@ -498,7 +498,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
|
|||
GetChars( componentFlatList[ii].GetRef() ),
|
||||
GetChars( tmp ),
|
||||
componentFlatList[ii].m_Unit,
|
||||
componentFlatList[ii].GetLibComponent()->GetPartCount() );
|
||||
componentFlatList[ii].GetLibComponent()->GetUnitCount() );
|
||||
|
||||
if( aMessageList )
|
||||
aMessageList->Add( msg );
|
||||
|
@ -555,8 +555,8 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
|
|||
|
||||
/* 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) */
|
||||
if( componentFlatList[ii].GetLibComponent()->GetPartCount()
|
||||
!= componentFlatList[ii + 1].GetLibComponent()->GetPartCount() )
|
||||
if( componentFlatList[ii].GetLibComponent()->GetUnitCount()
|
||||
!= componentFlatList[ii + 1].GetLibComponent()->GetUnitCount() )
|
||||
{
|
||||
if( componentFlatList[ii].m_NumRef >= 0 )
|
||||
tmp << componentFlatList[ii].m_NumRef;
|
||||
|
@ -584,7 +584,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
|
|||
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;
|
||||
|
||||
if( componentFlatList[ii].CompareValue( componentFlatList[next] ) != 0 )
|
||||
|
@ -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)" ),
|
||||
GetChars( componentFlatList[ii].GetRef() ),
|
||||
componentFlatList[ii].m_NumRef,
|
||||
GetChars( LIB_COMPONENT::SubReference(
|
||||
GetChars( LIB_PART::SubReference(
|
||||
componentFlatList[ii].m_Unit ) ),
|
||||
GetChars( componentFlatList[ii].m_Value->GetText() ),
|
||||
GetChars( componentFlatList[next].GetRef() ),
|
||||
componentFlatList[next].m_NumRef,
|
||||
GetChars( LIB_COMPONENT::SubReference(
|
||||
GetChars( LIB_PART::SubReference(
|
||||
componentFlatList[next].m_Unit ) ),
|
||||
GetChars( componentFlatList[next].m_Value->GetText() ) );
|
||||
|
||||
|
@ -617,7 +617,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
|
|||
|| ( componentFlatList[ii].GetSheetPath() != componentFlatList[ii + 1].GetSheetPath() ) )
|
||||
continue;
|
||||
|
||||
/* Same time stamp found. */
|
||||
// Same time stamp found.
|
||||
wxString full_path;
|
||||
|
||||
full_path.Printf( wxT( "%s%8.8X" ),
|
||||
|
@ -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 )
|
||||
{
|
||||
wxASSERT( aComponent != NULL && aLibComponent != NULL );
|
||||
|
@ -694,7 +694,7 @@ void SCH_REFERENCE::Split()
|
|||
{
|
||||
m_IsNew = true;
|
||||
|
||||
if( !IsPartsLocked() )
|
||||
if( !IsUnitsLocked() )
|
||||
m_Unit = 0x7FFFFFFF;
|
||||
|
||||
refText.erase( ll ); // delete last char
|
||||
|
@ -705,7 +705,7 @@ void SCH_REFERENCE::Split()
|
|||
{
|
||||
m_IsNew = true;
|
||||
|
||||
if( !IsPartsLocked() )
|
||||
if( !IsUnitsLocked() )
|
||||
m_Unit = 0x7FFFFFFF;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -98,8 +98,11 @@ bool COMPONENT_TREE_SEARCH_CONTAINER::scoreComparator( const TREE_NODE* a1, cons
|
|||
}
|
||||
|
||||
|
||||
COMPONENT_TREE_SEARCH_CONTAINER::COMPONENT_TREE_SEARCH_CONTAINER()
|
||||
: tree( NULL ), libraries_added( 0 ), preselect_unit_number( -1 )
|
||||
COMPONENT_TREE_SEARCH_CONTAINER::COMPONENT_TREE_SEARCH_CONTAINER( PART_LIBS* aLibs ) :
|
||||
tree( NULL ),
|
||||
libraries_added( 0 ),
|
||||
preselect_unit_number( -1 ),
|
||||
m_libs( aLibs )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -139,7 +142,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddLibrary( CMP_LIBRARY& aLib )
|
|||
|
||||
void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName,
|
||||
const wxArrayString& aAliasNameList,
|
||||
CMP_LIBRARY* aOptionalLib )
|
||||
PART_LIB* aOptionalLib )
|
||||
{
|
||||
TREE_NODE* const lib_node = new TREE_NODE( TREE_NODE::TYPE_LIB, NULL, NULL,
|
||||
aNodeName, wxEmptyString, wxEmptyString );
|
||||
|
@ -152,7 +155,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName,
|
|||
if( aOptionalLib )
|
||||
a = aOptionalLib->FindAlias( aName );
|
||||
else
|
||||
a = CMP_LIBRARY::FindLibraryEntry( aName, wxEmptyString );
|
||||
a = m_libs->FindLibraryEntry( aName, wxEmptyString );
|
||||
|
||||
if( a == NULL )
|
||||
continue;
|
||||
|
@ -186,12 +189,12 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName,
|
|||
a, a->GetName(), display_info, search_text );
|
||||
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");
|
||||
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,
|
||||
alias_node, a,
|
||||
unitName,
|
||||
|
|
|
@ -28,13 +28,14 @@
|
|||
#include <wx/string.h>
|
||||
|
||||
class LIB_ALIAS;
|
||||
class CMP_LIBRARY;
|
||||
class PART_LIB;
|
||||
class PART_LIBS;
|
||||
class wxTreeCtrl;
|
||||
class wxArrayString;
|
||||
|
||||
// class COMPONENT_TREE_SEARCH_CONTAINER
|
||||
// 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.
|
||||
//
|
||||
// The scored result list is adpated on each update on the search-term: this allows
|
||||
|
@ -42,7 +43,7 @@ class wxArrayString;
|
|||
class COMPONENT_TREE_SEARCH_CONTAINER
|
||||
{
|
||||
public:
|
||||
COMPONENT_TREE_SEARCH_CONTAINER();
|
||||
COMPONENT_TREE_SEARCH_CONTAINER( PART_LIBS* aLibs );
|
||||
~COMPONENT_TREE_SEARCH_CONTAINER();
|
||||
|
||||
/** Function AddLibrary
|
||||
|
@ -51,7 +52,7 @@ public:
|
|||
*
|
||||
* @param aLib containting all the components to be added.
|
||||
*/
|
||||
void AddLibrary( CMP_LIBRARY& aLib );
|
||||
void AddLibrary( PART_LIB& aLib );
|
||||
|
||||
/** Function AddComponentList
|
||||
* Add the given list of components, given by name, to be searched.
|
||||
|
@ -62,7 +63,7 @@ public:
|
|||
* @param aOptionalLib Library to look up the component names (if NULL: global lookup)
|
||||
*/
|
||||
void AddAliasList( const wxString& aNodeName, const wxArrayString& aAliasNameList,
|
||||
CMP_LIBRARY* aOptionalLib );
|
||||
PART_LIB* aOptionalLib );
|
||||
|
||||
/** Function SetPreselectNode
|
||||
* Set the component name to be selected in absence of any search-result.
|
||||
|
@ -111,6 +112,8 @@ private:
|
|||
|
||||
wxString preselect_node_name;
|
||||
int preselect_unit_number;
|
||||
|
||||
PART_LIBS* m_libs; // no ownership
|
||||
};
|
||||
|
||||
#endif /* COMPONENT_TREE_SEARCH_CONTAINER_H */
|
||||
|
|
|
@ -38,25 +38,27 @@
|
|||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
extern void DisplayCmpDocAndKeywords( wxString& Name );
|
||||
|
||||
|
||||
// Used in DataBaseGetName: this is a callback function for EDA_LIST_DIALOG
|
||||
// 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;
|
||||
|
||||
CmpEntry = CMP_LIBRARY::FindLibraryEntry( Name );
|
||||
wxASSERT( libs );
|
||||
|
||||
if( CmpEntry == NULL )
|
||||
LIB_ALIAS* part = libs->FindLibraryEntry( aName );
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
||||
Name = wxT( "Description: " ) + CmpEntry->GetDescription();
|
||||
Name += wxT( "\nKey Words: " ) + CmpEntry->GetKeyWords();
|
||||
aName = wxT( "Description: " ) + part->GetDescription();
|
||||
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,
|
||||
* 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
|
|||
Keys.MakeUpper();
|
||||
|
||||
/* 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 );
|
||||
}
|
||||
|
@ -119,6 +121,7 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
|
|||
|
||||
// Show candidate list:
|
||||
wxString cmpname;
|
||||
|
||||
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), headers, nameList, cmpname,
|
||||
DisplayCmpDocAndKeywords, true );
|
||||
|
||||
|
@ -128,3 +131,4 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
|
|||
cmpname = dlg.GetTextSelection();
|
||||
return cmpname;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -302,7 +302,7 @@ void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event )
|
|||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
|
||||
if( fn.GetPath().IsEmpty() )
|
||||
fn.SetPath( wxGetCwd() );
|
||||
fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
|
||||
|
||||
fn.ClearExt();
|
||||
wxString fullfilename = fn.GetFullPath();
|
||||
|
|
|
@ -251,13 +251,13 @@ void DIALOG_CHOOSE_COMPONENT::OnHandlePreviewRepaint( wxPaintEvent& aRepaintEven
|
|||
int unit = 0;
|
||||
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
|
||||
// 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 );
|
||||
dc.SetBackground( *wxWHITE_BRUSH );
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
class COMPONENT_TREE_SEARCH_CONTAINER;
|
||||
class LIB_ALIAS;
|
||||
class LIB_COMPONENT;
|
||||
class LIB_PART;
|
||||
class wxTreeItemId;
|
||||
|
||||
class DIALOG_CHOOSE_COMPONENT : public DIALOG_CHOOSE_COMPONENT_BASE
|
||||
|
@ -79,7 +79,7 @@ protected:
|
|||
private:
|
||||
bool updateSelection();
|
||||
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;
|
||||
const int m_deMorganConvert;
|
||||
|
|
|
@ -64,7 +64,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg()
|
|||
{
|
||||
m_AliasLocation = -1;
|
||||
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
LIB_PART* component = m_Parent->GetCurPart();
|
||||
|
||||
if( component == NULL )
|
||||
{
|
||||
|
@ -125,7 +125,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnCancelClick( wxCommandEvent& event )
|
|||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
|
||||
{
|
||||
LIB_ALIAS* alias;
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
LIB_PART* component = m_Parent->GetCurPart();
|
||||
|
||||
if( component == NULL )
|
||||
return;
|
||||
|
@ -151,7 +151,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
|
|||
*/
|
||||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
|
||||
{
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
LIB_PART* component = m_Parent->GetCurPart();
|
||||
|
||||
if( m_Parent->GetShowDeMorgan() )
|
||||
m_AsConvertButt->SetValue( true );
|
||||
|
@ -172,10 +172,10 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
|
|||
m_ShowPinNumButt->SetValue( component->ShowPinNumbers() );
|
||||
m_ShowPinNameButt->SetValue( component->ShowPinNames() );
|
||||
m_PinsNameInsideButt->SetValue( component->GetPinNameOffset() != 0 );
|
||||
m_SelNumberOfUnits->SetValue( component->GetPartCount() );
|
||||
m_SelNumberOfUnits->SetValue( component->GetUnitCount() );
|
||||
m_SetSkew->SetValue( component->GetPinNameOffset() );
|
||||
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 )
|
|||
/* Update the doc, keyword and doc filename strings */
|
||||
int index;
|
||||
LIB_ALIAS* alias;
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
LIB_PART* component = m_Parent->GetCurPart();
|
||||
|
||||
if( component == NULL )
|
||||
{
|
||||
|
@ -248,7 +248,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
|
|||
* Obviously, cannot be true if there is only one part */
|
||||
component->LockUnits( m_OptionPartsLocked->GetValue() );
|
||||
|
||||
if( component->GetPartCount() <= 1 )
|
||||
if( component->GetUnitCount() <= 1 )
|
||||
component->LockUnits( false );
|
||||
|
||||
/* Update the footprint filter list */
|
||||
|
@ -265,7 +265,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocFromRootToAlias( wxCommandEvent& e
|
|||
return;
|
||||
|
||||
LIB_ALIAS* parent_alias;
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
LIB_PART* component = m_Parent->GetCurPart();
|
||||
|
||||
if( component == NULL )
|
||||
return;
|
||||
|
@ -309,8 +309,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& eve
|
|||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event )
|
||||
{
|
||||
wxString aliasname;
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
CMP_LIBRARY* library = m_Parent->GetLibrary();
|
||||
LIB_PART* component = m_Parent->GetCurPart();
|
||||
PART_LIB* library = m_Parent->GetCurLib();
|
||||
|
||||
if( component == NULL )
|
||||
return;
|
||||
|
@ -371,7 +371,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event
|
|||
}
|
||||
|
||||
m_PartAliasListCtrl->Delete( m_PartAliasListCtrl->GetSelection() );
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
LIB_PART* component = m_Parent->GetCurPart();
|
||||
|
||||
if( component )
|
||||
component->RemoveAlias( aliasname );
|
||||
|
@ -389,16 +389,16 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event
|
|||
*/
|
||||
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;
|
||||
|
||||
if( MaxUnit < component->GetPartCount()
|
||||
if( MaxUnit < part->GetUnitCount()
|
||||
&& !IsOK( this, _( "Delete extra parts from component?" ) ) )
|
||||
return false;
|
||||
|
||||
component->SetPartCount( MaxUnit );
|
||||
part->SetUnitCount( MaxUnit );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::ChangeNbUnitsPerPackage( int MaxUnit )
|
|||
*/
|
||||
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() ) )
|
||||
return false;
|
||||
|
@ -437,13 +437,13 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
|
|||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& event )
|
||||
{
|
||||
PROJECT& prj = Prj();
|
||||
SEARCH_STACK& search = prj.SchSearchS();
|
||||
SEARCH_STACK* search = prj.SchSearchS();
|
||||
|
||||
wxString mask = wxT( "*" );
|
||||
wxString docpath = prj.GetRString( PROJECT::DOC_PATH );
|
||||
|
||||
if( !docpath )
|
||||
docpath = search.LastVisitedPath( wxT( "doc" ) );
|
||||
docpath = search->LastVisitedPath( wxT( "doc" ) );
|
||||
|
||||
wxString fullFileName = EDA_FileSelector( _( "Doc Files" ),
|
||||
docpath,
|
||||
|
@ -468,7 +468,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& e
|
|||
|
||||
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 "/"
|
||||
// to ensure files are identical under unices and windows
|
||||
|
@ -496,7 +497,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter( wxCommandEvent&
|
|||
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& event )
|
||||
{
|
||||
wxString Line;
|
||||
LIB_COMPONENT* component = m_Parent->GetComponent();
|
||||
LIB_PART* component = m_Parent->GetCurPart();
|
||||
|
||||
if( component == NULL )
|
||||
return;
|
||||
|
@ -531,7 +532,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( 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();
|
||||
|
||||
m_FootprintFilterListBox->Delete( ii );
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
|
||||
SCH_EDIT_FRAME* m_Parent;
|
||||
SCH_COMPONENT* m_Cmp;
|
||||
LIB_COMPONENT* m_LibEntry;
|
||||
LIB_PART* m_part;
|
||||
bool m_skipCopyFromPanel;
|
||||
|
||||
static int s_SelectedRow;
|
||||
|
@ -161,7 +161,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
|
|||
{
|
||||
m_Parent = (SCH_EDIT_FRAME*) parent;
|
||||
|
||||
m_LibEntry = NULL;
|
||||
m_part = NULL;
|
||||
m_skipCopyFromPanel = false;
|
||||
|
||||
wxListItem columnLabel;
|
||||
|
@ -225,23 +225,27 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
|
|||
#ifndef KICAD_KEEPCASE
|
||||
newname.MakeUpper();
|
||||
#endif
|
||||
|
||||
newname.Replace( wxT( " " ), wxT( "_" ) );
|
||||
|
||||
if( newname.IsEmpty() )
|
||||
{
|
||||
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;
|
||||
message.Printf( _( "Component [%s] not found!" ), GetChars( newname ) );
|
||||
DisplayError( NULL, message );
|
||||
wxString msg = wxString::Format( _(
|
||||
"Component '%s' not found!" ),
|
||||
GetChars( newname ) );
|
||||
DisplayError( this, msg );
|
||||
}
|
||||
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()
|
|||
{
|
||||
int unit_selection = unitChoice->GetCurrentSelection() + 1;
|
||||
STATUS_FLAGS flags = m_Cmp->GetFlags();
|
||||
|
||||
m_Cmp->SetUnitSelection( &m_Parent->GetCurrentSheet(), unit_selection );
|
||||
m_Cmp->SetUnit( unit_selection );
|
||||
m_Cmp->ClearFlags();
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
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() )
|
||||
m_FieldsBuf[VALUE].SetText( m_Cmp->m_ChipName );
|
||||
if( entry && entry->IsPower() )
|
||||
m_FieldsBuf[VALUE].SetText( m_Cmp->m_part_name );
|
||||
|
||||
// copy all the fields back, and change the length of m_Fields.
|
||||
m_Cmp->SetFields( m_FieldsBuf );
|
||||
|
@ -553,7 +558,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
|
|||
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)
|
||||
for( int i = 0; i<aComponent->GetFieldCount(); ++i )
|
||||
|
@ -765,7 +770,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
|
|||
|
||||
// For power symbols, the value is NOR editable, because value and pin
|
||||
// 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 );
|
||||
else
|
||||
fieldValueTextCtrl->Enable( true );
|
||||
|
@ -869,7 +874,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
|
|||
int choiceCount = unitChoice->GetCount();
|
||||
|
||||
// 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 )
|
||||
unitcount = 1;
|
||||
|
@ -899,7 +904,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
|
|||
else
|
||||
{
|
||||
// Show the "Units are not interchangeable" message option?
|
||||
if( !m_LibEntry || !m_LibEntry->UnitsLocked() )
|
||||
if( !m_part || !m_part->UnitsLocked() )
|
||||
unitsInterchageableLabel->SetLabel( _("Yes") );
|
||||
else
|
||||
unitsInterchageableLabel->SetLabel( _("No") );
|
||||
|
@ -937,11 +942,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
|
|||
if( m_Cmp->GetConvert() > 1 )
|
||||
convertCheckBox->SetValue( true );
|
||||
|
||||
if( m_LibEntry == NULL || !m_LibEntry->HasConversion() )
|
||||
if( m_part == NULL || !m_part->HasConversion() )
|
||||
convertCheckBox->Enable( false );
|
||||
|
||||
// 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.
|
||||
m_textCtrlTimeStamp->SetValue( wxString::Format( wxT("%8.8lX"),
|
||||
|
@ -955,53 +960,54 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
|
|||
*/
|
||||
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
|
||||
{
|
||||
LIB_COMPONENT* entry;
|
||||
|
||||
if( m_Cmp == NULL )
|
||||
if( !m_Cmp )
|
||||
return;
|
||||
|
||||
entry = CMP_LIBRARY::FindLibraryComponent( m_Cmp->m_ChipName );
|
||||
|
||||
if( entry == NULL )
|
||||
return;
|
||||
|
||||
// save old cmp in undo list if not already in edit, or moving ...
|
||||
if( m_Cmp->m_Flags == 0 )
|
||||
m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_Parent->GetCanvas() );
|
||||
m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
// Initialize fixed field values to default values found in library
|
||||
// Note: the field texts are not modified because they are set in schematic,
|
||||
// the text from libraries is most of time a dummy text
|
||||
// Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
|
||||
LIB_FIELD& refField = entry->GetReferenceField();
|
||||
m_Cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_Cmp->m_Pos );
|
||||
m_Cmp->GetField( REFERENCE )->ImportValues( refField );
|
||||
|
||||
LIB_FIELD& valField = entry->GetValueField();
|
||||
m_Cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_Cmp->m_Pos );
|
||||
m_Cmp->GetField( VALUE )->ImportValues( valField );
|
||||
|
||||
LIB_FIELD* field = entry->GetField(FOOTPRINT);
|
||||
if( field && m_Cmp->GetField( FOOTPRINT ) )
|
||||
if( LIB_PART* part = Prj().SchLibs()->FindLibPart( m_Cmp->m_part_name ) )
|
||||
{
|
||||
m_Cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
|
||||
m_Cmp->GetField( FOOTPRINT )->ImportValues( *field );
|
||||
// save old cmp in undo list if not already in edit, or moving ...
|
||||
if( m_Cmp->m_Flags == 0 )
|
||||
m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_Parent->GetCanvas() );
|
||||
m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
// Initialize fixed field values to default values found in library
|
||||
// Note: the field texts are not modified because they are set in schematic,
|
||||
// the text from libraries is most of time a dummy text
|
||||
// Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
|
||||
LIB_FIELD& refField = part->GetReferenceField();
|
||||
|
||||
m_Cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_Cmp->m_Pos );
|
||||
m_Cmp->GetField( REFERENCE )->ImportValues( refField );
|
||||
|
||||
LIB_FIELD& valField = part->GetValueField();
|
||||
|
||||
m_Cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_Cmp->m_Pos );
|
||||
m_Cmp->GetField( VALUE )->ImportValues( valField );
|
||||
|
||||
LIB_FIELD* field = part->GetField(FOOTPRINT);
|
||||
|
||||
if( field && m_Cmp->GetField( FOOTPRINT ) )
|
||||
{
|
||||
m_Cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
|
||||
m_Cmp->GetField( FOOTPRINT )->ImportValues( *field );
|
||||
}
|
||||
|
||||
field = part->GetField(DATASHEET);
|
||||
|
||||
if( field && m_Cmp->GetField( DATASHEET ) )
|
||||
{
|
||||
m_Cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
|
||||
m_Cmp->GetField( DATASHEET )->ImportValues( *field );
|
||||
}
|
||||
|
||||
m_Cmp->SetOrientation( CMP_NORMAL );
|
||||
|
||||
m_Parent->OnModify();
|
||||
|
||||
m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
|
||||
EndQuasiModal( 1 );
|
||||
}
|
||||
|
||||
field = entry->GetField(DATASHEET);
|
||||
if( field && m_Cmp->GetField( DATASHEET ) )
|
||||
{
|
||||
m_Cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
|
||||
m_Cmp->GetField( DATASHEET )->ImportValues( *field );
|
||||
}
|
||||
|
||||
m_Cmp->SetOrientation( CMP_NORMAL );
|
||||
|
||||
m_Parent->OnModify();
|
||||
|
||||
m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
EndQuasiModal( 1 );
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ static int s_SelectedRow;
|
|||
class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
|
||||
{
|
||||
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() {}
|
||||
|
||||
private:
|
||||
|
@ -125,7 +125,7 @@ private:
|
|||
}
|
||||
|
||||
LIB_EDIT_FRAME* m_parent;
|
||||
LIB_COMPONENT* m_libEntry;
|
||||
LIB_PART* m_libEntry;
|
||||
bool m_skipCopyFromPanel;
|
||||
|
||||
/// a copy of the edited component's LIB_FIELDs
|
||||
|
@ -135,12 +135,12 @@ private:
|
|||
|
||||
void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event )
|
||||
{
|
||||
if( m_component == NULL )
|
||||
if( !GetCurLib() )
|
||||
return;
|
||||
|
||||
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();
|
||||
|
||||
|
@ -156,7 +156,7 @@ void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event )
|
|||
|
||||
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB(
|
||||
LIB_EDIT_FRAME* aParent,
|
||||
LIB_COMPONENT* aLibEntry ) :
|
||||
LIB_PART* aLibEntry ) :
|
||||
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent )
|
||||
{
|
||||
m_parent = aParent;
|
||||
|
|
|
@ -39,31 +39,44 @@
|
|||
#include <libeditframe.h>
|
||||
#include <viewlib_frame.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
|
||||
#include <dialog_eeschema_config_fbp.h>
|
||||
|
||||
|
||||
class SCH_EDIT_FRAME;
|
||||
class EDA_DRAW_FRAME;
|
||||
|
||||
|
||||
class DIALOG_EESCHEMA_CONFIG : public DIALOG_EESCHEMA_CONFIG_FBP
|
||||
{
|
||||
public:
|
||||
DIALOG_EESCHEMA_CONFIG( SCH_EDIT_FRAME* parent, wxFrame* activeWindow );
|
||||
DIALOG_EESCHEMA_CONFIG( wxWindow* aParent,
|
||||
wxString* aCallersProjectSpecificLibPaths, wxArrayString* aCallersLibNames );
|
||||
|
||||
private:
|
||||
SCH_EDIT_FRAME* m_Parent;
|
||||
bool m_LibListChanged;
|
||||
bool m_LibPathChanged;
|
||||
wxString m_UserLibDirBufferImg;
|
||||
wxString* m_callers_project_specific_lib_paths;
|
||||
wxArrayString* m_callers_lib_names;
|
||||
|
||||
bool m_lib_list_changed;
|
||||
bool m_lib_path_changed;
|
||||
|
||||
//------ event handlers, overiding the fbp handlers --------------
|
||||
|
||||
// event handlers, overiding the fbp handlers
|
||||
void Init();
|
||||
void OnCloseWindow( wxCloseEvent& event );
|
||||
|
||||
/* Remove a library to the library list.
|
||||
* The real list (m_Parent->m_ComponentLibFiles) is not changed, so the change can be canceled
|
||||
*/
|
||||
void OnRemoveLibClick( wxCommandEvent& event );
|
||||
|
||||
/* Insert or add a library to the library list:
|
||||
* The new library is put in list before (insert button) the selection,
|
||||
* or added (add button) to end of list
|
||||
* The real list (m_Parent->m_ComponentLibFiles) is not changed, so the change
|
||||
* can be canceled
|
||||
*/
|
||||
void OnAddOrInsertLibClick( wxCommandEvent& event );
|
||||
|
||||
void OnAddOrInsertPath( wxCommandEvent& event );
|
||||
void OnOkClick( wxCommandEvent& event );
|
||||
void OnCancelClick( wxCommandEvent& event );
|
||||
|
@ -73,59 +86,53 @@ private:
|
|||
};
|
||||
|
||||
|
||||
DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG( SCH_EDIT_FRAME* aSchFrame,
|
||||
wxFrame* aParent ) :
|
||||
DIALOG_EESCHEMA_CONFIG_FBP( aParent )
|
||||
DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG( wxWindow* aParent,
|
||||
wxString* aCallersProjectSpecificLibPaths, wxArrayString* aCallersLibNames ) :
|
||||
DIALOG_EESCHEMA_CONFIG_FBP( aParent ),
|
||||
m_callers_project_specific_lib_paths( aCallersProjectSpecificLibPaths ),
|
||||
m_callers_lib_names( aCallersLibNames ),
|
||||
m_lib_list_changed( false ),
|
||||
m_lib_path_changed( false )
|
||||
{
|
||||
m_Parent = aSchFrame;
|
||||
m_ListLibr->InsertItems( *aCallersLibNames, 0 );
|
||||
|
||||
Init();
|
||||
// Load user libs paths:
|
||||
wxArrayString paths;
|
||||
|
||||
wxString msg = wxString::Format(
|
||||
_( "from '%s'" ),
|
||||
GetChars( Prj().GetProjectFullName() ) );
|
||||
SEARCH_STACK::Split( &paths, *aCallersProjectSpecificLibPaths );
|
||||
|
||||
for( unsigned i=0; i<paths.GetCount(); ++i )
|
||||
{
|
||||
wxString path = paths[i];
|
||||
|
||||
if( wxFileName::DirExists( Prj().AbsolutePath( path ) ) )
|
||||
m_listUserPaths->Append( path );
|
||||
}
|
||||
|
||||
// Display actual library paths which come in part from KIFACE::KifaceSearch()
|
||||
// along with aCallersProjectSpecificLibPaths at the front.
|
||||
SEARCH_STACK* libpaths = Prj().SchSearchS();
|
||||
|
||||
DBG( libpaths->Show( __func__ ); )
|
||||
|
||||
for( unsigned ii = 0; ii < libpaths->GetCount(); ii++ )
|
||||
{
|
||||
m_DefaultLibraryPathslistBox->Append( (*libpaths)[ii] );
|
||||
}
|
||||
|
||||
// select the first path after the current project's path
|
||||
if( libpaths->GetCount() > 1 )
|
||||
m_DefaultLibraryPathslistBox->Select( 1 );
|
||||
|
||||
wxString msg = wxString::Format( _(
|
||||
"Project '%s'" ),
|
||||
GetChars( Prj().GetProjectFullName() )
|
||||
);
|
||||
|
||||
SetTitle( msg );
|
||||
|
||||
if( GetSizer() )
|
||||
GetSizer()->SetSizeHints( this );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_EESCHEMA_CONFIG::Init()
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
SetFocus();
|
||||
|
||||
m_LibListChanged = false;
|
||||
m_LibPathChanged = false;
|
||||
m_UserLibDirBufferImg = m_Parent->GetUserLibraryPath();
|
||||
|
||||
m_ListLibr->InsertItems( m_Parent->GetComponentLibraries(), 0 );
|
||||
|
||||
// Load user libs paths:
|
||||
wxStringTokenizer tokenizer( m_UserLibDirBufferImg, wxT( ";\n\r" ) );
|
||||
|
||||
while( tokenizer.HasMoreTokens() )
|
||||
{
|
||||
wxString path = tokenizer.GetNextToken();
|
||||
|
||||
if( wxFileName::DirExists( path ) )
|
||||
m_listUserPaths->Append( path );
|
||||
}
|
||||
|
||||
// Display actual libraries paths:
|
||||
SEARCH_STACK& libpaths = Prj().SchSearchS();
|
||||
|
||||
for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ )
|
||||
{
|
||||
m_DefaultLibraryPathslistBox->Append( libpaths[ii] );
|
||||
}
|
||||
|
||||
// select the first path after the current path project
|
||||
if ( libpaths.GetCount() > 1 )
|
||||
m_DefaultLibraryPathslistBox->Select( 1 );
|
||||
|
||||
m_sdbSizer1OK->SetDefault();
|
||||
}
|
||||
|
@ -160,7 +167,7 @@ void DIALOG_EESCHEMA_CONFIG::OnButtonUpClick( wxCommandEvent& event )
|
|||
m_ListLibr->SetSelection(jj-1);
|
||||
}
|
||||
|
||||
m_LibListChanged = true;
|
||||
m_lib_list_changed = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,49 +201,36 @@ void DIALOG_EESCHEMA_CONFIG::OnButtonDownClick( wxCommandEvent& event )
|
|||
m_ListLibr->SetSelection(jj+1);
|
||||
}
|
||||
|
||||
m_LibListChanged = true;
|
||||
m_lib_list_changed = true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_EESCHEMA_CONFIG::OnCancelClick( wxCommandEvent& event )
|
||||
{
|
||||
SEARCH_STACK& lib_search = Prj().SchSearchS();
|
||||
|
||||
// Recreate the user lib path
|
||||
if( m_LibPathChanged )
|
||||
{
|
||||
for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ )
|
||||
lib_search.RemovePaths( m_listUserPaths->GetString(ii) );
|
||||
|
||||
lib_search.AddPaths( m_Parent->GetUserLibraryPath(), 1 );
|
||||
}
|
||||
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
|
||||
{
|
||||
// Recreate the user lib path
|
||||
if( m_LibPathChanged )
|
||||
// Give caller the changed paths
|
||||
if( m_lib_path_changed )
|
||||
{
|
||||
wxString path;
|
||||
wxString paths;
|
||||
|
||||
for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ )
|
||||
{
|
||||
if( ii > 0 )
|
||||
path << wxT( ";" );
|
||||
paths += wxT( ';' );
|
||||
|
||||
path << m_listUserPaths->GetString( ii );
|
||||
paths += m_listUserPaths->GetString( ii );
|
||||
}
|
||||
|
||||
m_Parent->SetUserLibraryPath( path );
|
||||
*m_callers_project_specific_lib_paths = paths;
|
||||
}
|
||||
|
||||
/* Set new active library list if the lib list of if default path list
|
||||
* was modified
|
||||
*/
|
||||
if( m_LibListChanged || m_LibPathChanged )
|
||||
// Update caller's lib_names if changed.
|
||||
if( m_lib_list_changed )
|
||||
{
|
||||
wxArrayString list;
|
||||
|
||||
|
@ -244,18 +238,9 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event )
|
|||
list.Add( m_ListLibr->GetString( ii ) );
|
||||
|
||||
// Recreate lib list
|
||||
m_Parent->SetComponentLibraries( list );
|
||||
|
||||
// take new list in account
|
||||
m_Parent->LoadLibraries();
|
||||
|
||||
// Clear (if needed) the current active library in libedit because it could be
|
||||
// removed from memory
|
||||
LIB_EDIT_FRAME::EnsureActiveLibExists();
|
||||
*m_callers_lib_names = list;
|
||||
}
|
||||
|
||||
m_Parent->SaveProjectSettings( false );
|
||||
|
||||
EndModal( wxID_OK );
|
||||
}
|
||||
|
||||
|
@ -266,9 +251,6 @@ void DIALOG_EESCHEMA_CONFIG::OnCloseWindow( wxCloseEvent& event )
|
|||
}
|
||||
|
||||
|
||||
/* Remove a library to the library list.
|
||||
* The real list (m_Parent->m_ComponentLibFiles) is not changed, so the change can be canceled
|
||||
*/
|
||||
void DIALOG_EESCHEMA_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
|
||||
{
|
||||
wxArrayInt selections;
|
||||
|
@ -278,7 +260,7 @@ void DIALOG_EESCHEMA_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
|
|||
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
|
||||
{
|
||||
m_ListLibr->Delete( selections[ii] );
|
||||
m_LibListChanged = true;
|
||||
m_lib_list_changed = true;
|
||||
}
|
||||
|
||||
// Select next item after deleted in m_ListLibr
|
||||
|
@ -294,21 +276,13 @@ void DIALOG_EESCHEMA_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
/* Insert or add a library to the library list:
|
||||
* The new library is put in list before (insert button) the selection,
|
||||
* or added (add button) to end of list
|
||||
* The real list (m_Parent->m_ComponentLibFiles) is not changed, so the change
|
||||
* can be canceled
|
||||
*/
|
||||
void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
|
||||
{
|
||||
int ii;
|
||||
wxString libfilename;
|
||||
wxFileName fn;
|
||||
wxArrayInt selections;
|
||||
|
||||
PROJECT& prj = Prj();
|
||||
SEARCH_STACK& search = prj.SchSearchS();
|
||||
|
||||
m_ListLibr->GetSelections( selections );
|
||||
|
||||
|
@ -319,13 +293,12 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
|
|||
else
|
||||
ii = 0;
|
||||
|
||||
wxString libpath = m_DefaultLibraryPathslistBox->GetStringSelection();
|
||||
wxString selection = m_DefaultLibraryPathslistBox->GetStringSelection();
|
||||
wxString libpath = Prj().AbsolutePath( selection );
|
||||
|
||||
if( !libpath )
|
||||
{
|
||||
libpath = prj.GetRString( PROJECT::SCH_LIB_PATH );
|
||||
if( !libpath )
|
||||
libpath = search.LastVisitedPath();
|
||||
}
|
||||
|
||||
wxFileDialog filesDialog( this, _( "Library files:" ), libpath,
|
||||
|
@ -335,10 +308,12 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
|
|||
if( filesDialog.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
wxArrayString filenames;
|
||||
wxArrayString filenames;
|
||||
|
||||
filesDialog.GetPaths( filenames );
|
||||
|
||||
wxFileName fn;
|
||||
|
||||
for( unsigned jj = 0; jj < filenames.GetCount(); jj++ )
|
||||
{
|
||||
fn = filenames[jj];
|
||||
|
@ -346,24 +321,15 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
|
|||
if( jj == 0 )
|
||||
prj.SetRString( PROJECT::SCH_LIB_PATH, fn.GetPath() );
|
||||
|
||||
/* 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
|
||||
*/
|
||||
libfilename = search.FilenameWithRelativePathInSearchList( fn.GetFullPath() );
|
||||
|
||||
// Remove extension:
|
||||
fn = libfilename;
|
||||
fn.SetExt( wxEmptyString );
|
||||
libfilename = fn.GetFullPath();
|
||||
|
||||
libfilename = fn.GetName();
|
||||
|
||||
// Add or insert new library name, if not already in list
|
||||
if( m_ListLibr->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND )
|
||||
{
|
||||
m_LibListChanged = true;
|
||||
m_lib_list_changed = true;
|
||||
|
||||
if( event.GetId() == ID_ADD_LIB )
|
||||
m_ListLibr->Append( libfilename );
|
||||
|
@ -372,8 +338,10 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
|
|||
}
|
||||
else
|
||||
{
|
||||
wxString msg = wxT( "<" ) + libfilename + wxT( "> : " ) +
|
||||
_( "Library already in use" );
|
||||
wxString msg = wxString::Format( _(
|
||||
"'%s' : library already in use" ),
|
||||
GetChars( libfilename )
|
||||
);
|
||||
DisplayError( this, msg );
|
||||
}
|
||||
}
|
||||
|
@ -383,24 +351,21 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
|
|||
void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
|
||||
{
|
||||
PROJECT& prj = Prj();
|
||||
SEARCH_STACK& search = Prj().SchSearchS();
|
||||
wxString path = prj.GetRString( PROJECT::SCH_LIB_PATH );
|
||||
|
||||
if( !path )
|
||||
path = search.LastVisitedPath();
|
||||
wxString abs_path = prj.GetRString( PROJECT::SCH_LIB_PATH );
|
||||
wxString path;
|
||||
|
||||
bool select = EDA_DirectorySelector( _( "Default Path for Libraries" ),
|
||||
path, wxDD_DEFAULT_STYLE,
|
||||
abs_path, wxDD_DEFAULT_STYLE,
|
||||
this, wxDefaultPosition );
|
||||
|
||||
if( !select )
|
||||
return;
|
||||
|
||||
if( !wxFileName::DirExists( path ) ) // Should not occurs
|
||||
if( !wxFileName::DirExists( abs_path ) ) // Should not occur
|
||||
return;
|
||||
|
||||
// Add or insert path if not already in list
|
||||
if( m_listUserPaths->FindString( path ) == wxNOT_FOUND )
|
||||
if( m_listUserPaths->FindString( abs_path ) == wxNOT_FOUND )
|
||||
{
|
||||
int ipos = m_listUserPaths->GetCount();
|
||||
|
||||
|
@ -416,43 +381,53 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
// Ask the user if this is a relative path
|
||||
int diag = wxMessageBox( _( "Use a relative path?" ), _( "Path type" ),
|
||||
int diag = wxMessageBox( _( "Use a relative path?" ), _( "Path type" ),
|
||||
wxYES_NO | wxICON_QUESTION, this );
|
||||
|
||||
if( diag == wxYES )
|
||||
{
|
||||
// Make it relative
|
||||
wxFileName fn = path;
|
||||
fn.MakeRelativeTo( wxT(".") );
|
||||
wxFileName fn = abs_path;
|
||||
fn.MakeRelativeTo( wxPathOnly( Prj().GetProjectFullName() ) );
|
||||
path = fn.GetPathWithSep() + fn.GetFullName();
|
||||
}
|
||||
else
|
||||
path = abs_path;
|
||||
|
||||
m_listUserPaths->Insert(path, ipos);
|
||||
m_LibPathChanged = true;
|
||||
m_listUserPaths->Insert( path, ipos );
|
||||
m_lib_path_changed = true;
|
||||
|
||||
search.AddPaths( path, ipos+1 );
|
||||
|
||||
// Display actual libraries paths:
|
||||
m_DefaultLibraryPathslistBox->Clear();
|
||||
|
||||
for( unsigned ii = 0; ii < search.GetCount(); ii++ )
|
||||
{
|
||||
m_DefaultLibraryPathslistBox->Append( search[ii] );
|
||||
}
|
||||
m_DefaultLibraryPathslistBox->InsertItems( 1, &path, ipos+1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayError( this, _("Path already in use") );
|
||||
}
|
||||
|
||||
prj.SetRString( PROJECT::SCH_LIB_PATH, path );
|
||||
prj.SetRString( PROJECT::SCH_LIB_PATH, abs_path );
|
||||
}
|
||||
|
||||
|
||||
static void remove_from_listbox( wxListBox* aListBox, const wxString& aText )
|
||||
{
|
||||
wxArrayString a;
|
||||
|
||||
for( int i=0, cnt = aListBox->GetCount(); i<cnt; ++i )
|
||||
{
|
||||
wxString item = aListBox->GetString( i );
|
||||
|
||||
if( item != aText )
|
||||
a.Add( item );
|
||||
}
|
||||
|
||||
aListBox->Clear();
|
||||
|
||||
aListBox->InsertItems( a, 0 );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_EESCHEMA_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
|
||||
{
|
||||
SEARCH_STACK& lib_search = Prj().SchSearchS();
|
||||
|
||||
int ii = m_listUserPaths->GetSelection();
|
||||
|
||||
if( ii < 0 )
|
||||
|
@ -460,27 +435,23 @@ void DIALOG_EESCHEMA_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
|
|||
|
||||
if( ii >= 0 )
|
||||
{
|
||||
lib_search.RemovePaths( m_listUserPaths->GetStringSelection() );
|
||||
wxString sel = m_listUserPaths->GetStringSelection();
|
||||
|
||||
remove_from_listbox( m_DefaultLibraryPathslistBox, sel );
|
||||
|
||||
m_listUserPaths->Delete( ii );
|
||||
m_LibPathChanged = true;
|
||||
}
|
||||
|
||||
// Display actual libraries paths:
|
||||
m_DefaultLibraryPathslistBox->Clear();
|
||||
|
||||
for( unsigned ii = 0; ii < lib_search.GetCount(); ii++ )
|
||||
{
|
||||
m_DefaultLibraryPathslistBox->Append( lib_search[ii] );
|
||||
m_lib_path_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int InvokeEeschemaConfig( SCH_EDIT_FRAME* aEditFrame, wxFrame* aParent )
|
||||
bool InvokeEeschemaConfig( wxWindow* aParent,
|
||||
wxString* aCallersProjectSpecificLibPaths, wxArrayString* aCallersLibNames )
|
||||
{
|
||||
DIALOG_EESCHEMA_CONFIG dlg( aEditFrame, aParent );
|
||||
DIALOG_EESCHEMA_CONFIG dlg( aParent,
|
||||
aCallersProjectSpecificLibPaths, aCallersLibNames );
|
||||
|
||||
dlg.ShowModal();
|
||||
int ret = dlg.ShowModal();
|
||||
|
||||
return 1;
|
||||
return wxID_OK == ret;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -36,6 +36,7 @@
|
|||
#include <class_sch_screen.h>
|
||||
#include <wxEeschemaStruct.h>
|
||||
#include <invoke_sch_dialog.h>
|
||||
#include <project.h>
|
||||
|
||||
#include <netlist.h>
|
||||
#include <class_netlist_object.h>
|
||||
|
@ -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 )
|
||||
{
|
||||
ResetDefaultERCDiag( event );
|
||||
}
|
||||
|
||||
|
||||
/* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERC_CMP */
|
||||
void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
|
||||
{
|
||||
wxBusyCursor();
|
||||
|
@ -155,7 +154,6 @@ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
|
|||
m_MessagesList->AppendText( messageList[ii] );
|
||||
}
|
||||
|
||||
// Single click on a marker info:
|
||||
void DIALOG_ERC::OnLeftClickMarkersList( wxCommandEvent& event )
|
||||
{
|
||||
m_lastMarkerFound = NULL;
|
||||
|
@ -209,8 +207,7 @@ void DIALOG_ERC::OnLeftClickMarkersList( wxCommandEvent& event )
|
|||
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 )
|
||||
{
|
||||
// Remember: OnLeftClickMarkersList was called just berfore
|
||||
|
@ -231,8 +228,6 @@ void DIALOG_ERC::OnLeftDblClickMarkersList( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
/* Build or rebuild the panel showing the ERC conflict matrix
|
||||
*/
|
||||
void DIALOG_ERC::ReBuildMatrixPanel()
|
||||
{
|
||||
// Try to know the size of bitmap button used in drc matrix
|
||||
|
@ -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()
|
||||
{
|
||||
SCH_SHEET_LIST sheetList;
|
||||
|
@ -358,8 +349,6 @@ void DIALOG_ERC::DisplayERC_MarkersList()
|
|||
}
|
||||
|
||||
|
||||
/* Resets the default values of the ERC matrix.
|
||||
*/
|
||||
void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
|
||||
{
|
||||
memcpy( DiagErc, DefaultDiagErc, sizeof(DiagErc) );
|
||||
|
@ -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 )
|
||||
{
|
||||
int id, level, ii, x, y;
|
||||
|
@ -426,9 +413,9 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
|||
|
||||
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;
|
||||
sheets.AnnotatePowerSymbols();
|
||||
sheets.AnnotatePowerSymbols( Prj().SchLibs() );
|
||||
|
||||
if( m_parent->CheckAnnotate( aMessagesList, false ) )
|
||||
{
|
||||
|
|
|
@ -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
|
||||
// to know some options, about pin texts
|
||||
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
|
||||
EDA_RECT bBox = m_dummyPin->GetBoundingBox();
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
wxString GetReference( void ) { return m_textReference->GetValue(); }
|
||||
|
||||
void SetPartCount( int count ) { m_spinPartCount->SetValue( count ); }
|
||||
int GetPartCount( void ) { return m_spinPartCount->GetValue(); }
|
||||
int GetUnitCount( void ) { return m_spinPartCount->GetValue(); }
|
||||
|
||||
void SetAlternateBodyStyle( bool enable )
|
||||
{
|
||||
|
|
|
@ -613,7 +613,7 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
|
|||
fn.SetExt( fileExt );
|
||||
|
||||
if( fn.GetPath().IsEmpty() )
|
||||
fn.SetPath( wxGetCwd() );
|
||||
fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) );
|
||||
|
||||
wxString fullpath = fn.GetFullPath();
|
||||
|
||||
|
|
|
@ -53,18 +53,20 @@ void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField )
|
|||
wxCHECK_RET( component != NULL && component->Type() == SCH_COMPONENT_T,
|
||||
wxT( "Invalid schematic field parent item." ) );
|
||||
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() );
|
||||
LIB_PART* part = Prj().SchLibs()->FindLibPart( component->GetPartName() );
|
||||
|
||||
wxCHECK_RET( entry != NULL, wxT( "Library entry for component <" ) +
|
||||
component->GetLibName() + wxT( "> could not be found." ) );
|
||||
wxCHECK_RET( part, wxT( "Library part for component <" ) +
|
||||
component->GetPartName() + wxT( "> could not be found." ) );
|
||||
|
||||
fieldNdx = aField->GetId();
|
||||
|
||||
if( fieldNdx == VALUE && entry->IsPower() )
|
||||
if( fieldNdx == VALUE && part->IsPower() )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "%s is a power component and it's value cannot be modified!\n\nYou must \
|
||||
create a new power component with the new value." ), GetChars( entry->GetName() ) );
|
||||
wxString msg = wxString::Format( _(
|
||||
"%s is a power component and it's value cannot be modified!\n\n"
|
||||
"You must create a new power component with the new value." ),
|
||||
GetChars( part->GetName() )
|
||||
);
|
||||
DisplayInfoMessage( this, msg );
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,116 +16,3 @@
|
|||
|
||||
#include <html_messagebox.h>
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::LoadLibraries()
|
||||
{
|
||||
size_t ii;
|
||||
wxFileName fn;
|
||||
wxString msg, tmp, errMsg;
|
||||
wxString libraries_not_found;
|
||||
wxArrayString sortOrder;
|
||||
SEARCH_STACK& lib_search = Prj().SchSearchS();
|
||||
|
||||
#if defined(DEBUG) && 1
|
||||
lib_search.Show( __func__ );
|
||||
#endif
|
||||
|
||||
CMP_LIBRARY_LIST::iterator i = CMP_LIBRARY::GetLibraryList().begin();
|
||||
|
||||
// Free the unwanted libraries but keep the cache library.
|
||||
while( i < CMP_LIBRARY::GetLibraryList().end() )
|
||||
{
|
||||
if( i->IsCache() )
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
DBG(printf( "ll:%s\n", TO_UTF8( i->GetName() ) );)
|
||||
|
||||
if( m_componentLibFiles.Index( i->GetName(), false ) == wxNOT_FOUND )
|
||||
i = CMP_LIBRARY::GetLibraryList().erase( i );
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
||||
// Load missing libraries.
|
||||
for( ii = 0; ii < m_componentLibFiles.GetCount(); ii++ )
|
||||
{
|
||||
fn.Clear();
|
||||
fn.SetName( m_componentLibFiles[ii] );
|
||||
fn.SetExt( SchematicLibraryFileExtension );
|
||||
|
||||
// Skip if the file name is not valid..
|
||||
if( !fn.IsOk() )
|
||||
continue;
|
||||
|
||||
if( !fn.FileExists() )
|
||||
{
|
||||
tmp = lib_search.FindValidPath( fn.GetFullPath() );
|
||||
|
||||
if( !tmp )
|
||||
{
|
||||
libraries_not_found += fn.GetName() + _( "\n" );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = fn.GetFullPath();
|
||||
}
|
||||
|
||||
// Loaded library statusbar message
|
||||
fn = tmp;
|
||||
|
||||
if( CMP_LIBRARY::AddLibrary( fn, errMsg ) )
|
||||
{
|
||||
msg.Printf( _( "Library '%s' loaded" ), GetChars( tmp ) );
|
||||
sortOrder.Add( fn.GetName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxString prompt;
|
||||
|
||||
prompt.Printf( _( "Component library '%s' failed to load.\nError: %s" ),
|
||||
GetChars( fn.GetFullPath() ),
|
||||
GetChars( errMsg ) );
|
||||
DisplayError( this, prompt );
|
||||
msg.Printf( _( "Library '%s' error!" ), GetChars( tmp ) );
|
||||
}
|
||||
|
||||
PrintMsg( msg );
|
||||
}
|
||||
|
||||
// Print the libraries not found
|
||||
if( !libraries_not_found.IsEmpty() )
|
||||
{
|
||||
// parent of this dialog cannot be NULL since that breaks the Kiway() chain.
|
||||
HTML_MESSAGE_BOX dialog( this, _("Files not found") );
|
||||
|
||||
dialog.MessageSet( _( "The following libraries could not be found:" ) );
|
||||
dialog.ListSet( libraries_not_found );
|
||||
libraries_not_found.empty();
|
||||
dialog.ShowModal();
|
||||
}
|
||||
|
||||
// Put the libraries in the correct order.
|
||||
CMP_LIBRARY::SetSortOrder( sortOrder );
|
||||
CMP_LIBRARY::GetLibraryList().sort();
|
||||
|
||||
#if 0 && defined(__WXDEBUG__)
|
||||
wxLogDebug( wxT( "LoadLibraries() requested component library sort order:" ) );
|
||||
|
||||
for( size_t i = 0; i < sortOrder.GetCount(); i++ )
|
||||
wxLogDebug( wxT( " " ) + sortOrder[i] );
|
||||
|
||||
wxLogDebug( wxT( "Real component library sort order:" ) );
|
||||
|
||||
for ( i = CMP_LIBRARY::GetLibraryList().begin();
|
||||
i < CMP_LIBRARY::GetLibraryList().end(); i++ )
|
||||
wxLogDebug( wxT( " " ) + i->GetName() );
|
||||
|
||||
wxLogDebug( wxT( "end LoadLibraries ()" ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -70,10 +70,7 @@ static struct IFACE : public KIFACE_I
|
|||
|
||||
bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits );
|
||||
|
||||
void OnKifaceEnd( PGM_BASE* aProgram )
|
||||
{
|
||||
end_common();
|
||||
}
|
||||
void OnKifaceEnd( PGM_BASE* aProgram );
|
||||
|
||||
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 )
|
||||
{
|
||||
|
@ -83,11 +80,6 @@ static struct IFACE : public KIFACE_I
|
|||
{
|
||||
SCH_EDIT_FRAME* frame = new SCH_EDIT_FRAME( aKiway, aParent );
|
||||
|
||||
frame->Zoom_Automatique( true );
|
||||
|
||||
// Read a default config file in case no project given on command line.
|
||||
frame->LoadProjectFile( wxEmptyString, true );
|
||||
|
||||
if( Kiface().IsSingle() )
|
||||
{
|
||||
// only run this under single_top, not under a project manager.
|
||||
|
@ -162,6 +154,62 @@ PGM_BASE& Pgm()
|
|||
}
|
||||
|
||||
|
||||
static EDA_COLOR_T s_layerColor[NB_SCH_LAYERS];
|
||||
|
||||
EDA_COLOR_T GetLayerColor( LayerNumber aLayer )
|
||||
{
|
||||
wxASSERT( unsigned( aLayer ) < DIM( s_layerColor ) );
|
||||
return s_layerColor[aLayer];
|
||||
}
|
||||
|
||||
void SetLayerColor( EDA_COLOR_T aColor, int aLayer )
|
||||
{
|
||||
wxASSERT( unsigned( aLayer ) < DIM( s_layerColor ) );
|
||||
s_layerColor[aLayer] = aColor;
|
||||
}
|
||||
|
||||
|
||||
static PARAM_CFG_ARRAY& cfg_params()
|
||||
{
|
||||
static PARAM_CFG_ARRAY ca;
|
||||
|
||||
if( !ca.size() )
|
||||
{
|
||||
// These are KIFACE specific, they need to be loaded once when the
|
||||
// eeschema KIFACE comes in.
|
||||
|
||||
#define CLR(x, y, z) ca.push_back( new PARAM_CFG_SETCOLOR( true, wxT( x ), &s_layerColor[y], z ));
|
||||
|
||||
CLR( "ColorWireEx", LAYER_WIRE, GREEN )
|
||||
CLR( "ColorBusEx", LAYER_BUS, BLUE )
|
||||
CLR( "ColorConnEx", LAYER_JUNCTION, GREEN )
|
||||
CLR( "ColorLLabelEx", LAYER_LOCLABEL, BLACK )
|
||||
CLR( "ColorHLabelEx", LAYER_HIERLABEL, BROWN )
|
||||
CLR( "ColorGLabelEx", LAYER_GLOBLABEL, RED )
|
||||
CLR( "ColorPinNumEx", LAYER_PINNUM, RED )
|
||||
CLR( "ColorPinNameEx", LAYER_PINNAM, CYAN )
|
||||
CLR( "ColorFieldEx", LAYER_FIELDS, MAGENTA )
|
||||
CLR( "ColorReferenceEx", LAYER_REFERENCEPART, CYAN )
|
||||
CLR( "ColorValueEx", LAYER_VALUEPART, CYAN )
|
||||
CLR( "ColorNoteEx", LAYER_NOTES, LIGHTBLUE )
|
||||
CLR( "ColorBodyEx", LAYER_DEVICE, RED )
|
||||
CLR( "ColorBodyBgEx", LAYER_DEVICE_BACKGROUND,LIGHTYELLOW )
|
||||
CLR( "ColorNetNameEx", LAYER_NETNAM, DARKGRAY )
|
||||
CLR( "ColorPinEx", LAYER_PIN, RED )
|
||||
CLR( "ColorSheetEx", LAYER_SHEET, MAGENTA )
|
||||
CLR( "ColorSheetFileNameEx", LAYER_SHEETFILENAME, BROWN )
|
||||
CLR( "ColorSheetNameEx", LAYER_SHEETNAME, CYAN )
|
||||
CLR( "ColorSheetLabelEx", LAYER_SHEETLABEL, BROWN )
|
||||
CLR( "ColorNoConnectEx", LAYER_NOCONNECT, BLUE )
|
||||
CLR( "ColorErcWEx", LAYER_ERC_WARN, GREEN )
|
||||
CLR( "ColorErcEEx", LAYER_ERC_ERR, RED )
|
||||
CLR( "ColorGridEx", LAYER_GRID, DARKGRAY )
|
||||
}
|
||||
|
||||
return ca;
|
||||
}
|
||||
|
||||
|
||||
bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
|
||||
{
|
||||
// This is process level, not project level, initialization of the DSO.
|
||||
|
@ -179,6 +227,16 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
|
|||
// display the real hotkeys in menus or tool tips
|
||||
ReadHotkeyConfig( wxT("SchematicFrame"), s_Eeschema_Hokeys_Descr );
|
||||
|
||||
wxConfigLoadSetups( KifaceSettings(), cfg_params() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void IFACE::OnKifaceEnd( PGM_BASE* aProgram )
|
||||
{
|
||||
wxConfigSaveSetups( KifaceSettings(), cfg_params() );
|
||||
|
||||
end_common();
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <sch_sheet.h>
|
||||
#include <class_libentry.h>
|
||||
#include <worksheet_shape_builder.h>
|
||||
#include <class_library.h>
|
||||
|
||||
#include <dialog_hotkeys_editor.h>
|
||||
|
||||
|
@ -55,8 +56,6 @@
|
|||
|
||||
#define FR_HISTORY_LIST_CNT 10 ///< Maximum number of find and replace strings.
|
||||
|
||||
static EDA_COLOR_T s_layerColor[NB_SCH_LAYERS];
|
||||
|
||||
/// The width to draw busses that do not have a specific width
|
||||
static int s_defaultBusThickness;
|
||||
|
||||
|
@ -131,18 +130,6 @@ void SetDefaultPinLength( int aLength )
|
|||
}
|
||||
|
||||
|
||||
EDA_COLOR_T GetLayerColor( LayerNumber aLayer )
|
||||
{
|
||||
return s_layerColor[aLayer];
|
||||
}
|
||||
|
||||
|
||||
void SetLayerColor( EDA_COLOR_T aColor, int aLayer )
|
||||
{
|
||||
s_layerColor[aLayer] = aColor;
|
||||
}
|
||||
|
||||
|
||||
// Color to draw selected items
|
||||
EDA_COLOR_T GetItemSelectedColor()
|
||||
{
|
||||
|
@ -160,10 +147,31 @@ EDA_COLOR_T GetInvisibleItemColor()
|
|||
|
||||
void LIB_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event )
|
||||
{
|
||||
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
|
||||
wxASSERT( frame );
|
||||
// Identical to SCH_EDIT_FRAME::InstallConfigFrame()
|
||||
|
||||
InvokeEeschemaConfig( frame, this );
|
||||
PROJECT* prj = &Prj();
|
||||
wxArrayString lib_names;
|
||||
wxString lib_paths;
|
||||
|
||||
try
|
||||
{
|
||||
PART_LIBS::LibNamesAndPaths( prj, false, &lib_paths, &lib_names );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.errorText ) );)
|
||||
return;
|
||||
}
|
||||
|
||||
if( InvokeEeschemaConfig( this, &lib_paths, &lib_names ) )
|
||||
{
|
||||
// save the [changed] settings.
|
||||
PART_LIBS::LibNamesAndPaths( prj, true, &lib_paths, &lib_names );
|
||||
|
||||
// Force a reload of the PART_LIBS
|
||||
prj->SetElem( PROJECT::ELEM_SCH_PART_LIBS, NULL );
|
||||
prj->SetElem( PROJECT::ELEM_SCH_SEARCH_STACK, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,6 +199,10 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
|
||||
case ID_CONFIG_READ:
|
||||
{
|
||||
#if 0 // This is confusing. From the library parts editor, we trigger the loading
|
||||
// of configuration information into the schematic editor? Makes no more sense
|
||||
// than me storing my old newspapers in your garage.
|
||||
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
|
@ -201,11 +213,14 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
break;
|
||||
|
||||
schFrame->LoadProjectFile( dlg.GetPath(), true );
|
||||
wxString foreign_pro = dlg.GetPath();
|
||||
|
||||
Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH,
|
||||
GetProjectFileParametersList(), foreign_pro );
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
// Hotkey IDs
|
||||
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
|
||||
InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr );
|
||||
|
@ -240,7 +255,41 @@ void SCH_EDIT_FRAME::OnColorConfig( wxCommandEvent& aEvent )
|
|||
|
||||
void SCH_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event )
|
||||
{
|
||||
InvokeEeschemaConfig( this, this );
|
||||
// Identical to LIB_EDIT_FRAME::InstallConfigFrame()
|
||||
|
||||
PROJECT* prj = &Prj();
|
||||
wxArrayString lib_names;
|
||||
wxString lib_paths;
|
||||
|
||||
try
|
||||
{
|
||||
PART_LIBS::LibNamesAndPaths( prj, false, &lib_paths, &lib_names );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.errorText ) );)
|
||||
return;
|
||||
}
|
||||
|
||||
if( InvokeEeschemaConfig( this, &lib_paths, &lib_names ) )
|
||||
{
|
||||
// save the [changed] settings.
|
||||
PART_LIBS::LibNamesAndPaths( prj, true, &lib_paths, &lib_names );
|
||||
|
||||
#if defined(DEBUG)
|
||||
printf( "%s: lib_names:\n", __func__ );
|
||||
for( unsigned i=0; i<lib_names.size(); ++i )
|
||||
{
|
||||
printf( " %s\n", TO_UTF8( lib_names[i] ) );
|
||||
}
|
||||
|
||||
printf( "%s: lib_paths:'%s'\n", __func__, TO_UTF8( lib_paths ) );
|
||||
#endif
|
||||
|
||||
// Force a reload of the PART_LIBS
|
||||
prj->SetElem( PROJECT::ELEM_SCH_PART_LIBS, NULL );
|
||||
prj->SetElem( PROJECT::ELEM_SCH_SEARCH_STACK, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,7 +316,12 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
break;
|
||||
|
||||
LoadProjectFile( dlg.GetPath(), true );
|
||||
wxString chosen = dlg.GetPath();
|
||||
|
||||
if( chosen == Prj().GetProjectFullName() )
|
||||
LoadProjectFile();
|
||||
else
|
||||
Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_SCH, GetProjectFileParametersList() );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -315,8 +369,8 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
|
|||
dlg.SetRepeatVertical( g_RepeatStep.y );
|
||||
dlg.SetRepeatLabel( g_RepeatDeltaLabel );
|
||||
dlg.SetAutoSaveInterval( GetAutoSaveInterval() / 60 );
|
||||
dlg.SetRefIdSeparator( LIB_COMPONENT::GetSubpartIdSeparator( ),
|
||||
LIB_COMPONENT::GetSubpartFirstId() );
|
||||
dlg.SetRefIdSeparator( LIB_PART::GetSubpartIdSeparator( ),
|
||||
LIB_PART::GetSubpartFirstId() );
|
||||
|
||||
dlg.SetShowGrid( IsGridVisible() );
|
||||
dlg.SetShowHiddenPins( m_showAllPins );
|
||||
|
@ -349,11 +403,10 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
|
|||
|
||||
int sep, firstId;
|
||||
dlg.GetRefIdSeparator( sep, firstId);
|
||||
|
||||
if( sep != (int)LIB_COMPONENT::GetSubpartIdSeparator()
|
||||
|| firstId != (int)LIB_COMPONENT::GetSubpartFirstId() )
|
||||
if( sep != (int)LIB_PART::GetSubpartIdSeparator() ||
|
||||
firstId != (int)LIB_PART::GetSubpartFirstId() )
|
||||
{
|
||||
LIB_COMPONENT::SetSubpartIdNotation( sep, firstId );
|
||||
LIB_PART::SetSubpartIdNotation( sep, firstId );
|
||||
SaveProjectSettings( true );
|
||||
}
|
||||
|
||||
|
@ -408,17 +461,19 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParametersList()
|
|||
&BASE_SCREEN::m_PageLayoutDescrFileName ) );
|
||||
|
||||
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "SubpartIdSeparator" ),
|
||||
LIB_COMPONENT::SubpartIdSeparatorPtr(),
|
||||
LIB_PART::SubpartIdSeparatorPtr(),
|
||||
0, 0, 126 ) );
|
||||
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "SubpartFirstId" ),
|
||||
LIB_COMPONENT::SubpartFirstIdPtr(),
|
||||
LIB_PART::SubpartFirstIdPtr(),
|
||||
'A', '1', 'z' ) );
|
||||
|
||||
/* moved to library load/save specific code
|
||||
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),
|
||||
&m_userLibraryPath ) );
|
||||
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
|
||||
&m_componentLibFiles,
|
||||
GROUP_SCH_LIBS ) );
|
||||
*/
|
||||
|
||||
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "NetFmtName" ),
|
||||
&m_netListFormat) );
|
||||
|
@ -445,52 +500,23 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParametersList()
|
|||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& aFileName, bool aForceReread )
|
||||
bool SCH_EDIT_FRAME::LoadProjectFile()
|
||||
{
|
||||
wxFileName fn;
|
||||
bool isRead = true;
|
||||
wxArrayString liblist_tmp = m_componentLibFiles;
|
||||
PROJECT& prj = Prj();
|
||||
|
||||
if( aFileName.IsEmpty() )
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
else
|
||||
fn = aFileName;
|
||||
|
||||
m_componentLibFiles.Clear();
|
||||
|
||||
// Change the schematic file extension (.sch) to the project file
|
||||
// extension (.pro).
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
if( !prj.ConfigLoad( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_SCH,
|
||||
GetProjectFileParametersList(), !aForceReread ) )
|
||||
{
|
||||
m_componentLibFiles = liblist_tmp;
|
||||
isRead = false;
|
||||
}
|
||||
bool isRead = Prj().ConfigLoad( Kiface().KifaceSearch(),
|
||||
GROUP_SCH, GetProjectFileParametersList() );
|
||||
|
||||
// Verify some values, because the config file can be edited by hand,
|
||||
// and have bad values:
|
||||
LIB_COMPONENT::SetSubpartIdNotation( LIB_COMPONENT::GetSubpartIdSeparator(),
|
||||
LIB_COMPONENT::GetSubpartFirstId() );
|
||||
LIB_PART::SetSubpartIdNotation(
|
||||
LIB_PART::GetSubpartIdSeparator(),
|
||||
LIB_PART::GetSubpartFirstId() );
|
||||
|
||||
// Load the page layout decr file, from the filename stored in
|
||||
// BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file
|
||||
// If empty, the default descr is loaded
|
||||
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
|
||||
pglayout.SetPageLayout(BASE_SCREEN::m_PageLayoutDescrFileName);
|
||||
|
||||
// libraries in the *.pro file take precedence over standard library search paths,
|
||||
// but not over the directory of the project, which is at index 0.
|
||||
prj.SchSearchS().AddPaths( m_userLibraryPath, 1 );
|
||||
|
||||
// If the list is empty, force loading the standard power symbol library.
|
||||
if( m_componentLibFiles.GetCount() == 0 )
|
||||
m_componentLibFiles.Add( wxT( "power" ) );
|
||||
|
||||
LoadLibraries();
|
||||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||
pglayout.SetPageLayout( BASE_SCREEN::m_PageLayoutDescrFileName );
|
||||
|
||||
return isRead;
|
||||
}
|
||||
|
@ -518,8 +544,7 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
|
|||
fn = dlg.GetPath();
|
||||
}
|
||||
|
||||
prj.ConfigSave( Kiface().KifaceSearch(),
|
||||
fn.GetFullPath(), GROUP_SCH, GetProjectFileParametersList() );
|
||||
prj.ConfigSave( Kiface().KifaceSearch(), GROUP_SCH, GetProjectFileParametersList() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -549,7 +574,7 @@ static const wxChar FieldNamesEntry[] = wxT( "FieldNames" );
|
|||
static const wxChar SimulatorCommandEntry[] = wxT( "SimCmdLine" );
|
||||
|
||||
|
||||
PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings( void )
|
||||
PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings()
|
||||
{
|
||||
if( !m_configSettings.empty() )
|
||||
return m_configSettings;
|
||||
|
@ -562,79 +587,6 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetConfigurationSettings( void )
|
|||
&m_drawBgColor,
|
||||
WHITE ) );
|
||||
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorWireEx" ),
|
||||
&s_layerColor[LAYER_WIRE],
|
||||
GREEN ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBusEx" ),
|
||||
&s_layerColor[LAYER_BUS],
|
||||
BLUE ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorConnEx" ),
|
||||
&s_layerColor[LAYER_JUNCTION],
|
||||
GREEN ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLLabelEx" ),
|
||||
&s_layerColor[LAYER_LOCLABEL],
|
||||
BLACK ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorHLabelEx" ),
|
||||
&s_layerColor[LAYER_HIERLABEL],
|
||||
BROWN ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGLabelEx" ),
|
||||
&s_layerColor[LAYER_GLOBLABEL],
|
||||
RED ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinNumEx" ),
|
||||
&s_layerColor[LAYER_PINNUM],
|
||||
RED ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinNameEx" ),
|
||||
&s_layerColor[LAYER_PINNAM],
|
||||
CYAN ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorFieldEx" ),
|
||||
&s_layerColor[LAYER_FIELDS],
|
||||
MAGENTA ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorReferenceEx" ),
|
||||
&s_layerColor[LAYER_REFERENCEPART],
|
||||
CYAN ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorValueEx" ),
|
||||
&s_layerColor[LAYER_VALUEPART],
|
||||
CYAN ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoteEx" ),
|
||||
&s_layerColor[LAYER_NOTES],
|
||||
LIGHTBLUE ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyEx" ),
|
||||
&s_layerColor[LAYER_DEVICE],
|
||||
RED ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyBgEx" ),
|
||||
&s_layerColor[LAYER_DEVICE_BACKGROUND],
|
||||
LIGHTYELLOW ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNetNameEx" ),
|
||||
&s_layerColor[LAYER_NETNAM],
|
||||
DARKGRAY ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinEx" ),
|
||||
&s_layerColor[LAYER_PIN],
|
||||
RED ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetEx" ),
|
||||
&s_layerColor[LAYER_SHEET],
|
||||
MAGENTA ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
|
||||
wxT( "ColorSheetFileNameEx" ),
|
||||
&s_layerColor[LAYER_SHEETFILENAME],
|
||||
BROWN ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetNameEx" ),
|
||||
&s_layerColor[LAYER_SHEETNAME],
|
||||
CYAN ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetLabelEx" ),
|
||||
&s_layerColor[LAYER_SHEETLABEL],
|
||||
BROWN ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoConnectEx" ),
|
||||
&s_layerColor[LAYER_NOCONNECT],
|
||||
BLUE ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcWEx" ),
|
||||
&s_layerColor[LAYER_ERC_WARN],
|
||||
GREEN ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcEEx" ),
|
||||
&s_layerColor[LAYER_ERC_ERR],
|
||||
RED ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGridEx" ),
|
||||
&s_layerColor[LAYER_GRID],
|
||||
DARKGRAY ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintMonochrome" ),
|
||||
&m_printMonochrome, true ) );
|
||||
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintSheetReferenceAndTitleBlock" ),
|
||||
|
@ -652,7 +604,6 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|||
|
||||
wxConfigLoadSetups( aCfg, GetConfigurationSettings() );
|
||||
|
||||
// This is required until someone gets rid of the global variable s_layerColor.
|
||||
m_GridColor = GetLayerColor( LAYER_GRID );
|
||||
|
||||
SetDefaultBusThickness( aCfg->Read( DefaultBusWidthEntry, 12l ) );
|
||||
|
|
|
@ -48,7 +48,6 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo
|
|||
{
|
||||
wxString msg;
|
||||
wxFileName schematicFileName;
|
||||
FILE* f;
|
||||
bool success;
|
||||
|
||||
if( aScreen == NULL )
|
||||
|
@ -59,11 +58,12 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo
|
|||
aSaveUnderNewName = true;
|
||||
|
||||
// Construct the name of the file to be saved
|
||||
schematicFileName = aScreen->GetFileName();
|
||||
schematicFileName = Prj().AbsolutePath( aScreen->GetFileName() );
|
||||
|
||||
if( aSaveUnderNewName )
|
||||
{
|
||||
wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(),
|
||||
wxFileDialog dlg( this, _( "Schematic Files" ),
|
||||
wxPathOnly( Prj().GetProjectFullName() ),
|
||||
schematicFileName.GetFullName(), SchematicFileWildcard,
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
|
@ -75,43 +75,38 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo
|
|||
if( schematicFileName.GetExt() != SchematicFileExtension )
|
||||
schematicFileName.SetExt( SchematicFileExtension );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sheet file names are relative to the root sheet path which is the current
|
||||
// working directory. The IsWritable function expects the path to be set.
|
||||
if( schematicFileName.GetPath().IsEmpty() )
|
||||
schematicFileName.Assign( wxFileName::GetCwd(),
|
||||
schematicFileName.GetFullName() );
|
||||
}
|
||||
|
||||
if( !IsWritable( schematicFileName ) )
|
||||
return false;
|
||||
|
||||
/* Create backup if requested */
|
||||
// Create backup if requested
|
||||
if( aCreateBackupFile && schematicFileName.FileExists() )
|
||||
{
|
||||
wxFileName backupFileName = schematicFileName;
|
||||
|
||||
/* Rename the old file to a '.bak' one: */
|
||||
// Rename the old file to a '.bak' one:
|
||||
backupFileName.SetExt( SchematicBackupFileExtension );
|
||||
|
||||
if( backupFileName.FileExists() )
|
||||
wxRemoveFile( backupFileName.GetFullPath() );
|
||||
|
||||
if( !wxRenameFile( schematicFileName.GetFullPath(), backupFileName.GetFullPath() ) )
|
||||
{
|
||||
msg.Printf( _( "Could not save backup of file <%s>" ),
|
||||
msg.Printf( _( "Could not save backup of file '%s'" ),
|
||||
GetChars( schematicFileName.GetFullPath() ) );
|
||||
DisplayError( this, msg );
|
||||
}
|
||||
}
|
||||
|
||||
/* Save */
|
||||
// Save
|
||||
wxLogTrace( traceAutoSave,
|
||||
wxT( "Saving file <" ) + schematicFileName.GetFullPath() + wxT( ">" ) );
|
||||
|
||||
if( ( f = wxFopen( schematicFileName.GetFullPath(), wxT( "wt" ) ) ) == NULL )
|
||||
FILE* f = wxFopen( schematicFileName.GetFullPath(), wxT( "wt" ) );
|
||||
|
||||
if( !f )
|
||||
{
|
||||
msg.Printf( _( "Failed to create file <%s>" ),
|
||||
msg.Printf( _( "Failed to create file '%s'" ),
|
||||
GetChars( schematicFileName.GetFullPath() ) );
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
|
@ -176,245 +171,170 @@ void SCH_EDIT_FRAME::Save_File( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::LoadCacheLibrary( const wxString& aFilename )
|
||||
{
|
||||
wxString msg;
|
||||
bool LibCacheExist = false;
|
||||
wxFileName fn = aFilename;
|
||||
|
||||
/* Loading the project library cache
|
||||
* until apr 2009 the lib is named <root_name>.cache.lib
|
||||
* and after (due to code change): <root_name>-cache.lib
|
||||
* so if the <name>-cache.lib is not found, the old way will be tried
|
||||
*/
|
||||
bool use_oldcachename = false;
|
||||
wxString cachename = fn.GetName() + wxT( "-cache" );
|
||||
|
||||
fn.SetName( cachename );
|
||||
fn.SetExt( SchematicLibraryFileExtension );
|
||||
|
||||
if( ! fn.FileExists() )
|
||||
{
|
||||
fn = aFilename;
|
||||
fn.SetExt( wxT( "cache.lib" ) );
|
||||
use_oldcachename = true;
|
||||
}
|
||||
|
||||
if( fn.FileExists() )
|
||||
{
|
||||
wxString errMsg;
|
||||
|
||||
wxLogDebug( wxT( "Load schematic cache library file <%s>" ),
|
||||
GetChars( fn.GetFullPath() ) );
|
||||
msg = wxT( "Load " ) + fn.GetFullPath();
|
||||
|
||||
CMP_LIBRARY* LibCache = CMP_LIBRARY::LoadLibrary( fn, errMsg );
|
||||
|
||||
if( LibCache )
|
||||
{
|
||||
LibCache->SetCache();
|
||||
msg += wxT( " OK" );
|
||||
|
||||
if ( use_oldcachename ) // set the new name
|
||||
{
|
||||
fn.SetName( cachename );
|
||||
fn.SetExt( SchematicLibraryFileExtension );
|
||||
LibCache->SetFileName( fn );
|
||||
}
|
||||
|
||||
LibCacheExist = true;
|
||||
CMP_LIBRARY::GetLibraryList().push_back( LibCache );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxString prompt;
|
||||
|
||||
prompt.Printf( _( "Component library <%s> failed to load.\nError: %s" ),
|
||||
GetChars( fn.GetFullPath() ),
|
||||
GetChars( errMsg ) );
|
||||
DisplayError( this, prompt );
|
||||
msg += _( " ->Error" );
|
||||
}
|
||||
|
||||
PrintMsg( msg );
|
||||
}
|
||||
|
||||
return LibCacheExist;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
|
||||
{
|
||||
SCH_SCREEN* screen;
|
||||
wxString fullFileName( aFileSet[0] );
|
||||
wxString msg;
|
||||
// implement the pseudo code from KIWAY_PLAYER.h:
|
||||
|
||||
SCH_SCREENS screenList;
|
||||
|
||||
for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() )
|
||||
// This is for python:
|
||||
if( aFileSet.size() != 1 )
|
||||
{
|
||||
if( screen->IsModify() )
|
||||
break;
|
||||
}
|
||||
|
||||
if( screen )
|
||||
{
|
||||
int response = YesNoCancelDialog( this,
|
||||
_( "The current schematic has been modified. Do you wish to save the changes?" ),
|
||||
wxEmptyString,
|
||||
_( "Save and Load" ),
|
||||
_( "Load Without Saving" )
|
||||
);
|
||||
|
||||
if( response == wxID_CANCEL )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if( response == wxID_YES )
|
||||
{
|
||||
wxCommandEvent dummy;
|
||||
OnSaveProject( dummy );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if( fullFileName.IsEmpty() && !aIsNew )
|
||||
{
|
||||
wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(),
|
||||
wxEmptyString, SchematicFileWildcard,
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
|
||||
FullFileName = dlg.GetPath();
|
||||
}
|
||||
*/
|
||||
|
||||
wxFileName fn = fullFileName;
|
||||
|
||||
if( fn.IsRelative() )
|
||||
{
|
||||
fn.MakeAbsolute();
|
||||
fullFileName = fn.GetFullPath();
|
||||
}
|
||||
|
||||
if( !Pgm().LockFile( fullFileName ) )
|
||||
{
|
||||
DisplayError( this, _( "This file is already open." ) );
|
||||
UTF8 msg = StrPrintf( "Eeschema:%s() takes only a single filename", __func__ );
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear the screen before open a new file
|
||||
if( g_RootSheet )
|
||||
wxString fullFileName( aFileSet[0] );
|
||||
|
||||
// We insist on caller sending us an absolute path, if it does not, we say it's a bug.
|
||||
wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(),
|
||||
wxT( "bug in single_top.cpp or project manager." ) );
|
||||
|
||||
if( !Pgm().LockFile( fullFileName ) )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Schematic file '%s' is already open." ),
|
||||
GetChars( fullFileName )
|
||||
);
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
}
|
||||
|
||||
// save any currently open and modified project files.
|
||||
for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
|
||||
{
|
||||
if( screen->IsModify() )
|
||||
{
|
||||
int response = YesNoCancelDialog( this, _(
|
||||
"The current schematic has been modified. Do you wish to save the changes?" ),
|
||||
wxEmptyString,
|
||||
_( "Save and Load" ),
|
||||
_( "Load Without Saving" )
|
||||
);
|
||||
|
||||
if( response == wxID_CANCEL )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if( response == wxID_YES )
|
||||
{
|
||||
wxCommandEvent dummy;
|
||||
OnSaveProject( dummy );
|
||||
}
|
||||
else
|
||||
{
|
||||
// response == wxID_NO, fall thru
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wxFileName pro = fullFileName;
|
||||
pro.SetExt( ProjectFileExtension );
|
||||
|
||||
bool is_new = !wxFileName::IsFileReadable( fullFileName );
|
||||
|
||||
// If its a non-existent schematic and caller thinks it exists
|
||||
if( is_new && !( aCtl & KICTL_CREATE ) )
|
||||
{
|
||||
// notify user that fullFileName does not exist, ask if user wants to create it.
|
||||
wxString ask = wxString::Format( _(
|
||||
"Schematic '%s' does not exist. Do you wish to create it?" ),
|
||||
GetChars( fullFileName )
|
||||
);
|
||||
if( !IsOK( this, ask ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
// unload current project file before loading new
|
||||
{
|
||||
delete g_RootSheet;
|
||||
g_RootSheet = NULL;
|
||||
|
||||
CreateScreens();
|
||||
}
|
||||
|
||||
CreateScreens();
|
||||
screen = GetScreen();
|
||||
|
||||
wxLogDebug( wxT( "Loading schematic " ) + fullFileName );
|
||||
|
||||
// @todo: this is bad:
|
||||
wxSetWorkingDirectory( fn.GetPath() );
|
||||
|
||||
screen->SetFileName( fullFileName );
|
||||
g_RootSheet->SetFileName( fullFileName );
|
||||
SetStatusText( wxEmptyString );
|
||||
ClearMsgPanel();
|
||||
|
||||
screen->ClrModify();
|
||||
|
||||
#if 0
|
||||
if( aIsNew )
|
||||
#if defined(DEBUG) && 1
|
||||
{
|
||||
/* SCH_SCREEN constructor does this now
|
||||
screen->SetPageSettings( PAGE_INFO( wxT( "A4" ) ) );
|
||||
*/
|
||||
wxFileName fn = aFileSet[0];
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
screen->SetZoom( 32 );
|
||||
m_LastGridSizeId = screen->SetGrid( ID_POPUP_GRID_LEVEL_50 );
|
||||
wxString n1 = fn.GetFullPath();
|
||||
wxString n2 = Prj().GetProjectFullName();
|
||||
|
||||
TITLE_BLOCK tb;
|
||||
wxString title;
|
||||
|
||||
title += NAMELESS_PROJECT;
|
||||
title += wxT( ".sch" );
|
||||
tb.SetTitle( title );
|
||||
screen->SetTitleBlock( tb );
|
||||
|
||||
GetScreen()->SetFileName( title );
|
||||
|
||||
LoadProjectFile( wxEmptyString, true );
|
||||
Zoom_Automatique( false );
|
||||
SetSheetNumberAndCount();
|
||||
m_canvas->Refresh();
|
||||
return true;
|
||||
wxASSERT( n1 == n2 );
|
||||
}
|
||||
#endif
|
||||
|
||||
// Reloading configuration.
|
||||
msg.Printf( _( "Ready\nWorking dir: '%s'\n" ), GetChars( wxGetCwd() ) );
|
||||
PrintMsg( msg );
|
||||
GetScreen()->SetFileName( fullFileName );
|
||||
g_RootSheet->SetFileName( fullFileName );
|
||||
|
||||
LoadProjectFile( wxEmptyString, true );
|
||||
SetStatusText( wxEmptyString );
|
||||
ClearMsgPanel();
|
||||
|
||||
// Clear (if needed) the current active library in libedit because it could be
|
||||
// removed from memory
|
||||
LIB_EDIT_FRAME::EnsureActiveLibExists();
|
||||
wxString msg = wxString::Format( _(
|
||||
"Ready\nProject dir: '%s'\n" ),
|
||||
GetChars( wxPathOnly( Prj().GetProjectFullName() ) )
|
||||
);
|
||||
SetStatusText( msg );
|
||||
|
||||
// Delete old caches.
|
||||
CMP_LIBRARY::RemoveCacheLibrary();
|
||||
// PROJECT::SetProjectFullName() is an impactful function. It should only be
|
||||
// called under carefully considered circumstances.
|
||||
|
||||
if( !wxFileExists( g_RootSheet->GetScreen()->GetFileName() ) )
|
||||
// The calling code should know not to ask me here to change projects unless
|
||||
// it knows what consequences that will have on other KIFACEs running and using
|
||||
// this same PROJECT. It can be very harmful if that calling code is stupid.
|
||||
Prj().SetProjectFullName( pro.GetFullPath() );
|
||||
|
||||
LoadProjectFile();
|
||||
|
||||
if( is_new )
|
||||
{
|
||||
Zoom_Automatique( false );
|
||||
// mark new, unsaved file as modified.
|
||||
GetScreen()->SetModify();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_RootSheet->SetScreen( NULL );
|
||||
|
||||
if( aCtl == 0 )
|
||||
{
|
||||
msg.Printf( _( "File '%s' not found." ),
|
||||
GetChars( g_RootSheet->GetScreen()->GetFileName() ) );
|
||||
DisplayInfoMessage( this, msg );
|
||||
}
|
||||
DBG( printf( "%s: loading schematic %s\n", __func__, TO_UTF8( fullFileName ) );)
|
||||
|
||||
return true; // do not close Eeschema if the file if not found:
|
||||
// we may have to create a new schematic file.
|
||||
bool diag = g_RootSheet->Load( this );
|
||||
(void) diag;
|
||||
|
||||
SetScreen( m_CurrentSheet->LastScreen() );
|
||||
|
||||
GetScreen()->ClrModify();
|
||||
|
||||
UpdateFileHistory( fullFileName );
|
||||
}
|
||||
|
||||
// load the project.
|
||||
bool libCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() );
|
||||
|
||||
g_RootSheet->SetScreen( NULL );
|
||||
|
||||
bool diag = g_RootSheet->Load( this );
|
||||
|
||||
SetScreen( m_CurrentSheet->LastScreen() );
|
||||
|
||||
UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() );
|
||||
|
||||
// Redraw base screen (ROOT) if necessary.
|
||||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||
Zoom_Automatique( false );
|
||||
SetSheetNumberAndCount();
|
||||
|
||||
/* this is done in ReDraw()
|
||||
UpdateTitle();
|
||||
*/
|
||||
|
||||
// load the libraries here, not in SCH_SCREEN::Draw() which is a context
|
||||
// that will not tolerate DisplayError() dialog since we're already in an
|
||||
// event handler in there.
|
||||
Prj().SchLibs();
|
||||
|
||||
m_canvas->Refresh( true );
|
||||
|
||||
(void) libCacheExist;
|
||||
(void) diag;
|
||||
|
||||
// return diag;
|
||||
return true; // do not close Eeschema if the file if not found:
|
||||
// we may have to create a new schematic file.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::AppendOneEEProject()
|
||||
{
|
||||
SCH_SCREEN* screen;
|
||||
wxString fullFileName;
|
||||
wxString msg;
|
||||
|
||||
screen = GetScreen();
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
|
||||
if( !screen )
|
||||
{
|
||||
|
@ -423,7 +343,9 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
|||
}
|
||||
|
||||
// open file chooser dialog
|
||||
wxFileDialog dlg( this, _( "Import Schematic" ), wxGetCwd(),
|
||||
wxString path = wxPathOnly( Prj().GetProjectFullName() );
|
||||
|
||||
wxFileDialog dlg( this, _( "Import Schematic" ), path,
|
||||
wxEmptyString, SchematicFileWildcard,
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
||||
|
||||
|
@ -440,7 +362,14 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
|||
fullFileName = fn.GetFullPath();
|
||||
}
|
||||
|
||||
LoadCacheLibrary( fullFileName );
|
||||
wxString cache_name = PART_LIBS::CacheName( fullFileName );
|
||||
if( !!cache_name )
|
||||
{
|
||||
PART_LIBS* libs = Prj().SchLibs();
|
||||
|
||||
if( PART_LIB* lib = libs->AddLibrary( cache_name ) )
|
||||
lib->SetCache();
|
||||
}
|
||||
|
||||
wxLogDebug( wxT( "Importing schematic " ) + fullFileName );
|
||||
|
||||
|
@ -462,6 +391,7 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
|||
{
|
||||
( (SCH_COMPONENT*) bs )->SetTimeStamp( GetNewTimeStamp() );
|
||||
( (SCH_COMPONENT*) bs )->ClearAnnotation( NULL );
|
||||
|
||||
// Clear flags, which are set by these previous modifications:
|
||||
bs->ClearFlags();
|
||||
}
|
||||
|
@ -495,23 +425,25 @@ void SCH_EDIT_FRAME::OnAppendProject( wxCommandEvent& event )
|
|||
void SCH_EDIT_FRAME::OnSaveProject( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SCREEN* screen;
|
||||
wxFileName fn;
|
||||
wxFileName tmp;
|
||||
SCH_SCREENS ScreenList;
|
||||
SCH_SCREENS screenList;
|
||||
|
||||
fn = g_RootSheet->GetFileName();
|
||||
// I want to see it in the debugger, show me the string! Can't do that with wxFileName.
|
||||
wxString fileName = Prj().AbsolutePath( g_RootSheet->GetFileName() );
|
||||
|
||||
// Ensure a path exists. if no path, assume the cwd is used
|
||||
// The IsWritable function expects the path to be set
|
||||
if( !fn.GetPath().IsEmpty() )
|
||||
tmp.AssignDir( fn.GetPath() );
|
||||
else
|
||||
tmp.AssignDir( wxGetCwd() );
|
||||
wxFileName fn = fileName;
|
||||
|
||||
if( !IsWritable( tmp ) )
|
||||
if( !fn.IsDirWritable() )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Directory '%s' is not writable" ),
|
||||
GetChars( fn.GetPath() )
|
||||
);
|
||||
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
|
||||
for( screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
|
||||
SaveEEFile( screen );
|
||||
|
||||
CreateArchiveLibraryCacheFile();
|
||||
|
@ -522,10 +454,11 @@ void SCH_EDIT_FRAME::OnSaveProject( wxCommandEvent& aEvent )
|
|||
|
||||
bool SCH_EDIT_FRAME::doAutoSave()
|
||||
{
|
||||
wxFileName tmpFileName = g_RootSheet->GetFileName();
|
||||
wxFileName fn = tmpFileName;
|
||||
wxFileName tmpFileName = g_RootSheet->GetFileName();
|
||||
wxFileName fn = tmpFileName;
|
||||
wxFileName tmp;
|
||||
SCH_SCREENS screens;
|
||||
|
||||
bool autoSaveOk = true;
|
||||
|
||||
tmp.AssignDir( fn.GetPath() );
|
||||
|
@ -533,7 +466,7 @@ bool SCH_EDIT_FRAME::doAutoSave()
|
|||
if( !IsWritable( tmp ) )
|
||||
return false;
|
||||
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
{
|
||||
// Only create auto save files for the schematics that have been modified.
|
||||
if( !screen->IsSave() )
|
||||
|
|
|
@ -102,14 +102,15 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
|
|||
{
|
||||
int cmpCount = 0;
|
||||
wxString dialogTitle;
|
||||
PART_LIBS* libs = Prj().SchLibs();
|
||||
|
||||
COMPONENT_TREE_SEARCH_CONTAINER search_container; // Container doing search-as-you-type
|
||||
COMPONENT_TREE_SEARCH_CONTAINER search_container( libs ); // Container doing search-as-you-type
|
||||
|
||||
if( !aLibname.IsEmpty() )
|
||||
{
|
||||
CMP_LIBRARY* currLibrary = CMP_LIBRARY::FindLibrary( aLibname );
|
||||
PART_LIB* currLibrary = libs->FindLibrary( aLibname );
|
||||
|
||||
if( currLibrary != NULL )
|
||||
if( currLibrary )
|
||||
{
|
||||
cmpCount = currLibrary->GetCount();
|
||||
search_container.AddLibrary( *currLibrary );
|
||||
|
@ -117,7 +118,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
|
|||
}
|
||||
else
|
||||
{
|
||||
BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
|
||||
BOOST_FOREACH( PART_LIB& lib, *libs )
|
||||
{
|
||||
cmpCount += lib.GetCount();
|
||||
search_container.AddLibrary( lib );
|
||||
|
@ -153,7 +154,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const wxString& aLibname,
|
|||
if( dlg.IsExternalBrowserSelected() ) // User requested big component browser.
|
||||
cmpName = SelectComponentFromLibBrowser( alias, aUnit, aConvert);
|
||||
|
||||
if ( !cmpName.empty() )
|
||||
if( !cmpName.empty() )
|
||||
{
|
||||
AddHistoryComponentName( aHistoryList, cmpName );
|
||||
if ( aUnit ) aHistoryLastUnit = *aUnit;
|
||||
|
@ -174,10 +175,10 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
|
|||
SetRepeatItem( NULL );
|
||||
m_canvas->SetIgnoreMouseEvents( true );
|
||||
|
||||
wxString Name = SelectComponentFromLibrary( aLibname, aHistoryList, aHistoryLastUnit,
|
||||
wxString name = SelectComponentFromLibrary( aLibname, aHistoryList, aHistoryLastUnit,
|
||||
aUseLibBrowser, &unit, &convert );
|
||||
|
||||
if( Name.IsEmpty() )
|
||||
if( name.IsEmpty() )
|
||||
{
|
||||
m_canvas->SetIgnoreMouseEvents( false );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
|
@ -185,33 +186,34 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
|
|||
}
|
||||
|
||||
#ifndef KICAD_KEEPCASE
|
||||
Name.MakeUpper();
|
||||
name.MakeUpper();
|
||||
#endif
|
||||
|
||||
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( Name, aLibname );
|
||||
|
||||
m_canvas->SetIgnoreMouseEvents( false );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
|
||||
if( Entry == NULL )
|
||||
LIB_PART* part = Prj().SchLibs()->FindLibPart( name, aLibname );
|
||||
|
||||
if( !part )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Failed to find part <%s> in library" ), GetChars( Name ) );
|
||||
wxString msg = wxString::Format( _(
|
||||
"Failed to find part '%s' in library" ),
|
||||
GetChars( name )
|
||||
);
|
||||
wxMessageBox( msg );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SCH_COMPONENT* component;
|
||||
component = new SCH_COMPONENT( *Entry, m_CurrentSheet, unit, convert,
|
||||
GetCrossHairPosition(), true );
|
||||
SCH_COMPONENT* component = new SCH_COMPONENT( *part, m_CurrentSheet, unit, convert,
|
||||
GetCrossHairPosition(), true );
|
||||
|
||||
// Set the m_ChipName value, from component name in lib, for aliases
|
||||
// Note if Entry is found, and if Name is an alias of a component,
|
||||
// Note if part is found, and if name is an alias of a component,
|
||||
// alias exists because its root component was found
|
||||
component->SetLibName( Name );
|
||||
component->SetPartName( name );
|
||||
|
||||
// Set the component value that can differ from component name in lib, for aliases
|
||||
component->GetField( VALUE )->SetText( Name );
|
||||
component->GetField( VALUE )->SetText( name );
|
||||
|
||||
MSG_PANEL_ITEMS items;
|
||||
|
||||
|
@ -275,12 +277,12 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
|
|||
|
||||
|
||||
/*
|
||||
* Handle select part in multi-part component.
|
||||
* Handle select part in multi-unit part.
|
||||
*/
|
||||
void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
wxCHECK_RET( item != NULL && item->Type() == SCH_COMPONENT_T,
|
||||
wxT( "Cannot select unit of invalid schematic item." ) );
|
||||
|
@ -293,98 +295,92 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
|
|||
|
||||
int unit = aEvent.GetId() + 1 - ID_POPUP_SCH_SELECT_UNIT1;
|
||||
|
||||
LIB_COMPONENT* libEntry = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() );
|
||||
if( LIB_PART* part = Prj().SchLibs()->FindLibPart( component->GetPartName() ) )
|
||||
{
|
||||
wxCHECK_RET( (unit >= 1) && (unit <= part->GetUnitCount()),
|
||||
wxString::Format( wxT( "Cannot select unit %d from component " ), unit ) +
|
||||
part->GetName() );
|
||||
|
||||
if( libEntry == NULL )
|
||||
return;
|
||||
int unitCount = part->GetUnitCount();
|
||||
|
||||
wxCHECK_RET( (unit >= 1) && (unit <= libEntry->GetPartCount()),
|
||||
wxString::Format( wxT( "Cannot select unit %d from component "), unit ) +
|
||||
libEntry->GetName() );
|
||||
if( unitCount <= 1 || component->GetUnit() == unit )
|
||||
return;
|
||||
|
||||
int unitCount = libEntry->GetPartCount();
|
||||
if( unit < 1 )
|
||||
unit = 1;
|
||||
|
||||
if( (unitCount <= 1) || (component->GetUnit() == unit) )
|
||||
return;
|
||||
if( unit > unitCount )
|
||||
unit = unitCount;
|
||||
|
||||
if( unit < 1 )
|
||||
unit = 1;
|
||||
STATUS_FLAGS flags = component->GetFlags();
|
||||
|
||||
if( unit > unitCount )
|
||||
unit = unitCount;
|
||||
if( !flags ) // No command in progress: save in undo list
|
||||
SaveCopyInUndoList( component, UR_CHANGED );
|
||||
|
||||
STATUS_FLAGS flags = component->GetFlags();
|
||||
if( flags )
|
||||
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
|
||||
else
|
||||
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
if( !flags ) // No command in progress: save in undo list
|
||||
SaveCopyInUndoList( component, UR_CHANGED );
|
||||
/* Update the unit number. */
|
||||
component->SetUnitSelection( m_CurrentSheet, unit );
|
||||
component->SetUnit( unit );
|
||||
component->ClearFlags();
|
||||
component->SetFlags( flags ); // Restore m_Flag modified by SetUnit()
|
||||
|
||||
if( flags )
|
||||
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
|
||||
else
|
||||
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
|
||||
/* Redraw the component in the new position. */
|
||||
if( flags )
|
||||
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
|
||||
else
|
||||
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
|
||||
/* Update the unit number. */
|
||||
component->SetUnitSelection( m_CurrentSheet, unit );
|
||||
component->SetUnit( unit );
|
||||
component->ClearFlags();
|
||||
component->SetFlags( flags ); // Restore m_Flag modified by SetUnit()
|
||||
|
||||
/* Redraw the component in the new position. */
|
||||
if( flags )
|
||||
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
|
||||
else
|
||||
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
|
||||
screen->TestDanglingEnds( m_canvas, &dc );
|
||||
OnModify();
|
||||
screen->TestDanglingEnds( m_canvas, &dc );
|
||||
OnModify();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* DrawComponent, wxDC* DC )
|
||||
{
|
||||
LIB_COMPONENT* LibEntry;
|
||||
|
||||
if( DrawComponent == NULL )
|
||||
if( !DrawComponent )
|
||||
return;
|
||||
|
||||
LibEntry = CMP_LIBRARY::FindLibraryComponent( DrawComponent->GetLibName() );
|
||||
|
||||
if( LibEntry == NULL )
|
||||
return;
|
||||
|
||||
if( !LibEntry->HasConversion() )
|
||||
if( LIB_PART* part = Prj().SchLibs()->FindLibPart( DrawComponent->GetPartName() ) )
|
||||
{
|
||||
DisplayError( this, wxT( "No convert found" ) );
|
||||
return;
|
||||
if( !part->HasConversion() )
|
||||
{
|
||||
DisplayError( this, wxT( "No convert found" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
STATUS_FLAGS flags = DrawComponent->GetFlags();
|
||||
|
||||
if( DrawComponent->GetFlags() )
|
||||
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
|
||||
else
|
||||
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
DrawComponent->SetConvert( DrawComponent->GetConvert() + 1 );
|
||||
|
||||
// ensure m_Convert = 0, 1 or 2
|
||||
// 0 and 1 = shape 1 = not converted
|
||||
// 2 = shape 2 = first converted shape
|
||||
// > 2 is not used but could be used for more shapes
|
||||
// like multiple shapes for a programmable component
|
||||
// When m_Convert = val max, return to the first shape
|
||||
if( DrawComponent->GetConvert() > 2 )
|
||||
DrawComponent->SetConvert( 1 );
|
||||
|
||||
DrawComponent->ClearFlags();
|
||||
DrawComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert())
|
||||
|
||||
/* Redraw the component in the new position. */
|
||||
if( DrawComponent->IsMoving() )
|
||||
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
|
||||
else
|
||||
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
|
||||
GetScreen()->TestDanglingEnds( m_canvas, DC );
|
||||
OnModify();
|
||||
}
|
||||
|
||||
STATUS_FLAGS flags = DrawComponent->GetFlags();
|
||||
|
||||
if( DrawComponent->GetFlags() )
|
||||
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
|
||||
else
|
||||
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
DrawComponent->SetConvert( DrawComponent->GetConvert() + 1 );
|
||||
|
||||
// ensure m_Convert = 0, 1 or 2
|
||||
// 0 and 1 = shape 1 = not converted
|
||||
// 2 = shape 2 = first converted shape
|
||||
// > 2 is not used but could be used for more shapes
|
||||
// like multiple shapes for a programmable component
|
||||
// When m_Convert = val max, return to the first shape
|
||||
if( DrawComponent->GetConvert() > 2 )
|
||||
DrawComponent->SetConvert( 1 );
|
||||
|
||||
DrawComponent->ClearFlags();
|
||||
DrawComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert())
|
||||
|
||||
/* Redraw the component in the new position. */
|
||||
if( DrawComponent->IsMoving() )
|
||||
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
|
||||
else
|
||||
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
|
||||
GetScreen()->TestDanglingEnds( m_canvas, DC );
|
||||
OnModify( );
|
||||
}
|
||||
|
|
|
@ -75,6 +75,8 @@ int InvokeDialogCreateBOM( SCH_EDIT_FRAME* aCaller );
|
|||
#define NET_PLUGIN_CHANGE 1
|
||||
int InvokeDialogNetList( SCH_EDIT_FRAME* aCaller );
|
||||
|
||||
int InvokeEeschemaConfig( SCH_EDIT_FRAME* aEditFrame, wxFrame* aParent );
|
||||
bool InvokeEeschemaConfig( wxWindow* aParent,
|
||||
wxString* aCallersProjectSpecificLibPaths, wxArrayString* aCallersLibNames );
|
||||
|
||||
|
||||
#endif // INVOKE_SCH_DIALOG_H_
|
||||
|
|
|
@ -84,7 +84,7 @@ static wxPoint calcCenter( const wxPoint& A, const wxPoint& B, const wxPoint& C
|
|||
}
|
||||
|
||||
|
||||
LIB_ARC::LIB_ARC( LIB_COMPONENT* aParent ) : LIB_ITEM( LIB_ARC_T, aParent )
|
||||
LIB_ARC::LIB_ARC( LIB_PART* aParent ) : LIB_ITEM( LIB_ARC_T, aParent )
|
||||
{
|
||||
m_Radius = 0;
|
||||
m_t1 = 0;
|
||||
|
|
|
@ -84,7 +84,7 @@ class LIB_ARC : public LIB_ITEM
|
|||
void calcRadiusAngles();
|
||||
|
||||
public:
|
||||
LIB_ARC( LIB_COMPONENT * aParent );
|
||||
LIB_ARC( LIB_PART * aParent );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include <transform.h>
|
||||
|
||||
|
||||
LIB_BEZIER::LIB_BEZIER( LIB_COMPONENT* aParent ) :
|
||||
LIB_BEZIER::LIB_BEZIER( LIB_PART* aParent ) :
|
||||
LIB_ITEM( LIB_BEZIER_T, aParent )
|
||||
{
|
||||
m_Fill = NO_FILL;
|
||||
|
|
|
@ -47,7 +47,7 @@ class LIB_BEZIER : public LIB_ITEM
|
|||
const TRANSFORM& aTransform );
|
||||
|
||||
public:
|
||||
LIB_BEZIER( LIB_COMPONENT * aParent );
|
||||
LIB_BEZIER( LIB_PART * aParent );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include <transform.h>
|
||||
|
||||
|
||||
LIB_CIRCLE::LIB_CIRCLE( LIB_COMPONENT* aParent ) :
|
||||
LIB_CIRCLE::LIB_CIRCLE( LIB_PART* aParent ) :
|
||||
LIB_ITEM( LIB_CIRCLE_T, aParent )
|
||||
{
|
||||
m_Radius = 0;
|
||||
|
|
|
@ -45,7 +45,7 @@ class LIB_CIRCLE : public LIB_ITEM
|
|||
void calcEdit( const wxPoint& aPosition );
|
||||
|
||||
public:
|
||||
LIB_CIRCLE( LIB_COMPONENT * aParent );
|
||||
LIB_CIRCLE( LIB_PART * aParent );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ const int fill_tab[3] = { 'N', 'F', 'f' };
|
|||
|
||||
|
||||
LIB_ITEM::LIB_ITEM( KICAD_T aType,
|
||||
LIB_COMPONENT* aComponent,
|
||||
LIB_PART* aComponent,
|
||||
int aUnit,
|
||||
int aConvert,
|
||||
FILL_T aFillType ) :
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
class LINE_READER;
|
||||
class OUTPUTFORMATTER;
|
||||
class LIB_COMPONENT;
|
||||
class LIB_PART;
|
||||
class PLOTTER;
|
||||
class LIB_ITEM;
|
||||
class LIB_PIN;
|
||||
|
@ -117,7 +117,7 @@ class LIB_ITEM : public EDA_ITEM
|
|||
bool m_eraseLastDrawItem; ///< Used when editing a new draw item to prevent drawing
|
||||
///< artifacts.
|
||||
|
||||
friend class LIB_COMPONENT;
|
||||
friend class LIB_PART;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -150,7 +150,7 @@ protected:
|
|||
public:
|
||||
|
||||
LIB_ITEM( KICAD_T aType,
|
||||
LIB_COMPONENT* aComponent = NULL,
|
||||
LIB_PART* aComponent = NULL,
|
||||
int aUnit = 0,
|
||||
int aConvert = 0,
|
||||
FILL_T aFillType = NO_FILL );
|
||||
|
@ -237,9 +237,9 @@ public:
|
|||
|
||||
virtual bool Load( LINE_READER& aLine, wxString& aErrorMsg ) = 0;
|
||||
|
||||
LIB_COMPONENT* GetParent() const
|
||||
LIB_PART* GetParent() const
|
||||
{
|
||||
return (LIB_COMPONENT *)m_Parent;
|
||||
return (LIB_PART *)m_Parent;
|
||||
}
|
||||
|
||||
virtual bool HitTest( const wxPoint& aPosition ) const
|
||||
|
|
|
@ -46,11 +46,6 @@ extern int ExportPartId;
|
|||
|
||||
void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event )
|
||||
{
|
||||
wxString errMsg;
|
||||
wxFileName fn;
|
||||
CMP_LIBRARY* LibTmp;
|
||||
LIB_ALIAS* LibEntry;
|
||||
|
||||
m_lastDrawItem = NULL;
|
||||
|
||||
wxFileDialog dlg( this, _( "Import Component" ), m_lastLibImportPath,
|
||||
|
@ -60,25 +55,40 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event )
|
|||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return;
|
||||
|
||||
fn = dlg.GetPath();
|
||||
wxFileName fn = dlg.GetPath();
|
||||
|
||||
LibTmp = CMP_LIBRARY::LoadLibrary( fn, errMsg );
|
||||
std::auto_ptr<PART_LIB> lib;
|
||||
|
||||
if( LibTmp == NULL )
|
||||
return;
|
||||
|
||||
LibEntry = LibTmp->GetFirstEntry();
|
||||
|
||||
if( LibEntry == NULL )
|
||||
try
|
||||
{
|
||||
wxString msg;
|
||||
std::auto_ptr<PART_LIB> new_lib( PART_LIB::LoadLibrary( fn.GetFullPath() ) );
|
||||
lib = new_lib;
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Unable to import library '%s'. Error:\n"
|
||||
"%s" ),
|
||||
GetChars( fn.GetFullPath() )
|
||||
);
|
||||
|
||||
msg.Printf( _( "Component library file <%s> is empty." ), GetChars( fn.GetFullPath() ) );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
LIB_ALIAS* entry = lib->GetFirstEntry();
|
||||
|
||||
if( !entry )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Part library file '%s' is empty." ),
|
||||
GetChars( fn.GetFullPath() )
|
||||
);
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
if( LoadOneLibraryPartAux( LibEntry, LibTmp ) )
|
||||
if( LoadOneLibraryPartAux( entry, lib.get() ) )
|
||||
{
|
||||
fn = dlg.GetPath();
|
||||
m_lastLibImportPath = fn.GetPath();
|
||||
|
@ -86,42 +96,39 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event )
|
|||
GetScreen()->ClearUndoRedoList();
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
delete LibTmp;
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn;
|
||||
wxString msg, title;
|
||||
CMP_LIBRARY* CurLibTmp;
|
||||
bool createLib = ( event.GetId() == ExportPartId ) ? false : true;
|
||||
wxString msg, title;
|
||||
bool createLib = ( event.GetId() == ExportPartId ) ? false : true;
|
||||
|
||||
if( m_component == NULL )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
{
|
||||
DisplayError( this, _( "There is no component selected to save." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
fn = m_component->GetName().Lower();
|
||||
wxFileName fn = part->GetName().Lower();
|
||||
|
||||
fn.SetExt( SchematicLibraryFileExtension );
|
||||
|
||||
title = createLib ? _( "New Library" ) : _( "Export Component" );
|
||||
|
||||
wxFileDialog dlg( this, title, wxGetCwd(), fn.GetFullName(),
|
||||
SchematicLibraryFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
wxFileDialog dlg( this, title, m_lastLibExportPath, fn.GetFullName(),
|
||||
SchematicLibraryFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return;
|
||||
|
||||
fn = dlg.GetPath();
|
||||
|
||||
CurLibTmp = m_library;
|
||||
std::auto_ptr<PART_LIB> temp_lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, fn.GetFullPath() ) );
|
||||
|
||||
m_library = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, fn );
|
||||
|
||||
SaveOnePartInMemory();
|
||||
SaveOnePart( temp_lib.get() );
|
||||
|
||||
bool result = false;
|
||||
|
||||
|
@ -129,7 +136,7 @@ void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event )
|
|||
{
|
||||
FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
|
||||
|
||||
result = m_library->Save( formatter );
|
||||
result = GetCurLib()->Save( formatter );
|
||||
}
|
||||
catch( ... /* IO_ERROR ioe */ )
|
||||
{
|
||||
|
@ -142,26 +149,24 @@ void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event )
|
|||
if( result )
|
||||
m_lastLibExportPath = fn.GetPath();
|
||||
|
||||
delete m_library;
|
||||
m_library = CurLibTmp;
|
||||
|
||||
if( result )
|
||||
{
|
||||
if( createLib )
|
||||
{
|
||||
msg.Printf( _( "<%s> - OK" ), GetChars( fn.GetFullPath() ) );
|
||||
DisplayInfoMessage( this, _( "This library will not be available \
|
||||
until it is loaded by Eeschema.\n\nModify the Eeschema library configuration \
|
||||
if you want to include it as part of this project." ) );
|
||||
msg.Printf( _( "'%s' - OK" ), GetChars( fn.GetFullPath() ) );
|
||||
DisplayInfoMessage( this, _(
|
||||
"This library will not be available until it is loaded by Eeschema.\n\n"
|
||||
"Modify the Eeschema library configuration if you want to include it"
|
||||
" as part of this project." ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Printf( _( "<%s> - Export OK" ), GetChars( fn.GetFullPath() ) );
|
||||
msg.Printf( _( "'%s' - Export OK" ), GetChars( fn.GetFullPath() ) );
|
||||
}
|
||||
} // Error
|
||||
else
|
||||
}
|
||||
else // Error
|
||||
{
|
||||
msg.Printf( _( "Error creating <%s>" ), GetChars( fn.GetFullName() ) );
|
||||
msg.Printf( _( "Error creating '%s'" ), GetChars( fn.GetFullName() ) );
|
||||
}
|
||||
|
||||
SetStatusText( msg );
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include <template_fieldnames.h>
|
||||
|
||||
|
||||
LIB_FIELD::LIB_FIELD(LIB_COMPONENT * aParent, int idfield ) :
|
||||
LIB_FIELD::LIB_FIELD(LIB_PART * aParent, int idfield ) :
|
||||
LIB_ITEM( LIB_FIELD_T, aParent )
|
||||
{
|
||||
Init( idfield );
|
||||
|
@ -346,9 +346,9 @@ bool LIB_FIELD::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFO
|
|||
{
|
||||
wxString extended_text = tmp_text.GetText();
|
||||
extended_text.Append('?');
|
||||
const LIB_COMPONENT* parent = static_cast<const LIB_COMPONENT*>( m_Parent );
|
||||
const LIB_PART* parent = static_cast<const LIB_PART* >( m_Parent );
|
||||
|
||||
if ( parent && ( parent->GetPartCount() > 1 ) )
|
||||
if ( parent && ( parent->GetUnitCount() > 1 ) )
|
||||
extended_text.Append('A');
|
||||
tmp_text.SetText( extended_text );
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ wxString LIB_FIELD::GetFullText( int unit )
|
|||
text << wxT( "?" );
|
||||
|
||||
if( GetParent()->IsMulti() )
|
||||
text << LIB_COMPONENT::SubReference( unit );
|
||||
text << LIB_PART::SubReference( unit );
|
||||
|
||||
return text;
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ void LIB_FIELD::SetText( const wxString& aText )
|
|||
|
||||
if( m_id == VALUE && m_Parent != NULL )
|
||||
{
|
||||
LIB_COMPONENT* parent = GetParent();
|
||||
LIB_PART* parent = GetParent();
|
||||
|
||||
// Set the parent component and root alias to the new name.
|
||||
if( parent->GetName().CmpNoCase( aText ) != 0 )
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
|
||||
LIB_FIELD( int idfield = 2 );
|
||||
|
||||
LIB_FIELD( LIB_COMPONENT * aParent, int idfield = 2 );
|
||||
LIB_FIELD( LIB_PART * aParent, int idfield = 2 );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ static int ExternalPinDecoSize( const LIB_PIN &aPin )
|
|||
return aPin.GetNumberTextSize() / 2;
|
||||
}
|
||||
|
||||
LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) :
|
||||
LIB_PIN::LIB_PIN( LIB_PART* aParent ) :
|
||||
LIB_ITEM( LIB_PIN_T, aParent )
|
||||
{
|
||||
m_length = GetDefaultPinLength(); // default Pin len
|
||||
|
@ -209,7 +209,7 @@ LIB_PIN::LIB_PIN( LIB_COMPONENT* aParent ) :
|
|||
m_attributes = 0; // bit 0 != 0: pin invisible
|
||||
m_number = 0; // pin number (i.e. 4 ASCII chars)
|
||||
m_numTextSize = GetDefaultTextSize(); // Default size for pin name and num
|
||||
m_nameTextSize = GetDefaultTextSize();
|
||||
m_nameTextSize = GetDefaultTextSize();
|
||||
m_width = 0;
|
||||
m_typeName = _( "Pin" );
|
||||
}
|
||||
|
@ -834,7 +834,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
|
|||
aColor = GetInvisibleItemColor();
|
||||
}
|
||||
|
||||
LIB_COMPONENT* Entry = GetParent();
|
||||
LIB_PART* Entry = GetParent();
|
||||
bool DrawPinText = true;
|
||||
|
||||
if( ( aData != NULL ) && ( (bool*) aData == false ) )
|
||||
|
@ -1956,7 +1956,7 @@ void LIB_PIN::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
|
|||
|
||||
const EDA_RECT LIB_PIN::GetBoundingBox() const
|
||||
{
|
||||
LIB_COMPONENT* entry = (LIB_COMPONENT*) m_Parent;
|
||||
LIB_PART* entry = (LIB_PART* ) m_Parent;
|
||||
EDA_RECT bbox;
|
||||
wxPoint begin;
|
||||
wxPoint end;
|
||||
|
|
|
@ -105,7 +105,7 @@ class LIB_PIN : public LIB_ITEM
|
|||
const TRANSFORM& aTransform );
|
||||
|
||||
public:
|
||||
LIB_PIN( LIB_COMPONENT* aParent );
|
||||
LIB_PIN( LIB_PART* aParent );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include <boost/foreach.hpp>
|
||||
|
||||
|
||||
LIB_POLYLINE::LIB_POLYLINE( LIB_COMPONENT* aParent ) :
|
||||
LIB_POLYLINE::LIB_POLYLINE( LIB_PART* aParent ) :
|
||||
LIB_ITEM( LIB_POLYLINE_T, aParent )
|
||||
{
|
||||
m_Fill = NO_FILL;
|
||||
|
|
|
@ -46,7 +46,7 @@ class LIB_POLYLINE : public LIB_ITEM
|
|||
void calcEdit( const wxPoint& aPosition );
|
||||
|
||||
public:
|
||||
LIB_POLYLINE( LIB_COMPONENT * aParent );
|
||||
LIB_POLYLINE( LIB_PART * aParent );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include <transform.h>
|
||||
|
||||
|
||||
LIB_RECTANGLE::LIB_RECTANGLE( LIB_COMPONENT* aParent ) :
|
||||
LIB_RECTANGLE::LIB_RECTANGLE( LIB_PART* aParent ) :
|
||||
LIB_ITEM( LIB_RECTANGLE_T, aParent )
|
||||
{
|
||||
m_Width = 0;
|
||||
|
|
|
@ -48,7 +48,7 @@ class LIB_RECTANGLE : public LIB_ITEM
|
|||
void calcEdit( const wxPoint& aPosition );
|
||||
|
||||
public:
|
||||
LIB_RECTANGLE( LIB_COMPONENT * aParent );
|
||||
LIB_RECTANGLE( LIB_PART * aParent );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include <lib_text.h>
|
||||
|
||||
|
||||
LIB_TEXT::LIB_TEXT( LIB_COMPONENT * aParent ) :
|
||||
LIB_TEXT::LIB_TEXT( LIB_PART * aParent ) :
|
||||
LIB_ITEM( LIB_TEXT_T, aParent ),
|
||||
EDA_TEXT()
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
|
|||
void calcEdit( const wxPoint& aPosition );
|
||||
|
||||
public:
|
||||
LIB_TEXT( LIB_COMPONENT * aParent );
|
||||
LIB_TEXT( LIB_PART * aParent );
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
|
|
|
@ -61,19 +61,18 @@ bool SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile( bool aUseCurrentSheetFilenam
|
|||
|
||||
bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
|
||||
{
|
||||
wxString msg;
|
||||
LIB_COMPONENT* libComponent;
|
||||
CMP_LIBRARY* libCache;
|
||||
SCH_SCREENS screens;
|
||||
SCH_SCREENS screens;
|
||||
PART_LIBS* libs = Prj().SchLibs();
|
||||
|
||||
std::auto_ptr<PART_LIB> libCache( new PART_LIB( LIBRARY_TYPE_EESCHEMA, aFileName ) );
|
||||
|
||||
libCache = new CMP_LIBRARY( LIBRARY_TYPE_EESCHEMA, aFileName );
|
||||
libCache->SetCache();
|
||||
|
||||
/* examine all screens (not sheets) used and build the list of components
|
||||
* found in lib complex hierarchies are not a problem because we just want
|
||||
* to know used components in libraries
|
||||
*/
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
|
||||
{
|
||||
for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
|
||||
{
|
||||
|
@ -81,14 +80,15 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
|
|||
continue;
|
||||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
||||
|
||||
// If not already saved in the new cache, put it:
|
||||
|
||||
if( libCache->FindEntry( component->GetLibName()) == NULL )
|
||||
if( !libCache->FindEntry( component->GetPartName() ) )
|
||||
{
|
||||
libComponent = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() );
|
||||
|
||||
if( libComponent ) // if NULL : component not found, cannot be stored
|
||||
libCache->AddComponent( libComponent );
|
||||
if( LIB_PART* part = libs->FindLibPart( component->GetPartName() ) )
|
||||
{
|
||||
// AddPart() does first clone the part before adding.
|
||||
libCache->AddPart( part );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,16 +99,20 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
|
|||
|
||||
if( !libCache->Save( formatter ) )
|
||||
{
|
||||
msg.Printf( _( "An error occurred attempting to save component library <%s>." ),
|
||||
GetChars( aFileName ) );
|
||||
wxString msg = wxString::Format( _(
|
||||
"An error occurred attempting to save component library '%s'." ),
|
||||
GetChars( aFileName )
|
||||
);
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch( ... /* IO_ERROR ioe */ )
|
||||
{
|
||||
msg.Printf( _( "Failed to create component library file <%s>" ),
|
||||
GetChars( aFileName ) );
|
||||
wxString msg = wxString::Format( _(
|
||||
"Failed to create component library file '%s'" ),
|
||||
GetChars( aFileName )
|
||||
);
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -51,15 +51,14 @@
|
|||
|
||||
void LIB_EDIT_FRAME::DisplayLibInfos()
|
||||
{
|
||||
wxString msg = _( "Component Library Editor: " );
|
||||
wxString msg = _( "Part Library Editor: " );
|
||||
PART_LIB* lib = GetCurLib();
|
||||
|
||||
EnsureActiveLibExists();
|
||||
|
||||
if( m_library )
|
||||
if( lib )
|
||||
{
|
||||
msg += m_library->GetFullFileName();
|
||||
msg += lib->GetFullFileName();
|
||||
|
||||
if( m_library->IsReadOnly() )
|
||||
if( lib->IsReadOnly() )
|
||||
msg += _( " [Read Only]" );
|
||||
}
|
||||
else
|
||||
|
@ -71,21 +70,21 @@ void LIB_EDIT_FRAME::DisplayLibInfos()
|
|||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::SelectActiveLibrary( CMP_LIBRARY* aLibrary )
|
||||
void LIB_EDIT_FRAME::SelectActiveLibrary( PART_LIB* aLibrary )
|
||||
{
|
||||
if( aLibrary == NULL )
|
||||
if( !aLibrary )
|
||||
aLibrary = SelectLibraryFromList( this );
|
||||
|
||||
if( aLibrary )
|
||||
{
|
||||
m_library = aLibrary;
|
||||
SetCurLib( aLibrary );
|
||||
}
|
||||
|
||||
DisplayLibInfos();
|
||||
}
|
||||
|
||||
|
||||
bool LIB_EDIT_FRAME::LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, CMP_LIBRARY* aLibrary )
|
||||
bool LIB_EDIT_FRAME::LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, PART_LIB* aLibrary )
|
||||
{
|
||||
if( GetScreen()->IsModify()
|
||||
&& !IsOK( this, _( "The current component is not saved.\n\nDiscard current changes?" ) ) )
|
||||
|
@ -98,14 +97,14 @@ bool LIB_EDIT_FRAME::LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, CMP_LIBRAR
|
|||
|
||||
bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry )
|
||||
{
|
||||
if( !LoadOneLibraryPartAux( aLibEntry, m_library ) )
|
||||
if( !LoadOneLibraryPartAux( aLibEntry, GetCurLib() ) )
|
||||
return false;
|
||||
|
||||
m_editPinsPerPartOrConvert = m_component->UnitsLocked() ? true : false;
|
||||
m_editPinsPerPartOrConvert = GetCurPart()->UnitsLocked() ? true : false;
|
||||
|
||||
GetScreen()->ClearUndoRedoList();
|
||||
Zoom_Automatique( false );
|
||||
SetShowDeMorgan( m_component->HasConversion() );
|
||||
SetShowDeMorgan( GetCurPart()->HasConversion() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -113,8 +112,7 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry )
|
|||
|
||||
void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
|
||||
{
|
||||
wxString msg;
|
||||
wxString CmpName;
|
||||
wxString cmp_name;
|
||||
LIB_ALIAS* libEntry = NULL;
|
||||
|
||||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
||||
|
@ -123,80 +121,84 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
|
|||
&& !IsOK( this, _( "The current component is not saved.\n\nDiscard current changes?" ) ) )
|
||||
return;
|
||||
|
||||
// No current lib, ask user for the library to use.
|
||||
if( m_library == NULL )
|
||||
PART_LIB* lib = GetCurLib();
|
||||
|
||||
// No current lib, ask user for the library to use.
|
||||
if( !lib )
|
||||
{
|
||||
SelectActiveLibrary();
|
||||
lib = GetCurLib();
|
||||
|
||||
if( m_library == NULL )
|
||||
if( !lib )
|
||||
return;
|
||||
}
|
||||
|
||||
wxArrayString dummyHistoryList;
|
||||
int dummyLastUnit;
|
||||
CmpName = SelectComponentFromLibrary( m_library->GetName(), dummyHistoryList, dummyLastUnit,
|
||||
cmp_name = SelectComponentFromLibrary( lib->GetName(), dummyHistoryList, dummyLastUnit,
|
||||
true, NULL, NULL );
|
||||
|
||||
if( CmpName.IsEmpty() )
|
||||
if( cmp_name.IsEmpty() )
|
||||
return;
|
||||
|
||||
GetScreen()->ClrModify();
|
||||
m_lastDrawItem = m_drawItem = NULL;
|
||||
|
||||
// Delete previous library component, if any
|
||||
if( m_component )
|
||||
SetCurPart( NULL );
|
||||
m_aliasName.Empty();
|
||||
|
||||
// Load the new library component
|
||||
libEntry = lib->FindEntry( cmp_name );
|
||||
PART_LIB* searchLib = lib;
|
||||
|
||||
if( !libEntry )
|
||||
{
|
||||
delete m_component;
|
||||
m_component = NULL;
|
||||
m_aliasName.Empty();
|
||||
}
|
||||
|
||||
/* Load the new library component */
|
||||
libEntry = m_library->FindEntry( CmpName );
|
||||
CMP_LIBRARY* searchLib = m_library;
|
||||
|
||||
if( libEntry == NULL )
|
||||
{ // Not found in the active library: search inside the full list
|
||||
// Not found in the active library: search inside the full list
|
||||
// (can happen when using Viewlib to load a component)
|
||||
libEntry = CMP_LIBRARY::FindLibraryEntry( CmpName );
|
||||
libEntry = Prj().SchLibs()->FindLibraryEntry( cmp_name );
|
||||
|
||||
if( libEntry )
|
||||
{
|
||||
searchLib = libEntry->GetLibrary();
|
||||
searchLib = libEntry->GetLib();
|
||||
|
||||
// The entry to load is not in the active lib
|
||||
// Ask for a new active lib
|
||||
wxString msg;
|
||||
msg << _("The selected component is not in the active library");
|
||||
msg << wxT("\n\n");
|
||||
msg << _("Do you want to change the active library?");
|
||||
wxString msg = _( "The selected component is not in the active library." );
|
||||
msg += wxT("\n\n");
|
||||
msg += _( "Do you want to change the active library?" );
|
||||
|
||||
if( IsOK( this, msg ) )
|
||||
SelectActiveLibrary( searchLib );
|
||||
}
|
||||
}
|
||||
|
||||
if( libEntry == NULL )
|
||||
if( !libEntry )
|
||||
{
|
||||
msg.Printf( _( "Component name %s not found in library %s" ),
|
||||
GetChars( CmpName ),
|
||||
GetChars( searchLib->GetName() ) );
|
||||
wxString msg = wxString::Format( _(
|
||||
"Part name '%s' not found in library '%s'" ),
|
||||
GetChars( cmp_name ),
|
||||
GetChars( searchLib->GetName() )
|
||||
);
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
EXCHG( searchLib, m_library );
|
||||
PART_LIB* old = SetCurLib( searchLib );
|
||||
|
||||
LoadComponentFromCurrentLib( libEntry );
|
||||
EXCHG( searchLib, m_library );
|
||||
|
||||
SetCurLib( old );
|
||||
|
||||
DisplayLibInfos();
|
||||
}
|
||||
|
||||
|
||||
bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLibrary )
|
||||
bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, PART_LIB* aLibrary )
|
||||
{
|
||||
wxString msg, cmpName, rootName;
|
||||
LIB_COMPONENT* component;
|
||||
wxString msg, rootName;
|
||||
|
||||
if( ( aEntry == NULL ) || ( aLibrary == NULL ) )
|
||||
if( !aEntry || !aLibrary )
|
||||
return false;
|
||||
|
||||
if( aEntry->GetName().IsEmpty() )
|
||||
|
@ -206,41 +208,28 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib
|
|||
return false;
|
||||
}
|
||||
|
||||
cmpName = m_aliasName = aEntry->GetName();
|
||||
wxString cmpName = m_aliasName = aEntry->GetName();
|
||||
|
||||
LIB_ALIAS* alias = (LIB_ALIAS*) aEntry;
|
||||
component = alias->GetComponent();
|
||||
|
||||
wxASSERT( component != NULL );
|
||||
LIB_PART* lib_part = alias->GetPart();
|
||||
|
||||
wxASSERT( lib_part );
|
||||
|
||||
wxLogDebug( wxT( "\"<%s>\" is alias of \"<%s>\"" ),
|
||||
GetChars( cmpName ),
|
||||
GetChars( component->GetName() ) );
|
||||
|
||||
if( m_component )
|
||||
{
|
||||
delete m_component;
|
||||
m_aliasName.Empty();
|
||||
}
|
||||
|
||||
m_component = new LIB_COMPONENT( *component );
|
||||
|
||||
if( m_component == NULL )
|
||||
{
|
||||
msg.Printf( _( "Could not create copy of component <%s> in library <%s>." ),
|
||||
GetChars( aEntry->GetName() ),
|
||||
GetChars( aLibrary->GetName() ) );
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
}
|
||||
GetChars( lib_part->GetName() ) );
|
||||
|
||||
LIB_PART* part = new LIB_PART( *lib_part ); // clone it and own it.
|
||||
SetCurPart( part );
|
||||
m_aliasName = aEntry->GetName();
|
||||
|
||||
m_unit = 1;
|
||||
m_convert = 1;
|
||||
|
||||
m_showDeMorgan = false;
|
||||
|
||||
if( m_component->HasConversion() )
|
||||
if( part->HasConversion() )
|
||||
m_showDeMorgan = true;
|
||||
|
||||
GetScreen()->ClrModify();
|
||||
|
@ -248,8 +237,8 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib
|
|||
UpdateAliasSelectList();
|
||||
UpdatePartSelectList();
|
||||
|
||||
/* Display the document information based on the entry selected just in
|
||||
* case the entry is an alias. */
|
||||
// Display the document information based on the entry selected just in
|
||||
// case the entry is an alias.
|
||||
DisplayCmpDoc();
|
||||
|
||||
return true;
|
||||
|
@ -258,16 +247,19 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib
|
|||
|
||||
void LIB_EDIT_FRAME::RedrawComponent( wxDC* aDC, wxPoint aOffset )
|
||||
{
|
||||
if( m_component )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( part )
|
||||
{
|
||||
// display reference like in schematic (a reference U is shown U? or U?A)
|
||||
// although it is stored without ? and part id.
|
||||
// So temporary change the reference by a schematic like reference
|
||||
LIB_FIELD* field = m_component->GetField( REFERENCE );
|
||||
wxString fieldText = field->GetText();
|
||||
wxString fieldfullText = field->GetFullText( m_unit );
|
||||
LIB_FIELD* field = part->GetField( REFERENCE );
|
||||
wxString fieldText = field->GetText();
|
||||
wxString fieldfullText = field->GetFullText( m_unit );
|
||||
|
||||
field->EDA_TEXT::SetText( fieldfullText ); // change the field text string only
|
||||
m_component->Draw( m_canvas, aDC, aOffset, m_unit, m_convert, GR_DEFAULT_DRAWMODE );
|
||||
part->Draw( m_canvas, aDC, aOffset, m_unit, m_convert, GR_DEFAULT_DRAWMODE );
|
||||
field->EDA_TEXT::SetText( fieldText ); // restore the field text string
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +309,9 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
|||
|
||||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
||||
|
||||
if( !m_library )
|
||||
PART_LIB* lib = GetCurLib();
|
||||
|
||||
if( !lib )
|
||||
{
|
||||
DisplayError( this, _( "No library specified." ) );
|
||||
return false;
|
||||
|
@ -326,20 +320,21 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
|||
if( GetScreen()->IsModify() )
|
||||
{
|
||||
if( IsOK( this, _( "Include last component changes?" ) ) )
|
||||
SaveOnePartInMemory();
|
||||
SaveOnePart( lib );
|
||||
}
|
||||
|
||||
if( newFile )
|
||||
{
|
||||
PROJECT& prj = Prj();
|
||||
SEARCH_STACK& search = prj.SchSearchS();
|
||||
SEARCH_STACK* search = prj.SchSearchS();
|
||||
|
||||
// Get a new name for the library
|
||||
wxString default_path = prj.GetRString( PROJECT::SCH_LIB_PATH );
|
||||
if( !default_path )
|
||||
default_path = search.LastVisitedPath();
|
||||
|
||||
wxFileDialog dlg( this, _( "Component Library Name:" ), default_path,
|
||||
if( !default_path )
|
||||
default_path = search->LastVisitedPath();
|
||||
|
||||
wxFileDialog dlg( this, _( "Part Library Name:" ), default_path,
|
||||
wxEmptyString, SchematicLibraryFileExtension,
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
|
@ -348,8 +343,8 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
|||
|
||||
fn = dlg.GetPath();
|
||||
|
||||
/* The GTK file chooser doesn't return the file extension added to
|
||||
* file name so add it here. */
|
||||
// The GTK file chooser doesn't return the file extension added to
|
||||
// file name so add it here.
|
||||
if( fn.GetExt().IsEmpty() )
|
||||
fn.SetExt( SchematicLibraryFileExtension );
|
||||
|
||||
|
@ -357,16 +352,17 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
|||
}
|
||||
else
|
||||
{
|
||||
fn = wxFileName( m_library->GetFullFileName() );
|
||||
fn = wxFileName( lib->GetFullFileName() );
|
||||
|
||||
msg.Printf( _( "Modify library file <%s> ?" ),
|
||||
msg.Printf( _( "Modify library file '%s' ?" ),
|
||||
GetChars( fn.GetFullPath() ) );
|
||||
|
||||
if( !IsOK( this, msg ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify the user has write privileges before attempting to save the library file.
|
||||
// Verify the user has write privileges before attempting to
|
||||
// save the library file.
|
||||
if( !IsWritable( fn ) )
|
||||
return false;
|
||||
|
||||
|
@ -379,6 +375,7 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
|||
if( libFileName.FileExists() )
|
||||
{
|
||||
backupFileName.SetExt( wxT( "bak" ) );
|
||||
|
||||
if( backupFileName.FileExists() )
|
||||
wxRemoveFile( backupFileName.GetFullPath() );
|
||||
|
||||
|
@ -395,9 +392,9 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
|||
{
|
||||
FILE_OUTPUTFORMATTER libFormatter( libFileName.GetFullPath() );
|
||||
|
||||
if( !m_library->Save( libFormatter ) )
|
||||
if( !lib->Save( libFormatter ) )
|
||||
{
|
||||
msg.Printf( _( "Error occurred while saving library file <%s>" ),
|
||||
msg.Printf( _( "Error occurred while saving library file '%s'" ),
|
||||
GetChars( fn.GetFullPath() ) );
|
||||
AppendMsgPanel( _( "*** ERROR: ***" ), msg, RED );
|
||||
DisplayError( this, msg );
|
||||
|
@ -407,7 +404,7 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
|||
catch( ... /* IO_ERROR ioe */ )
|
||||
{
|
||||
libFileName.MakeAbsolute();
|
||||
msg.Printf( _( "Failed to create component library file <%s>" ),
|
||||
msg.Printf( _( "Failed to create component library file '%s'" ),
|
||||
GetChars( libFileName.GetFullPath() ) );
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
|
@ -437,7 +434,7 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
|||
{
|
||||
FILE_OUTPUTFORMATTER docFormatter( docFileName.GetFullPath() );
|
||||
|
||||
if( !m_library->SaveDocs( docFormatter ) )
|
||||
if( !lib->SaveDocs( docFormatter ) )
|
||||
{
|
||||
msg.Printf( _( "Error occurred while saving library documentation file <%s>" ),
|
||||
GetChars( docFileName.GetFullPath() ) );
|
||||
|
@ -455,10 +452,10 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
|||
return false;
|
||||
}
|
||||
|
||||
msg.Printf( _( "Library file <%s> OK" ), GetChars( fn.GetFullName() ) );
|
||||
msg.Printf( _( "Library file '%s' OK" ), GetChars( fn.GetFullName() ) );
|
||||
fn.SetExt( DOC_EXT );
|
||||
wxString msg1;
|
||||
msg1.Printf( _( "Documentation file <%s> OK" ), GetChars( fn.GetFullPath() ) );
|
||||
msg1.Printf( _( "Documentation file '%s' OK" ), GetChars( fn.GetFullPath() ) );
|
||||
AppendMsgPanel( msg, msg1, BLUE );
|
||||
|
||||
return true;
|
||||
|
@ -467,24 +464,25 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
|||
|
||||
void LIB_EDIT_FRAME::DisplayCmpDoc()
|
||||
{
|
||||
wxString msg;
|
||||
LIB_ALIAS* alias;
|
||||
LIB_ALIAS* alias;
|
||||
PART_LIB* lib = GetCurLib();
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
ClearMsgPanel();
|
||||
|
||||
if( m_library == NULL || m_component == NULL )
|
||||
if( !lib || !part )
|
||||
return;
|
||||
|
||||
msg = m_component->GetName();
|
||||
wxString msg = part->GetName();
|
||||
|
||||
AppendMsgPanel( _( "Name" ), msg, BLUE, 8 );
|
||||
|
||||
if( m_aliasName == m_component->GetName() )
|
||||
if( m_aliasName == part->GetName() )
|
||||
msg = _( "None" );
|
||||
else
|
||||
msg = m_aliasName;
|
||||
|
||||
alias = m_component->GetAlias( m_aliasName );
|
||||
alias = part->GetAlias( m_aliasName );
|
||||
|
||||
wxCHECK_RET( alias != NULL, wxT( "Alias not found in component." ) );
|
||||
|
||||
|
@ -502,10 +500,10 @@ void LIB_EDIT_FRAME::DisplayCmpDoc()
|
|||
|
||||
AppendMsgPanel( _( "Body" ), msg, GREEN, 8 );
|
||||
|
||||
if( m_component->IsPower() )
|
||||
if( part->IsPower() )
|
||||
msg = _( "Power Symbol" );
|
||||
else
|
||||
msg = _( "Component" );
|
||||
msg = _( "Part" );
|
||||
|
||||
AppendMsgPanel( _( "Type" ), msg, MAGENTA, 8 );
|
||||
AppendMsgPanel( _( "Description" ), alias->GetDescription(), CYAN, 8 );
|
||||
|
@ -516,9 +514,9 @@ void LIB_EDIT_FRAME::DisplayCmpDoc()
|
|||
|
||||
void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
|
||||
{
|
||||
wxString CmpName;
|
||||
LIB_ALIAS* LibEntry;
|
||||
wxArrayString ListNames;
|
||||
wxString cmp_name;
|
||||
LIB_ALIAS* libEntry;
|
||||
wxArrayString nameList;
|
||||
wxString msg;
|
||||
|
||||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
||||
|
@ -526,79 +524,84 @@ void LIB_EDIT_FRAME::DeleteOnePart( wxCommandEvent& event )
|
|||
m_lastDrawItem = NULL;
|
||||
m_drawItem = NULL;
|
||||
|
||||
if( m_library == NULL )
|
||||
PART_LIB* lib = GetCurLib();
|
||||
|
||||
if( !lib )
|
||||
{
|
||||
SelectActiveLibrary();
|
||||
|
||||
if( m_library == NULL )
|
||||
lib = GetCurLib();
|
||||
if( !lib )
|
||||
{
|
||||
DisplayError( this, _( "Please select a component library." ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_library->GetEntryNames( ListNames );
|
||||
lib->GetEntryNames( nameList );
|
||||
|
||||
if( ListNames.IsEmpty() )
|
||||
if( nameList.IsEmpty() )
|
||||
{
|
||||
msg.Printf( _( "Component library <%s> is empty." ), GetChars( m_library->GetName() ) );
|
||||
msg.Printf( _( "Part library '%s' is empty." ), GetChars( lib->GetName() ) );
|
||||
wxMessageBox( msg, _( "Delete Entry Error" ), wxID_OK | wxICON_EXCLAMATION, this );
|
||||
return;
|
||||
}
|
||||
|
||||
msg.Printf( _( "Select 1 of %d components to delete\nfrom library <%s>." ),
|
||||
ListNames.GetCount(),
|
||||
GetChars( m_library->GetName() ) );
|
||||
msg.Printf( _( "Select 1 of %d components to delete\nfrom library '%s'." ),
|
||||
nameList.GetCount(),
|
||||
GetChars( lib->GetName() ) );
|
||||
|
||||
wxSingleChoiceDialog dlg( this, msg, _( "Delete Component" ), ListNames );
|
||||
wxSingleChoiceDialog dlg( this, msg, _( "Delete Part" ), nameList );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() )
|
||||
return;
|
||||
|
||||
LibEntry = m_library->FindEntry( dlg.GetStringSelection() );
|
||||
libEntry = lib->FindEntry( dlg.GetStringSelection() );
|
||||
|
||||
if( LibEntry == NULL )
|
||||
if( !libEntry )
|
||||
{
|
||||
msg.Printf( _( "Entry <%s> not found in library <%s>." ),
|
||||
msg.Printf( _( "Entry '%s' not found in library '%s'." ),
|
||||
GetChars( dlg.GetStringSelection() ),
|
||||
GetChars( m_library->GetName() ) );
|
||||
GetChars( lib->GetName() ) );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
msg.Printf( _( "Delete component %s from library %s?" ),
|
||||
GetChars( LibEntry->GetName() ),
|
||||
GetChars( m_library->GetName() ) );
|
||||
msg.Printf( _( "Delete component '%s' from library '%s' ?" ),
|
||||
GetChars( libEntry->GetName() ),
|
||||
GetChars( lib->GetName() ) );
|
||||
|
||||
if( !IsOK( this, msg ) )
|
||||
return;
|
||||
|
||||
if( m_component == NULL || !m_component->HasAlias( LibEntry->GetName() ) )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part || !part->HasAlias( libEntry->GetName() ) )
|
||||
{
|
||||
m_library->RemoveEntry( LibEntry );
|
||||
lib->RemoveEntry( libEntry );
|
||||
return;
|
||||
}
|
||||
|
||||
/* If deleting the current entry or removing one of the aliases for
|
||||
* the current entry, sync the changes in the current entry as well.
|
||||
*/
|
||||
// If deleting the current entry or removing one of the aliases for
|
||||
// the current entry, sync the changes in the current entry as well.
|
||||
|
||||
if( GetScreen()->IsModify()
|
||||
&& !IsOK( this, _( "The component being deleted has been modified. \
|
||||
All changes will be lost. Discard changes?" ) ) )
|
||||
if( GetScreen()->IsModify() && !IsOK( this, _(
|
||||
"The component being deleted has been modified."
|
||||
" All changes will be lost. Discard changes?" ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LIB_ALIAS* nextEntry = m_library->RemoveEntry( LibEntry );
|
||||
LIB_ALIAS* nextEntry = lib->RemoveEntry( libEntry );
|
||||
|
||||
if( nextEntry != NULL )
|
||||
{
|
||||
if( LoadOneLibraryPartAux( nextEntry, m_library ) )
|
||||
if( LoadOneLibraryPartAux( nextEntry, lib ) )
|
||||
Zoom_Automatique( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
delete m_component;
|
||||
m_component = NULL;
|
||||
SetCurPart( NULL ); // delete CurPart
|
||||
m_aliasName.Empty();
|
||||
}
|
||||
|
||||
|
@ -611,16 +614,19 @@ void LIB_EDIT_FRAME::CreateNewLibraryPart( wxCommandEvent& event )
|
|||
{
|
||||
wxString name;
|
||||
|
||||
if( m_component && GetScreen()->IsModify()
|
||||
&& !IsOK( this, _( "All changes to the current component will be \
|
||||
lost!\n\nClear the current component from the screen?" ) ) )
|
||||
if( GetCurPart() && GetScreen()->IsModify() && !IsOK( this, _(
|
||||
"All changes to the current component will be lost!\n\n"
|
||||
"Clear the current component from the screen?" ) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
||||
|
||||
m_drawItem = NULL;
|
||||
|
||||
DIALOG_LIB_NEW_COMPONENT dlg( this );
|
||||
|
||||
dlg.SetMinSize( dlg.GetSize() );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
|
@ -639,101 +645,86 @@ lost!\n\nClear the current component from the screen?" ) ) )
|
|||
#endif
|
||||
name.Replace( wxT( " " ), wxT( "_" ) );
|
||||
|
||||
/* Test if there a component with this name already. */
|
||||
if( m_library && m_library->FindEntry( name ) )
|
||||
PART_LIB* lib = GetCurLib();
|
||||
|
||||
// Test if there a component with this name already.
|
||||
if( lib && lib->FindEntry( name ) )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Component %s already exists in library %s" ),
|
||||
GetChars( name ),
|
||||
GetChars( m_library->GetName() ) );
|
||||
wxString msg = wxString::Format( _(
|
||||
"Part '%s' already exists in library '%s'" ),
|
||||
GetChars( name ),
|
||||
GetChars( lib->GetName() )
|
||||
);
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
}
|
||||
|
||||
LIB_COMPONENT* component = new LIB_COMPONENT( name );
|
||||
component->GetReferenceField().SetText( dlg.GetReference() );
|
||||
component->SetPartCount( dlg.GetPartCount() );
|
||||
LIB_PART* new_part = new LIB_PART( name );
|
||||
|
||||
// Initialize component->m_TextInside member:
|
||||
SetCurPart( new_part );
|
||||
m_aliasName = new_part->GetName();
|
||||
|
||||
new_part->GetReferenceField().SetText( dlg.GetReference() );
|
||||
new_part->SetUnitCount( dlg.GetUnitCount() );
|
||||
|
||||
// Initialize new_part->m_TextInside member:
|
||||
// if 0, pin text is outside the body (on the pin)
|
||||
// if > 0, pin text is inside the body
|
||||
component->SetConversion( dlg.GetAlternateBodyStyle() );
|
||||
new_part->SetConversion( dlg.GetAlternateBodyStyle() );
|
||||
SetShowDeMorgan( dlg.GetAlternateBodyStyle() );
|
||||
|
||||
if( dlg.GetPinNameInside() )
|
||||
{
|
||||
component->SetPinNameOffset( dlg.GetPinTextPosition() );
|
||||
new_part->SetPinNameOffset( dlg.GetPinTextPosition() );
|
||||
|
||||
if( component->GetPinNameOffset() == 0 )
|
||||
component->SetPinNameOffset( 1 );
|
||||
if( new_part->GetPinNameOffset() == 0 )
|
||||
new_part->SetPinNameOffset( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
component->SetPinNameOffset( 0 );
|
||||
new_part->SetPinNameOffset( 0 );
|
||||
}
|
||||
|
||||
( dlg.GetPowerSymbol() ) ? component->SetPower() : component->SetNormal();
|
||||
component->SetShowPinNumbers( dlg.GetShowPinNumber() );
|
||||
component->SetShowPinNames( dlg.GetShowPinName() );
|
||||
component->LockUnits( dlg.GetLockItems() );
|
||||
( dlg.GetPowerSymbol() ) ? new_part->SetPower() : new_part->SetNormal();
|
||||
new_part->SetShowPinNumbers( dlg.GetShowPinNumber() );
|
||||
new_part->SetShowPinNames( dlg.GetShowPinName() );
|
||||
new_part->LockUnits( dlg.GetLockItems() );
|
||||
|
||||
if( dlg.GetPartCount() < 2 )
|
||||
component->LockUnits( false );
|
||||
if( dlg.GetUnitCount() < 2 )
|
||||
new_part->LockUnits( false );
|
||||
|
||||
m_aliasName = component->GetName();
|
||||
|
||||
if( m_component )
|
||||
{
|
||||
delete m_component;
|
||||
m_aliasName.Empty();
|
||||
}
|
||||
|
||||
m_component = component;
|
||||
m_aliasName = m_component->GetName();
|
||||
m_unit = 1;
|
||||
m_convert = 1;
|
||||
|
||||
DisplayLibInfos();
|
||||
DisplayCmpDoc();
|
||||
UpdateAliasSelectList();
|
||||
UpdatePartSelectList();
|
||||
m_editPinsPerPartOrConvert = m_component->UnitsLocked() ? true : false;
|
||||
|
||||
m_editPinsPerPartOrConvert = new_part->UnitsLocked() ? true : false;
|
||||
m_lastDrawItem = NULL;
|
||||
|
||||
GetScreen()->ClearUndoRedoList();
|
||||
OnModify();
|
||||
|
||||
m_canvas->Refresh();
|
||||
m_mainToolBar->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::SaveOnePartInMemory()
|
||||
void LIB_EDIT_FRAME::SaveOnePart( PART_LIB* aLib )
|
||||
{
|
||||
LIB_COMPONENT* oldComponent;
|
||||
LIB_COMPONENT* component;
|
||||
wxString msg;
|
||||
|
||||
if( m_component == NULL )
|
||||
{
|
||||
DisplayError( this, _( "No component to save." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_library == NULL )
|
||||
SelectActiveLibrary();
|
||||
|
||||
if( m_library == NULL )
|
||||
{
|
||||
DisplayError( this, _( "No library specified." ) );
|
||||
return;
|
||||
}
|
||||
wxString msg;
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
GetScreen()->ClrModify();
|
||||
|
||||
oldComponent = m_library->FindComponent( m_component->GetName() );
|
||||
LIB_PART* old_part = aLib->FindPart( part->GetName() );
|
||||
|
||||
if( oldComponent != NULL )
|
||||
if( old_part )
|
||||
{
|
||||
msg.Printf( _( "Component %s already exists. Change it?" ),
|
||||
GetChars( m_component->GetName() ) );
|
||||
msg.Printf( _( "Part '%s' already exists. Change it?" ),
|
||||
GetChars( part->GetName() ) );
|
||||
|
||||
if( !IsOK( this, msg ) )
|
||||
return;
|
||||
|
@ -741,16 +732,14 @@ void LIB_EDIT_FRAME::SaveOnePartInMemory()
|
|||
|
||||
m_drawItem = m_lastDrawItem = NULL;
|
||||
|
||||
if( oldComponent != NULL )
|
||||
component = m_library->ReplaceComponent( oldComponent, m_component );
|
||||
if( old_part )
|
||||
aLib->ReplacePart( old_part, part );
|
||||
else
|
||||
component = m_library->AddComponent( m_component );
|
||||
aLib->AddPart( part );
|
||||
|
||||
if( component == NULL )
|
||||
return;
|
||||
msg.Printf( _( "Part '%s' saved in library '%s'" ),
|
||||
GetChars( part->GetName() ),
|
||||
GetChars( aLib->GetName() ) );
|
||||
|
||||
msg.Printf( _( "Component %s saved in library %s" ),
|
||||
GetChars( component->GetName() ),
|
||||
GetChars( m_library->GetName() ) );
|
||||
SetStatusText( msg );
|
||||
}
|
||||
|
|
|
@ -40,11 +40,13 @@
|
|||
|
||||
void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
|
||||
{
|
||||
LIB_ITEM* item = m_drawItem;
|
||||
bool item_in_edit = item && item->InEditMode();
|
||||
bool no_item_edited = !item_in_edit;
|
||||
LIB_ITEM* item = m_drawItem;
|
||||
bool item_in_edit = item && item->InEditMode();
|
||||
bool no_item_edited = !item_in_edit;
|
||||
|
||||
if( m_component == NULL ) // No component loaded !
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part ) // No component loaded !
|
||||
return;
|
||||
|
||||
if( ( GetToolId() == ID_NO_TOOL_SELECTED ) && no_item_edited )
|
||||
|
@ -98,7 +100,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
|
|||
case ID_LIBEDIT_BODY_RECT_BUTT:
|
||||
case ID_LIBEDIT_BODY_TEXT_BUTT:
|
||||
if( no_item_edited )
|
||||
m_drawItem = CreateGraphicItem( m_component, DC );
|
||||
m_drawItem = CreateGraphicItem( part, DC );
|
||||
else if( m_drawItem )
|
||||
{
|
||||
if( m_drawItem->IsNew() )
|
||||
|
@ -119,7 +121,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
|
|||
break;
|
||||
|
||||
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
|
||||
SaveCopyInUndoList( m_component );
|
||||
SaveCopyInUndoList( part );
|
||||
PlaceAnchor();
|
||||
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
||||
break;
|
||||
|
@ -139,16 +141,19 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
|
|||
*/
|
||||
void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
|
||||
{
|
||||
if( m_component == NULL )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
||||
if( ( m_drawItem == NULL ) || !m_drawItem->InEditMode() )
|
||||
if( !m_drawItem || !m_drawItem->InEditMode() )
|
||||
{ // We can locate an item
|
||||
m_drawItem = LocateItemUsingCursor( aPosition );
|
||||
|
||||
if( m_drawItem == NULL )
|
||||
{
|
||||
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
||||
|
||||
cmd.SetId( ID_LIBEDIT_GET_FRAME_EDIT_PART );
|
||||
GetEventHandler()->ProcessEvent( cmd );
|
||||
}
|
||||
|
@ -160,7 +165,7 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
|
|||
return;
|
||||
|
||||
m_canvas->SetIgnoreMouseEvents( true );
|
||||
bool not_edited = ! m_drawItem->InEditMode();
|
||||
bool not_edited = !m_drawItem->InEditMode();
|
||||
|
||||
switch( m_drawItem->Type() )
|
||||
{
|
||||
|
@ -168,6 +173,7 @@ void LIB_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
|
|||
if( not_edited )
|
||||
{
|
||||
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
||||
|
||||
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
|
||||
GetEventHandler()->ProcessEvent( cmd );
|
||||
}
|
||||
|
|
|
@ -49,17 +49,19 @@ static void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame
|
|||
|
||||
bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
||||
{
|
||||
LIB_ITEM* item = GetDrawItem();
|
||||
bool BlockActive = GetScreen()->IsBlockActive();
|
||||
LIB_ITEM* item = GetDrawItem();
|
||||
bool blockActive = GetScreen()->IsBlockActive();
|
||||
|
||||
if( BlockActive )
|
||||
if( blockActive )
|
||||
{
|
||||
AddMenusForBlock( PopMenu, this );
|
||||
PopMenu->AppendSeparator();
|
||||
return true;
|
||||
}
|
||||
|
||||
if( m_component == NULL )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
return true;
|
||||
|
||||
// If Command in progress, put menu "cancel"
|
||||
|
|
|
@ -46,12 +46,13 @@
|
|||
|
||||
void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
|
||||
{
|
||||
LIB_COMPONENT* cmp = GetComponent();
|
||||
wxString FullFileName;
|
||||
wxString fullFileName;
|
||||
wxString file_ext;
|
||||
wxString mask;
|
||||
|
||||
if( cmp == NULL )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
{
|
||||
wxMessageBox( _( "No component" ) );
|
||||
return;
|
||||
|
@ -65,20 +66,22 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
|
|||
|
||||
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
|
||||
mask = wxT( "*." ) + file_ext;
|
||||
wxFileName fn( cmp->GetName() );
|
||||
wxFileName fn( part->GetName() );
|
||||
fn.SetExt( file_ext );
|
||||
|
||||
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
|
||||
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
|
||||
|
||||
fullFileName = EDA_FileSelector( _( "Filename:" ), pro_dir,
|
||||
fn.GetFullName(), file_ext, mask, this,
|
||||
wxFD_SAVE, true );
|
||||
|
||||
if( FullFileName.IsEmpty() )
|
||||
if( fullFileName.IsEmpty() )
|
||||
return;
|
||||
|
||||
// calling wxYield is mandatory under Linux, after closing the file selector dialog
|
||||
// to refresh the screen before creating the PNG or JPEG image from screen
|
||||
wxYield();
|
||||
CreatePNGorJPEGFile( FullFileName, fmt_is_jpeg );
|
||||
CreatePNGorJPEGFile( fullFileName, fmt_is_jpeg );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -86,26 +89,29 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
|
|||
{
|
||||
file_ext = wxT( "svg" );
|
||||
mask = wxT( "*." ) + file_ext;
|
||||
wxFileName fn( cmp->GetName() );
|
||||
wxFileName fn( part->GetName() );
|
||||
fn.SetExt( file_ext );
|
||||
FullFileName = EDA_FileSelector( _( "Filename:" ), wxGetCwd(),
|
||||
|
||||
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
|
||||
|
||||
fullFileName = EDA_FileSelector( _( "Filename:" ), pro_dir,
|
||||
fn.GetFullName(), file_ext, mask, this,
|
||||
wxFD_SAVE, true );
|
||||
|
||||
if( FullFileName.IsEmpty() )
|
||||
if( fullFileName.IsEmpty() )
|
||||
return;
|
||||
|
||||
PAGE_INFO pageSave = GetScreen()->GetPageSettings();
|
||||
PAGE_INFO pageTemp = pageSave;
|
||||
|
||||
wxSize componentSize = m_component->GetBoundingBox( m_unit, m_convert ).GetSize();
|
||||
wxSize componentSize = part->GetBoundingBox( m_unit, m_convert ).GetSize();
|
||||
|
||||
// Add a small margin to the plot bounding box
|
||||
pageTemp.SetWidthMils( int( componentSize.x * 1.2 ) );
|
||||
pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) );
|
||||
|
||||
GetScreen()->SetPageSettings( pageTemp );
|
||||
SVG_PlotComponent( FullFileName );
|
||||
SVG_PlotComponent( fullFileName );
|
||||
GetScreen()->SetPageSettings( pageSave );
|
||||
}
|
||||
break;
|
||||
|
@ -165,18 +171,20 @@ void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName )
|
|||
|
||||
plotter->StartPlot();
|
||||
|
||||
if( m_component )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( part )
|
||||
{
|
||||
TRANSFORM temp; // Uses default transform
|
||||
wxPoint plotPos;
|
||||
TRANSFORM temp; // Uses default transform
|
||||
wxPoint plotPos;
|
||||
|
||||
plotPos.x = pageInfo.GetWidthIU() /2;
|
||||
plotPos.y = pageInfo.GetHeightIU()/2;
|
||||
|
||||
m_component->Plot( plotter, GetUnit(), GetConvert(), plotPos, temp );
|
||||
part->Plot( plotter, GetUnit(), GetConvert(), plotPos, temp );
|
||||
|
||||
// Plot lib fields, not plotted by m_component->Plot():
|
||||
m_component->PlotLibFields( plotter, GetUnit(), GetConvert(),
|
||||
plotPos, temp );
|
||||
part->PlotLibFields( plotter, GetUnit(), GetConvert(), plotPos, temp );
|
||||
}
|
||||
|
||||
plotter->EndPlot();
|
||||
|
@ -185,7 +193,9 @@ void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName )
|
|||
|
||||
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData)
|
||||
{
|
||||
if( ! m_component )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
||||
wxSize pagesize = GetScreen()->GetPageSettings().GetSizeIU();
|
||||
|
@ -198,7 +208,7 @@ void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMod
|
|||
plot_offset.x = pagesize.x/2;
|
||||
plot_offset.y = pagesize.y/2;
|
||||
|
||||
m_component->Draw( m_canvas, aDC, plot_offset, m_unit, m_convert, GR_DEFAULT_DRAWMODE );
|
||||
part->Draw( m_canvas, aDC, plot_offset, m_unit, m_convert, GR_DEFAULT_DRAWMODE );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
|
||||
void LIB_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* ItemToCopy, int unused_flag )
|
||||
{
|
||||
LIB_COMPONENT* CopyItem;
|
||||
LIB_PART* CopyItem;
|
||||
PICKED_ITEMS_LIST* lastcmd;
|
||||
|
||||
CopyItem = new LIB_COMPONENT( *( (LIB_COMPONENT*) ItemToCopy ) );
|
||||
CopyItem = new LIB_PART( * (LIB_PART*) ItemToCopy );
|
||||
|
||||
// Clear current flags (which can be temporary set by a current edit command).
|
||||
CopyItem->ClearStatus();
|
||||
|
@ -31,35 +31,38 @@ void LIB_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* ItemToCopy, int unused_flag )
|
|||
}
|
||||
|
||||
|
||||
/* Redo the last edition:
|
||||
* - Place the current edited library component in undo list
|
||||
* - Get old version of the current edited library component
|
||||
*/
|
||||
void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
|
||||
{
|
||||
if ( GetScreen()->GetRedoCommandCount() <= 0 )
|
||||
if( GetScreen()->GetRedoCommandCount() <= 0 )
|
||||
return;
|
||||
|
||||
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
|
||||
ITEM_PICKER wrapper( m_component, UR_LIBEDIT );
|
||||
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
ITEM_PICKER wrapper( part, UR_LIBEDIT );
|
||||
|
||||
lastcmd->PushItem( wrapper );
|
||||
GetScreen()->PushCommandToUndoList( lastcmd );
|
||||
|
||||
lastcmd = GetScreen()->PopCommandFromRedoList();
|
||||
|
||||
wrapper = lastcmd->PopItem();
|
||||
m_component = (LIB_COMPONENT*) wrapper.GetItem();
|
||||
|
||||
if( m_component == NULL )
|
||||
part = (LIB_PART*) wrapper.GetItem();
|
||||
|
||||
SetCurPart( part );
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
||||
if( !m_aliasName.IsEmpty() && !m_component->HasAlias( m_aliasName ) )
|
||||
m_aliasName = m_component->GetName();
|
||||
if( !m_aliasName.IsEmpty() && !part->HasAlias( m_aliasName ) )
|
||||
m_aliasName = part->GetName();
|
||||
|
||||
m_drawItem = NULL;
|
||||
UpdateAliasSelectList();
|
||||
UpdatePartSelectList();
|
||||
SetShowDeMorgan( m_component->HasConversion() );
|
||||
SetShowDeMorgan( part->HasConversion() );
|
||||
DisplayLibInfos();
|
||||
DisplayCmpDoc();
|
||||
OnModify();
|
||||
|
@ -67,35 +70,38 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
/** Undo the last edition:
|
||||
* - Place the current edited library component in Redo list
|
||||
* - Get old version of the current edited library component
|
||||
*/
|
||||
void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
|
||||
{
|
||||
if ( GetScreen()->GetUndoCommandCount() <= 0 )
|
||||
if( GetScreen()->GetUndoCommandCount() <= 0 )
|
||||
return;
|
||||
|
||||
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
|
||||
ITEM_PICKER wrapper( m_component, UR_LIBEDIT );
|
||||
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
ITEM_PICKER wrapper( part, UR_LIBEDIT );
|
||||
|
||||
lastcmd->PushItem( wrapper );
|
||||
GetScreen()->PushCommandToRedoList( lastcmd );
|
||||
|
||||
lastcmd = GetScreen()->PopCommandFromUndoList();
|
||||
|
||||
wrapper = lastcmd->PopItem();
|
||||
m_component = (LIB_COMPONENT*) wrapper.GetItem();
|
||||
|
||||
if( m_component == NULL )
|
||||
part = (LIB_PART* ) wrapper.GetItem();
|
||||
|
||||
SetCurPart( part );
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
||||
if( !m_aliasName.IsEmpty() && !m_component->HasAlias( m_aliasName ) )
|
||||
m_aliasName = m_component->GetName();
|
||||
if( !m_aliasName.IsEmpty() && !part->HasAlias( m_aliasName ) )
|
||||
m_aliasName = part->GetName();
|
||||
|
||||
m_drawItem = NULL;
|
||||
UpdateAliasSelectList();
|
||||
UpdatePartSelectList();
|
||||
SetShowDeMorgan( m_component->HasConversion() );
|
||||
SetShowDeMorgan( part->HasConversion() );
|
||||
DisplayLibInfos();
|
||||
DisplayCmpDoc();
|
||||
OnModify();
|
||||
|
|
|
@ -72,15 +72,6 @@ int ImportPartId = ::wxNewId();
|
|||
int CreateNewLibAndSavePartId = ::wxNewId();
|
||||
|
||||
|
||||
/*
|
||||
* Static component library editor members. These are static so their
|
||||
* state is saved between editing sessions. This way the last component
|
||||
* that was being edited will be displayed. These members are protected
|
||||
* making it necessary to use the class access methods.
|
||||
*/
|
||||
LIB_COMPONENT* LIB_EDIT_FRAME::m_component = NULL;
|
||||
CMP_LIBRARY* LIB_EDIT_FRAME:: m_library = NULL;
|
||||
|
||||
wxString LIB_EDIT_FRAME:: m_aliasName;
|
||||
int LIB_EDIT_FRAME:: m_unit = 1;
|
||||
int LIB_EDIT_FRAME:: m_convert = 1;
|
||||
|
@ -189,7 +180,9 @@ END_EVENT_TABLE()
|
|||
|
||||
LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ),
|
||||
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GetLibEditFrameName() )
|
||||
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GetLibEditFrameName() ),
|
||||
m_my_part( 0 ),
|
||||
m_tempCopyComponent( 0 )
|
||||
{
|
||||
wxASSERT( aParent );
|
||||
|
||||
|
@ -199,7 +192,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
SetShowDeMorgan( false );
|
||||
m_drawSpecificConvert = true;
|
||||
m_drawSpecificUnit = false;
|
||||
m_tempCopyComponent = NULL;
|
||||
m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr;
|
||||
m_editPinsPerPartOrConvert = false;
|
||||
|
||||
|
@ -214,7 +206,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
icon.CopyFromBitmap( KiBitmap( libedit_icon_xpm ) );
|
||||
SetIcon( icon );
|
||||
|
||||
SetScreen( new SCH_SCREEN() );
|
||||
SetScreen( new SCH_SCREEN( aKiway ) );
|
||||
GetScreen()->m_Center = true;
|
||||
|
||||
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
||||
|
@ -235,7 +227,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
if( m_canvas )
|
||||
m_canvas->SetEnableBlockCommands( true );
|
||||
|
||||
EnsureActiveLibExists();
|
||||
ReCreateMenuBar();
|
||||
ReCreateHToolbar();
|
||||
ReCreateVToolbar();
|
||||
|
@ -284,10 +275,8 @@ LIB_EDIT_FRAME::~LIB_EDIT_FRAME()
|
|||
{
|
||||
m_drawItem = m_lastDrawItem = NULL;
|
||||
|
||||
if ( m_tempCopyComponent )
|
||||
delete m_tempCopyComponent;
|
||||
|
||||
m_tempCopyComponent = NULL;
|
||||
delete m_tempCopyComponent;
|
||||
delete m_my_part;
|
||||
}
|
||||
|
||||
const wxChar* LIB_EDIT_FRAME::GetLibEditFrameName()
|
||||
|
@ -299,16 +288,6 @@ static const wxChar drawBgColorKey[] = wxT( "LibeditBgColor" );
|
|||
|
||||
void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
||||
{
|
||||
#if 0 // original
|
||||
|
||||
wxConfigBase* cfg;
|
||||
|
||||
EDA_DRAW_FRAME::LoadSettings();
|
||||
|
||||
wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath );
|
||||
cfg = Pgm().GetSettings();
|
||||
#else
|
||||
|
||||
EDA_DRAW_FRAME::LoadSettings( aCfg );
|
||||
|
||||
wxConfigPathChanger cpc( aCfg, m_configPath );
|
||||
|
@ -316,13 +295,13 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|||
EDA_COLOR_T itmp = ColorByName( aCfg->Read( drawBgColorKey, wxT("WHITE") ) );
|
||||
SetDrawBgColor( itmp );
|
||||
|
||||
m_lastLibExportPath = aCfg->Read( lastLibExportPathEntry, ::wxGetCwd() );
|
||||
m_lastLibImportPath = aCfg->Read( lastLibImportPathEntry, ::wxGetCwd() );
|
||||
wxString pro_dir = Prj().GetProjectFullName();
|
||||
|
||||
#endif
|
||||
m_lastLibExportPath = aCfg->Read( lastLibExportPathEntry, pro_dir );
|
||||
m_lastLibImportPath = aCfg->Read( lastLibImportPathEntry, pro_dir );
|
||||
|
||||
m_lastLibExportPath = aCfg->Read( lastLibExportPathEntry, ::wxGetCwd() );
|
||||
m_lastLibImportPath = aCfg->Read( lastLibImportPathEntry, ::wxGetCwd() );
|
||||
m_lastLibExportPath = aCfg->Read( lastLibExportPathEntry, pro_dir );
|
||||
m_lastLibImportPath = aCfg->Read( lastLibImportPathEntry, pro_dir );
|
||||
}
|
||||
|
||||
|
||||
|
@ -332,7 +311,6 @@ void LIB_EDIT_FRAME::SetDrawItem( LIB_ITEM* drawItem )
|
|||
}
|
||||
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
|
||||
{
|
||||
EDA_DRAW_FRAME::SaveSettings( aCfg );
|
||||
|
@ -369,13 +347,16 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
GetScreen()->ClrModify();
|
||||
}
|
||||
|
||||
BOOST_FOREACH( const CMP_LIBRARY &lib, CMP_LIBRARY::GetLibraryList() )
|
||||
PART_LIBS* libs = Prj().SchLibs();
|
||||
|
||||
BOOST_FOREACH( const PART_LIB& lib, *libs )
|
||||
{
|
||||
if( lib.IsModified() )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Library %s was modified!\nDiscard changes?" ),
|
||||
GetChars( lib.GetName() ) );
|
||||
wxString msg = wxString::Format( _(
|
||||
"Library '%s' was modified!\nDiscard changes?" ),
|
||||
GetChars( lib.GetName() )
|
||||
);
|
||||
|
||||
if( !IsOK( this, msg ) )
|
||||
{
|
||||
|
@ -398,14 +379,15 @@ double LIB_EDIT_FRAME::BestZoom()
|
|||
* and replace by static const int VIEWPORT_EXTENT = 10000;
|
||||
*/
|
||||
int dx, dy;
|
||||
wxSize size;
|
||||
EDA_RECT BoundaryBox;
|
||||
|
||||
if( m_component )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( part )
|
||||
{
|
||||
BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert );
|
||||
dx = BoundaryBox.GetWidth();
|
||||
dy = BoundaryBox.GetHeight();
|
||||
EDA_RECT boundingBox = part->GetBoundingBox( m_unit, m_convert );
|
||||
|
||||
dx = boundingBox.GetWidth();
|
||||
dy = boundingBox.GetHeight();
|
||||
SetScrollCenterPosition( wxPoint( 0, 0 ) );
|
||||
}
|
||||
else
|
||||
|
@ -418,7 +400,7 @@ double LIB_EDIT_FRAME::BestZoom()
|
|||
SetScrollCenterPosition( wxPoint( 0, 0 ) );
|
||||
}
|
||||
|
||||
size = m_canvas->GetClientSize();
|
||||
wxSize size = m_canvas->GetClientSize();
|
||||
|
||||
// Reserve a 10% margin around component bounding box.
|
||||
double margin_scale_factor = 0.8;
|
||||
|
@ -443,10 +425,12 @@ void LIB_EDIT_FRAME::UpdateAliasSelectList()
|
|||
|
||||
m_aliasSelectBox->Clear();
|
||||
|
||||
if( m_component == NULL )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
||||
m_aliasSelectBox->Append( m_component->GetAliasNames() );
|
||||
m_aliasSelectBox->Append( part->GetAliasNames() );
|
||||
m_aliasSelectBox->SetSelection( 0 );
|
||||
|
||||
int index = m_aliasSelectBox->FindString( m_aliasName );
|
||||
|
@ -464,17 +448,19 @@ void LIB_EDIT_FRAME::UpdatePartSelectList()
|
|||
if( m_partSelectBox->GetCount() != 0 )
|
||||
m_partSelectBox->Clear();
|
||||
|
||||
if( m_component == NULL || m_component->GetPartCount() <= 1 )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part || part->GetUnitCount() <= 1 )
|
||||
{
|
||||
m_partSelectBox->Append( wxEmptyString );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0; i < m_component->GetPartCount(); i++ )
|
||||
for( int i = 0; i < part->GetUnitCount(); i++ )
|
||||
{
|
||||
wxString sub = LIB_COMPONENT::SubReference( i+1, false );
|
||||
wxString part = wxString::Format( _( "Unit %s" ), GetChars( sub ) );
|
||||
m_partSelectBox->Append( part );
|
||||
wxString sub = LIB_PART::SubReference( i+1, false );
|
||||
wxString unit = wxString::Format( _( "Unit %s" ), GetChars( sub ) );
|
||||
m_partSelectBox->Append( unit );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,37 +470,41 @@ void LIB_EDIT_FRAME::UpdatePartSelectList()
|
|||
|
||||
void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent )
|
||||
{
|
||||
aEvent.Enable( m_component != NULL );
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( m_component != NULL && aEvent.GetEventObject() == m_drawToolBar )
|
||||
aEvent.Enable( part != NULL );
|
||||
|
||||
if( part && aEvent.GetEventObject() == m_drawToolBar )
|
||||
aEvent.Check( GetToolId() == aEvent.GetId() );
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnUpdateNotEditingPart( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( m_component == NULL );
|
||||
event.Enable( !GetCurPart() );
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnUpdateUndo( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( m_component != NULL && GetScreen() != NULL
|
||||
&& GetScreen()->GetUndoCommandCount() != 0 && !IsEditingDrawItem() );
|
||||
event.Enable( GetCurPart() && GetScreen() &&
|
||||
GetScreen()->GetUndoCommandCount() != 0 && !IsEditingDrawItem() );
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnUpdateRedo( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( m_component != NULL && GetScreen() != NULL
|
||||
&& GetScreen()->GetRedoCommandCount() != 0 && !IsEditingDrawItem() );
|
||||
event.Enable( GetCurPart() && GetScreen() &&
|
||||
GetScreen()->GetRedoCommandCount() != 0 && !IsEditingDrawItem() );
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnUpdateSaveCurrentLib( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( m_library != NULL && !m_library->IsReadOnly()
|
||||
&& ( m_library->IsModified() || GetScreen()->IsModify() ) );
|
||||
PART_LIB* lib = GetCurLib();
|
||||
|
||||
event.Enable( lib && !lib->IsReadOnly()
|
||||
&& ( lib->IsModified() || GetScreen()->IsModify() ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -522,9 +512,12 @@ void LIB_EDIT_FRAME::OnUpdateViewDoc( wxUpdateUIEvent& event )
|
|||
{
|
||||
bool enable = false;
|
||||
|
||||
if( m_component != NULL && m_library != NULL )
|
||||
PART_LIB* lib = GetCurLib();
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( part && lib )
|
||||
{
|
||||
LIB_ALIAS* alias = m_component->GetAlias( m_aliasName );
|
||||
LIB_ALIAS* alias = part->GetAlias( m_aliasName );
|
||||
|
||||
wxCHECK_RET( alias != NULL, wxT( "Alias <" ) + m_aliasName + wxT( "> not found." ) );
|
||||
|
||||
|
@ -537,8 +530,9 @@ void LIB_EDIT_FRAME::OnUpdateViewDoc( wxUpdateUIEvent& event )
|
|||
|
||||
void LIB_EDIT_FRAME::OnUpdatePinByPin( wxUpdateUIEvent& event )
|
||||
{
|
||||
event.Enable( ( m_component != NULL )
|
||||
&& ( ( m_component->GetPartCount() > 1 ) || m_showDeMorgan ) );
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
event.Enable( part && ( part->GetUnitCount() > 1 || m_showDeMorgan ) );
|
||||
|
||||
event.Check( m_editPinsPerPartOrConvert );
|
||||
}
|
||||
|
@ -549,10 +543,11 @@ void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event )
|
|||
if( m_partSelectBox == NULL )
|
||||
return;
|
||||
|
||||
/* Using the typical event.Enable() call doesn't seem to work with wxGTK
|
||||
* so use the pointer to alias combobox to directly enable or disable.
|
||||
*/
|
||||
m_partSelectBox->Enable( m_component && m_component->GetPartCount() > 1 );
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
// Using the typical event.Enable() call doesn't seem to work with wxGTK
|
||||
// so use the pointer to alias combobox to directly enable or disable.
|
||||
m_partSelectBox->Enable( part && part->GetUnitCount() > 1 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -561,7 +556,9 @@ void LIB_EDIT_FRAME::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
|
|||
if( m_mainToolBar == NULL )
|
||||
return;
|
||||
|
||||
event.Enable( GetShowDeMorgan() || ( m_component && m_component->HasConversion() ) );
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) );
|
||||
event.Check( m_convert <= 1 );
|
||||
}
|
||||
|
||||
|
@ -571,7 +568,9 @@ void LIB_EDIT_FRAME::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
|
|||
if( m_mainToolBar == NULL )
|
||||
return;
|
||||
|
||||
event.Enable( GetShowDeMorgan() || ( m_component && m_component->HasConversion() ) );
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
event.Enable( GetShowDeMorgan() || ( part && part->HasConversion() ) );
|
||||
event.Check( m_convert > 1 );
|
||||
}
|
||||
|
||||
|
@ -581,10 +580,11 @@ void LIB_EDIT_FRAME::OnUpdateSelectAlias( wxUpdateUIEvent& event )
|
|||
if( m_aliasSelectBox == NULL )
|
||||
return;
|
||||
|
||||
/* Using the typical event.Enable() call doesn't seem to work with wxGTK
|
||||
* so use the pointer to alias combobox to directly enable or disable.
|
||||
*/
|
||||
m_aliasSelectBox->Enable( m_component != NULL && m_component->GetAliasCount() > 1 );
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
// Using the typical event.Enable() call doesn't seem to work with wxGTK
|
||||
// so use the pointer to alias combobox to directly enable or disable.
|
||||
m_aliasSelectBox->Enable( part && part->GetAliasCount() > 1 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -618,11 +618,13 @@ void LIB_EDIT_FRAME::OnSelectPart( wxCommandEvent& event )
|
|||
|
||||
void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event )
|
||||
{
|
||||
if( m_component == NULL )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
||||
wxString fileName;
|
||||
LIB_ALIAS* alias = m_component->GetAlias( m_aliasName );
|
||||
LIB_ALIAS* alias = part->GetAlias( m_aliasName );
|
||||
|
||||
wxCHECK_RET( alias != NULL, wxT( "Alias not found." ) );
|
||||
|
||||
|
@ -630,7 +632,7 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event )
|
|||
|
||||
if( !fileName.IsEmpty() )
|
||||
{
|
||||
SEARCH_STACK* lib_search = &Prj().SchSearchS();
|
||||
SEARCH_STACK* lib_search = Prj().SchSearchS();
|
||||
|
||||
GetAssociatedDocument( this, fileName, lib_search );
|
||||
}
|
||||
|
@ -710,7 +712,30 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_LIBEDIT_SAVE_CURRENT_PART:
|
||||
SaveOnePartInMemory();
|
||||
{
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
{
|
||||
DisplayError( this, _( "No part to save." ) );
|
||||
break;
|
||||
}
|
||||
|
||||
PART_LIB* lib = GetCurLib();
|
||||
|
||||
if( !lib )
|
||||
SelectActiveLibrary();
|
||||
|
||||
lib = GetCurLib();
|
||||
|
||||
if( !lib )
|
||||
{
|
||||
DisplayError( this, _( "No library specified." ) );
|
||||
break;
|
||||
}
|
||||
|
||||
SaveOnePart( lib );
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_LIBEDIT_EDIT_PIN_BY_PIN:
|
||||
|
@ -821,13 +846,18 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
||||
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
|
||||
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
|
||||
if( ( m_drawItem == NULL ) || ( m_drawItem->Type() != LIB_PIN_T ) )
|
||||
break;
|
||||
{
|
||||
if( !m_drawItem || m_drawItem->Type() != LIB_PIN_T )
|
||||
break;
|
||||
|
||||
SaveCopyInUndoList( m_component );
|
||||
GlobalSetPins( (LIB_PIN*) m_drawItem, id );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
m_canvas->Refresh();
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
SaveCopyInUndoList( part );
|
||||
|
||||
GlobalSetPins( (LIB_PIN*) m_drawItem, id );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_POPUP_ZOOM_BLOCK:
|
||||
|
@ -899,49 +929,92 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
void LIB_EDIT_FRAME::OnActivate( wxActivateEvent& event )
|
||||
{
|
||||
EDA_DRAW_FRAME::OnActivate( event );
|
||||
|
||||
// Verify the existence of the current active library
|
||||
// (can be removed or changed by the schematic editor)
|
||||
EnsureActiveLibExists();
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::EnsureActiveLibExists()
|
||||
PART_LIB* LIB_EDIT_FRAME::GetCurLib()
|
||||
{
|
||||
if( m_library == NULL )
|
||||
return;
|
||||
wxString name = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_LIB );
|
||||
|
||||
bool exists = CMP_LIBRARY::LibraryExists( m_library );
|
||||
if( !!name )
|
||||
{
|
||||
PART_LIB* lib = Prj().SchLibs()->FindLibrary( name );
|
||||
|
||||
if( exists )
|
||||
return;
|
||||
if( !lib )
|
||||
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
|
||||
|
||||
return lib;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
PART_LIB* LIB_EDIT_FRAME::SetCurLib( PART_LIB* aLib )
|
||||
{
|
||||
PART_LIB* old = GetCurLib();
|
||||
|
||||
if( !aLib || !aLib->GetName() )
|
||||
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, wxEmptyString );
|
||||
else
|
||||
m_library = NULL;
|
||||
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_LIB, aLib->GetName() );
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
LIB_PART* LIB_EDIT_FRAME::GetCurPart()
|
||||
{
|
||||
if( !m_my_part )
|
||||
{
|
||||
wxString name = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_PART );
|
||||
LIB_PART* part;
|
||||
|
||||
if( !!name && ( part = Prj().SchLibs()->FindLibPart( name ) ) )
|
||||
{
|
||||
// clone it from the PART_LIB and own it.
|
||||
m_my_part = new LIB_PART( *part );
|
||||
}
|
||||
else
|
||||
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_PART, wxEmptyString );
|
||||
}
|
||||
|
||||
return m_my_part;
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart )
|
||||
{
|
||||
delete m_my_part;
|
||||
m_my_part = aPart; // take ownership here
|
||||
|
||||
// retain in case this wxFrame is re-opened later on the same PROJECT
|
||||
Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_PART,
|
||||
aPart ? aPart->GetName() : wxString() );
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::TempCopyComponent()
|
||||
{
|
||||
if( m_tempCopyComponent )
|
||||
delete m_tempCopyComponent;
|
||||
delete m_tempCopyComponent;
|
||||
|
||||
m_tempCopyComponent = NULL;
|
||||
|
||||
if( m_component )
|
||||
m_tempCopyComponent = new LIB_COMPONENT( *m_component );
|
||||
if( LIB_PART* part = GetCurPart() )
|
||||
// clone it and own the clone.
|
||||
m_tempCopyComponent = new LIB_PART( *part );
|
||||
else
|
||||
// clear it, there was no CurPart
|
||||
m_tempCopyComponent = NULL;
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::RestoreComponent()
|
||||
{
|
||||
if( m_tempCopyComponent == NULL )
|
||||
return;
|
||||
|
||||
if( m_component )
|
||||
delete m_component;
|
||||
|
||||
m_component = m_tempCopyComponent;
|
||||
m_tempCopyComponent = NULL;
|
||||
if( m_tempCopyComponent )
|
||||
{
|
||||
// transfer ownership to CurPart
|
||||
SetCurPart( m_tempCopyComponent );
|
||||
m_tempCopyComponent = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -952,7 +1025,6 @@ void LIB_EDIT_FRAME::ClearTempCopyComponent()
|
|||
}
|
||||
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem )
|
||||
{
|
||||
if ( ( DrawItem == NULL ) || ( DrawItem->Type() != LIB_TEXT_T ) )
|
||||
|
@ -977,18 +1049,18 @@ void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem )
|
|||
|
||||
void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
|
||||
{
|
||||
bool partLocked = GetComponent()->UnitsLocked();
|
||||
bool partLocked = GetCurPart()->UnitsLocked();
|
||||
|
||||
DIALOG_EDIT_COMPONENT_IN_LIBRARY dlg( this );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return;
|
||||
|
||||
if( partLocked != GetComponent()->UnitsLocked() )
|
||||
if( partLocked != GetCurPart()->UnitsLocked() )
|
||||
{
|
||||
// m_editPinsPerPartOrConvert is set to the better value, if m_UnitSelectionLocked
|
||||
// has changed
|
||||
m_editPinsPerPartOrConvert = GetComponent()->UnitsLocked() ? true : false;
|
||||
m_editPinsPerPartOrConvert = GetCurPart()->UnitsLocked() ? true : false;
|
||||
}
|
||||
|
||||
UpdateAliasSelectList();
|
||||
|
@ -1009,16 +1081,20 @@ void LIB_EDIT_FRAME::InstallDimensionsDialog( wxCommandEvent& event )
|
|||
|
||||
void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event )
|
||||
{
|
||||
wxCHECK_RET( m_component != NULL,
|
||||
wxT( "Cannot create new part from non-existent current part." ) );
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
wxCHECK_RET( part, wxT( "Cannot create new part from non-existent current part." ) );
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
m_canvas->CrossHairOff( &dc );
|
||||
EditField( &m_component->GetValueField() );
|
||||
|
||||
EditField( &part->GetValueField() );
|
||||
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
m_canvas->CrossHairOn( &dc );
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
||||
{
|
||||
int id = aEvent.GetId();
|
||||
|
@ -1029,6 +1105,8 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(),
|
||||
wxEmptyString );
|
||||
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case ID_NO_TOOL_SELECTED:
|
||||
|
@ -1036,14 +1114,16 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|||
break;
|
||||
|
||||
case ID_LIBEDIT_PIN_BUTT:
|
||||
if( m_component )
|
||||
if( part )
|
||||
{
|
||||
SetToolID( id, wxCURSOR_PENCIL, _( "Add pin" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetToolID( id, wxCURSOR_ARROW, _( "Set pin options" ) );
|
||||
|
||||
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
||||
|
||||
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
|
||||
GetEventHandler()->ProcessEvent( cmd );
|
||||
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
||||
|
@ -1087,7 +1167,7 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|||
break;
|
||||
|
||||
case ID_LIBEDIT_DELETE_ITEM_BUTT:
|
||||
if( m_component == NULL )
|
||||
if( !part )
|
||||
{
|
||||
wxBell();
|
||||
break;
|
||||
|
@ -1111,7 +1191,9 @@ void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent )
|
|||
|
||||
if( !m_drawItem->InEditMode() )
|
||||
{
|
||||
SaveCopyInUndoList( m_component );
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
SaveCopyInUndoList( part );
|
||||
m_drawItem->SetUnit( m_unit );
|
||||
}
|
||||
|
||||
|
@ -1131,7 +1213,9 @@ void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent )
|
|||
LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition,
|
||||
const KICAD_T aFilterList[] )
|
||||
{
|
||||
if( m_component == NULL )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
return NULL;
|
||||
|
||||
LIB_ITEM* item = locateItem( aPosition, aFilterList );
|
||||
|
@ -1150,12 +1234,14 @@ LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition,
|
|||
|
||||
LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aFilterList[] )
|
||||
{
|
||||
if( m_component == NULL )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
return NULL;
|
||||
|
||||
LIB_ITEM* item = NULL;
|
||||
|
||||
m_collectedItems.Collect( m_component->GetDrawItemList(), aFilterList, aPosition,
|
||||
m_collectedItems.Collect( part->GetDrawItemList(), aFilterList, aPosition,
|
||||
m_unit, m_convert );
|
||||
|
||||
if( m_collectedItems.GetCount() == 0 )
|
||||
|
@ -1181,8 +1267,9 @@ LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aF
|
|||
|
||||
for( int i = 0; i < m_collectedItems.GetCount() && i < MAX_SELECT_ITEM_IDS; i++ )
|
||||
{
|
||||
wxString text = m_collectedItems[i]->GetSelectMenuText();
|
||||
BITMAP_DEF xpm = m_collectedItems[i]->GetMenuImage();
|
||||
wxString text = m_collectedItems[i]->GetSelectMenuText();
|
||||
BITMAP_DEF xpm = m_collectedItems[i]->GetMenuImage();
|
||||
|
||||
AddMenuItem( &selectMenu, ID_SELECT_ITEM_START + i, text, KiBitmap( xpm ) );
|
||||
}
|
||||
|
||||
|
@ -1215,28 +1302,31 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
|
|||
wxCHECK_RET( m_drawItem != NULL, wxT( "No drawing item selected to delete." ) );
|
||||
|
||||
m_canvas->CrossHairOff( aDC );
|
||||
SaveCopyInUndoList( m_component );
|
||||
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
SaveCopyInUndoList( part );
|
||||
|
||||
if( m_drawItem->Type() == LIB_PIN_T )
|
||||
{
|
||||
LIB_PIN* pin = (LIB_PIN*) m_drawItem;
|
||||
wxPoint pos = pin->GetPosition();
|
||||
LIB_PIN* pin = (LIB_PIN*) m_drawItem;
|
||||
wxPoint pos = pin->GetPosition();
|
||||
|
||||
m_component->RemoveDrawItem( (LIB_ITEM*) pin, m_canvas, aDC );
|
||||
part->RemoveDrawItem( (LIB_ITEM*) pin, m_canvas, aDC );
|
||||
|
||||
if( SynchronizePins() )
|
||||
{
|
||||
LIB_PIN* tmp = m_component->GetNextPin();
|
||||
LIB_PIN* tmp = part->GetNextPin();
|
||||
|
||||
while( tmp != NULL )
|
||||
{
|
||||
pin = tmp;
|
||||
tmp = m_component->GetNextPin( pin );
|
||||
tmp = part->GetNextPin( pin );
|
||||
|
||||
if( pin->GetPosition() != pos )
|
||||
continue;
|
||||
|
||||
m_component->RemoveDrawItem( (LIB_ITEM*) pin );
|
||||
part->RemoveDrawItem( (LIB_ITEM*) pin );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1250,7 +1340,7 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
|
|||
}
|
||||
else
|
||||
{
|
||||
m_component->RemoveDrawItem( m_drawItem, m_canvas, aDC );
|
||||
part->RemoveDrawItem( m_drawItem, m_canvas, aDC );
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
}
|
||||
|
@ -1277,8 +1367,10 @@ void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
bool LIB_EDIT_FRAME::SynchronizePins() const
|
||||
bool LIB_EDIT_FRAME::SynchronizePins()
|
||||
{
|
||||
return !m_editPinsPerPartOrConvert && ( m_component && ( m_component->HasConversion() ||
|
||||
m_component->IsMulti()) );
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
return !m_editPinsPerPartOrConvert && ( part &&
|
||||
( part->HasConversion() || part->IsMulti() ) );
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
|
||||
|
||||
class SCH_EDIT_FRAME;
|
||||
class CMP_LIBRARY;
|
||||
class LIB_COMPONENT;
|
||||
class PART_LIB;
|
||||
class LIB_PART;
|
||||
class LIB_ALIAS;
|
||||
class LIB_FIELD;
|
||||
class DIALOG_LIB_EDIT_TEXT;
|
||||
|
@ -50,7 +50,8 @@ class DIALOG_LIB_EDIT_TEXT;
|
|||
*/
|
||||
class LIB_EDIT_FRAME : public SCH_BASE_FRAME
|
||||
{
|
||||
LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit.
|
||||
LIB_PART* m_my_part; ///< a part I own, it is not in any library, but a copy could be.
|
||||
LIB_PART* m_tempCopyComponent; ///< temp copy of a part during edit, I own it here.
|
||||
LIB_COLLECTOR m_collectedItems; ///< Used for hit testing.
|
||||
wxComboBox* m_partSelectBox; ///< a Box to select a part to edit (if any)
|
||||
wxComboBox* m_aliasSelectBox; ///< a box to select the alias to edit (if any)
|
||||
|
@ -85,14 +86,9 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME
|
|||
/** Default line width for drawing or editing graphic items. */
|
||||
static int m_drawLineWidth;
|
||||
|
||||
/** The current active library. NULL if no active library is selected. */
|
||||
static CMP_LIBRARY* m_library;
|
||||
/** The current component being edited. NULL if no component is selected. */
|
||||
static LIB_COMPONENT* m_component;
|
||||
|
||||
static LIB_ITEM* m_lastDrawItem;
|
||||
static LIB_ITEM* m_drawItem;
|
||||
static wxString m_aliasName;
|
||||
static LIB_ITEM* m_lastDrawItem;
|
||||
static LIB_ITEM* m_drawItem;
|
||||
static wxString m_aliasName;
|
||||
|
||||
// The unit number to edit and show
|
||||
static int m_unit;
|
||||
|
@ -133,6 +129,26 @@ public:
|
|||
*/
|
||||
static const wxChar* GetLibEditFrameName();
|
||||
|
||||
/** The current library being edited, or NULL if none. */
|
||||
PART_LIB* GetCurLib();
|
||||
|
||||
/** Sets the current library and return the old. */
|
||||
PART_LIB* SetCurLib( PART_LIB* aLib );
|
||||
|
||||
/**
|
||||
* Function GetCurPart
|
||||
* returns the current part being edited, or NULL if none selected.
|
||||
* This is a LIB_PART that I own, it is at best a copy of one in a library.
|
||||
*/
|
||||
LIB_PART* GetCurPart();
|
||||
|
||||
/**
|
||||
* Function SetCurPart
|
||||
* takes ownership over aPart and notes that it is the one currently
|
||||
* being edited.
|
||||
*/
|
||||
void SetCurPart( LIB_PART* aPart );
|
||||
|
||||
void ReCreateMenuBar();
|
||||
|
||||
/**
|
||||
|
@ -153,7 +169,7 @@ public:
|
|||
* component has multiple parts or body styles. Otherwise false is
|
||||
* returned.
|
||||
*/
|
||||
bool SynchronizePins() const;
|
||||
bool SynchronizePins();
|
||||
|
||||
/**
|
||||
* Function OnPlotCurrentComponent
|
||||
|
@ -296,7 +312,6 @@ public:
|
|||
Close( false );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function OnModify
|
||||
* Must be called after a schematic change
|
||||
|
@ -307,14 +322,9 @@ public:
|
|||
GetScreen()->SetModify();
|
||||
}
|
||||
|
||||
const wxString& GetAliasName() { return m_aliasName; }
|
||||
|
||||
LIB_COMPONENT* GetComponent( void ) { return m_component; }
|
||||
|
||||
CMP_LIBRARY* GetLibrary( void ) { return m_library; }
|
||||
|
||||
wxString& GetAliasName( void ) { return m_aliasName; }
|
||||
|
||||
int GetUnit( void ) { return m_unit; }
|
||||
int GetUnit() { return m_unit; }
|
||||
|
||||
void SetUnit( int unit )
|
||||
{
|
||||
|
@ -322,8 +332,7 @@ public:
|
|||
m_unit = unit;
|
||||
}
|
||||
|
||||
|
||||
int GetConvert( void ) { return m_convert; }
|
||||
int GetConvert() { return m_convert; }
|
||||
|
||||
void SetConvert( int convert )
|
||||
{
|
||||
|
@ -331,24 +340,22 @@ public:
|
|||
m_convert = convert;
|
||||
}
|
||||
|
||||
|
||||
LIB_ITEM* GetLastDrawItem( void ) { return m_lastDrawItem; }
|
||||
LIB_ITEM* GetLastDrawItem() { return m_lastDrawItem; }
|
||||
|
||||
void SetLastDrawItem( LIB_ITEM* drawItem )
|
||||
{
|
||||
m_lastDrawItem = drawItem;
|
||||
}
|
||||
|
||||
|
||||
LIB_ITEM* GetDrawItem( void ) { return m_drawItem; }
|
||||
LIB_ITEM* GetDrawItem() { return m_drawItem; }
|
||||
|
||||
void SetDrawItem( LIB_ITEM* drawItem );
|
||||
|
||||
bool GetShowDeMorgan( void ) { return m_showDeMorgan; }
|
||||
bool GetShowDeMorgan() { return m_showDeMorgan; }
|
||||
|
||||
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
|
||||
|
||||
FILL_T GetFillStyle( void ) { return m_drawFillStyle; }
|
||||
FILL_T GetFillStyle() { return m_drawFillStyle; }
|
||||
|
||||
/**
|
||||
* Function TempCopyComponent
|
||||
|
@ -368,7 +375,7 @@ public:
|
|||
* Function GetTempCopyComponent
|
||||
* @return the temporary copy of the current component.
|
||||
*/
|
||||
LIB_COMPONENT* GetTempCopyComponent() { return m_tempCopyComponent; }
|
||||
LIB_PART* GetTempCopyComponent() { return m_tempCopyComponent; }
|
||||
|
||||
/**
|
||||
* Function ClearTempCopyComponent
|
||||
|
@ -384,30 +391,30 @@ private:
|
|||
* Function OnActivate
|
||||
* is called when the frame is activated. Tests if the current library exists.
|
||||
* The library list can be changed by the schematic editor after reloading a new schematic
|
||||
* and the current m_library can point a non existent lib.
|
||||
* and the current library can point a non existent lib.
|
||||
*/
|
||||
virtual void OnActivate( wxActivateEvent& event );
|
||||
|
||||
// General:
|
||||
|
||||
/**
|
||||
* Function SaveOnePartInMemory
|
||||
* updates the current component being edited in the active library.
|
||||
* Function SaveOnePart
|
||||
* saves the current LIB_PART into the provided PART_LIB.
|
||||
*
|
||||
* Any changes are updated in memory only and NOT to a file. The old component is
|
||||
* deleted from the library and/or any aliases before the edited component is updated
|
||||
* in the library.
|
||||
*/
|
||||
void SaveOnePartInMemory();
|
||||
void SaveOnePart( PART_LIB* aLib );
|
||||
|
||||
/**
|
||||
* Function SelectActiveLibrary
|
||||
* sets the current active library to \a aLibrary.
|
||||
*
|
||||
* @param aLibrary A pointer to the CMP_LIBRARY object to select. If NULL, then display
|
||||
* @param aLibrary A pointer to the PART_LIB object to select. If NULL, then display
|
||||
* list of available libraries to select from.
|
||||
*/
|
||||
void SelectActiveLibrary( CMP_LIBRARY* aLibrary = NULL );
|
||||
void SelectActiveLibrary( PART_LIB* aLibrary = NULL );
|
||||
|
||||
/**
|
||||
* Function OnSaveActiveLibrary
|
||||
|
@ -442,10 +449,10 @@ private:
|
|||
* loads a copy of \a aLibEntry from \a aLibrary into memory.
|
||||
*
|
||||
* @param aLibEntry A pointer to the LIB_ALIAS object to load.
|
||||
* @param aLibrary A pointer to the CMP_LIBRARY object to load \a aLibEntry from.
|
||||
* @param aLibrary A pointer to the PART_LIB object to load \a aLibEntry from.
|
||||
* @return True if a copy of \a aLibEntry was successfully loaded from \a aLibrary.
|
||||
*/
|
||||
bool LoadOneLibraryPartAux( LIB_ALIAS* aLibEntry, CMP_LIBRARY* aLibrary );
|
||||
bool LoadOneLibraryPartAux( LIB_ALIAS* aLibEntry, PART_LIB* aLibrary );
|
||||
|
||||
/**
|
||||
* Function DisplayCmpDoc
|
||||
|
@ -501,7 +508,7 @@ private:
|
|||
void PlaceAnchor();
|
||||
|
||||
// Editing graphic items
|
||||
LIB_ITEM* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC );
|
||||
LIB_ITEM* CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC );
|
||||
void GraphicItemBeginDraw( wxDC* DC );
|
||||
void StartMoveDrawSymbol( wxDC* DC );
|
||||
void StartModifyDrawSymbol( wxDC* DC ); //<! Modify the item, adjust size etc.
|
||||
|
@ -537,11 +544,11 @@ public:
|
|||
* Function LoadComponentAndSelectLib
|
||||
* selects the current active library.
|
||||
*
|
||||
* @param aLibrary The CMP_LIBRARY to select
|
||||
* @param aLibrary The PART_LIB to select
|
||||
* @param aLibEntry The component to load from aLibrary (can be an alias).
|
||||
* @return true if \a aLibEntry was loaded from \a aLibrary.
|
||||
*/
|
||||
bool LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, CMP_LIBRARY* aLibrary );
|
||||
bool LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, PART_LIB* aLibrary );
|
||||
|
||||
/* Block commands: */
|
||||
|
||||
|
@ -618,7 +625,6 @@ public:
|
|||
*/
|
||||
void SVG_PlotComponent( const wxString& aFullFileName );
|
||||
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField )
|
|||
if( aField == NULL )
|
||||
return;
|
||||
|
||||
LIB_COMPONENT* parent = aField->GetParent();
|
||||
LIB_PART* parent = aField->GetParent();
|
||||
|
||||
// Editing the component value field is equivalent to creating a new component based
|
||||
// on the current component. Set the dialog message to inform the user.
|
||||
|
@ -71,17 +71,21 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField )
|
|||
* the old one. Rename the component and remove any conflicting aliases to prevent name
|
||||
* errors when updating the library.
|
||||
*/
|
||||
if( (aField->GetId() == VALUE) && ( text != aField->GetText() ) )
|
||||
if( aField->GetId() == VALUE && text != aField->GetText() )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
PART_LIB* lib = GetCurLib();
|
||||
|
||||
// Test the current library for name conflicts.
|
||||
if( m_library && m_library->FindEntry( text ) != NULL )
|
||||
if( lib && lib->FindEntry( text ) )
|
||||
{
|
||||
msg.Printf( _( "The name <%s> conflicts with an existing entry in the component \
|
||||
library <%s>.\n\nDo you wish to replace the current component in library with this one?" ),
|
||||
GetChars( text ),
|
||||
GetChars( m_library->GetName() ) );
|
||||
msg.Printf( _(
|
||||
"The name '%s' conflicts with an existing entry in the component library '%s'.\n\n"
|
||||
"Do you wish to replace the current component in library with this one?" ),
|
||||
GetChars( text ),
|
||||
GetChars( lib->GetName() )
|
||||
);
|
||||
|
||||
int rsp = wxMessageBox( msg, _( "Confirm" ),
|
||||
wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT, this );
|
||||
|
@ -93,9 +97,11 @@ library <%s>.\n\nDo you wish to replace the current component in library with th
|
|||
// Test the current component for name conflicts.
|
||||
if( parent->HasAlias( text ) )
|
||||
{
|
||||
msg.Printf( _( "The current component already has an alias named <%s>.\n\nDo you \
|
||||
wish to remove this alias from the component?" ),
|
||||
GetChars( text ) );
|
||||
msg.Printf( _(
|
||||
"The current component already has an alias named '%s'.\n\n"
|
||||
"Do you wish to remove this alias from the component?" ),
|
||||
GetChars( text )
|
||||
);
|
||||
|
||||
int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this );
|
||||
|
||||
|
@ -108,12 +114,13 @@ wish to remove this alias from the component?" ),
|
|||
parent->SetName( text );
|
||||
|
||||
// Test the library for any conflicts with the any aliases in the current component.
|
||||
if( parent->GetAliasCount() > 1 && m_library && m_library->Conflicts( parent ) )
|
||||
if( parent->GetAliasCount() > 1 && lib && lib->Conflicts( parent ) )
|
||||
{
|
||||
msg.Printf( _( "The new component contains alias names that conflict with entries \
|
||||
in the component library <%s>.\n\nDo you wish to remove all of the conflicting aliases from \
|
||||
this component?" ),
|
||||
GetChars( m_library->GetName() ) );
|
||||
msg.Printf( _(
|
||||
"The new component contains alias names that conflict with entries in the component library '%s'.\n\n"
|
||||
"Do you wish to remove all of the conflicting aliases from this component?" ),
|
||||
GetChars( lib->GetName() )
|
||||
);
|
||||
|
||||
int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this );
|
||||
|
||||
|
@ -127,7 +134,7 @@ this component?" ),
|
|||
|
||||
for( size_t i = 0; i < aliases.GetCount(); i++ )
|
||||
{
|
||||
if( m_library->FindEntry( aliases[ i ] ) != NULL )
|
||||
if( lib->FindEntry( aliases[ i ] ) != NULL )
|
||||
parent->RemoveAlias( aliases[ i ] );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <kicad_string.h>
|
||||
#include <wxEeschemaStruct.h>
|
||||
#include <richio.h>
|
||||
#include <project.h>
|
||||
|
||||
#include <general.h>
|
||||
#include <sch_bus_entry.h>
|
||||
|
@ -76,17 +77,19 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi
|
|||
if( !append )
|
||||
aScreen->SetFileName( aFullFileName );
|
||||
|
||||
FILE* f;
|
||||
wxString fname = aFullFileName;
|
||||
wxString fname = Prj().AbsolutePath( aFullFileName );
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
fname.Replace( wxT("/"), wxT("\\") );
|
||||
#else
|
||||
fname.Replace( wxT("\\"), wxT("/") );
|
||||
#endif
|
||||
|
||||
if( ( f = wxFopen( fname, wxT( "rt" ) ) ) == NULL )
|
||||
FILE* f = wxFopen( fname, wxT( "rt" ) );
|
||||
|
||||
if( !f )
|
||||
{
|
||||
msgDiag.Printf( _( "Failed to open <%s>" ), GetChars( aFullFileName ) );
|
||||
msgDiag.Printf( _( "Failed to open '%s'" ), GetChars( aFullFileName ) );
|
||||
DisplayError( this, msgDiag );
|
||||
return false;
|
||||
}
|
||||
|
@ -94,14 +97,14 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi
|
|||
// reader now owns the open FILE.
|
||||
FILE_LINE_READER reader( f, aFullFileName );
|
||||
|
||||
msgDiag.Printf( _( "Loading <%s>" ), GetChars( aScreen->GetFileName() ) );
|
||||
msgDiag.Printf( _( "Loading '%s'" ), GetChars( aScreen->GetFileName() ) );
|
||||
PrintMsg( msgDiag );
|
||||
|
||||
if( !reader.ReadLine()
|
||||
|| strncmp( (char*)reader + 9, SCHEMATIC_HEAD_STRING,
|
||||
sizeof( SCHEMATIC_HEAD_STRING ) - 1 ) != 0 )
|
||||
{
|
||||
msgDiag.Printf( _( "<%s> is NOT an Eeschema file!" ), GetChars( aFullFileName ) );
|
||||
msgDiag.Printf( _( "'%s' is NOT an Eeschema file!" ), GetChars( aFullFileName ) );
|
||||
DisplayError( this, msgDiag );
|
||||
return false;
|
||||
}
|
||||
|
@ -119,9 +122,11 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi
|
|||
|
||||
if( version > EESCHEMA_VERSION )
|
||||
{
|
||||
msgDiag.Printf( _( "<%s> was created by a more recent \
|
||||
version of Eeschema and may not load correctly. Please consider updating!" ),
|
||||
GetChars( aFullFileName ) );
|
||||
msgDiag.Printf( _(
|
||||
"'%s' was created by a more recent version of Eeschema and may not"
|
||||
" load correctly. Please consider updating!" ),
|
||||
GetChars( aFullFileName )
|
||||
);
|
||||
DisplayInfoMessage( this, msgDiag );
|
||||
}
|
||||
|
||||
|
|
|
@ -266,7 +266,6 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
|
|||
AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
|
||||
|
||||
// Menu place:
|
||||
// @todo unify IDs
|
||||
wxMenu* placeMenu = new wxMenu;
|
||||
|
||||
text = AddHotkeyName( _( "&Component" ), s_Schematic_Hokeys_Descr,
|
||||
|
@ -428,7 +427,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
|
|||
wxMenu* toolsMenu = new wxMenu;
|
||||
|
||||
AddMenuItem( toolsMenu,
|
||||
ID_TO_LIBRARY,
|
||||
ID_RUN_LIBRARY,
|
||||
_( "Library &Editor" ), HELP_RUN_LIB_EDITOR,
|
||||
KiBitmap( libedit_xpm ) );
|
||||
|
||||
|
@ -467,14 +466,14 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
|
|||
|
||||
// Run CvPcb
|
||||
AddMenuItem( toolsMenu,
|
||||
ID_TO_CVPCB,
|
||||
ID_RUN_CVPCB,
|
||||
_( "A&ssign Component Footprint" ),
|
||||
_( "Run CvPcb" ),
|
||||
KiBitmap( cvpcb_xpm ) );
|
||||
|
||||
// Run Pcbnew
|
||||
AddMenuItem( toolsMenu,
|
||||
ID_TO_PCB,
|
||||
ID_RUN_PCB,
|
||||
_( "&Layout Printed Circuit Board" ),
|
||||
_( "Run Pcbnew" ),
|
||||
KiBitmap( pcbnew_xpm ) );
|
||||
|
|
|
@ -92,7 +92,9 @@ bool UNIQUE_STRINGS::Lookup( const wxString& aString )
|
|||
*/
|
||||
class NETLIST_EXPORT_TOOL
|
||||
{
|
||||
NETLIST_OBJECT_LIST * m_masterList; /// The main connected items flat list
|
||||
NETLIST_OBJECT_LIST* m_masterList; /// The main connected items flat list
|
||||
|
||||
PART_LIBS* m_libs; /// no ownership
|
||||
|
||||
/// Used to temporary store and filter the list of pins of a schematic component
|
||||
/// when generating schematic component data in netlist (comp section)
|
||||
|
@ -167,7 +169,7 @@ class NETLIST_EXPORT_TOOL
|
|||
* to the temporary sorted pin list.
|
||||
*/
|
||||
void findAllInstancesOfComponent( SCH_COMPONENT* aComponent,
|
||||
LIB_COMPONENT* aEntry,
|
||||
LIB_PART* aEntry,
|
||||
SCH_SHEET_PATH* aSheetPath );
|
||||
|
||||
/**
|
||||
|
@ -230,9 +232,10 @@ class NETLIST_EXPORT_TOOL
|
|||
XNODE* makeGenericLibraries();
|
||||
|
||||
public:
|
||||
NETLIST_EXPORT_TOOL( NETLIST_OBJECT_LIST * aMasterList )
|
||||
NETLIST_EXPORT_TOOL( NETLIST_OBJECT_LIST* aMasterList, PART_LIBS* aLibs )
|
||||
{
|
||||
m_masterList = aMasterList;
|
||||
m_libs = aLibs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -375,7 +378,8 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList
|
|||
{
|
||||
bool ret = true;
|
||||
FILE* f = NULL;
|
||||
NETLIST_EXPORT_TOOL helper( aConnectedItemsList );
|
||||
|
||||
NETLIST_EXPORT_TOOL helper( aConnectedItemsList, Prj().SchLibs() );
|
||||
|
||||
bool open_file = aFormat < NET_TYPE_CUSTOM1;
|
||||
if( (aFormat == NET_TYPE_PCBNEW) && (aNetlistOptions & NET_PCBNEW_USE_NEW_FORMAT ) )
|
||||
|
@ -524,12 +528,12 @@ SCH_COMPONENT* NETLIST_EXPORT_TOOL::findNextComponent( EDA_ITEM* aItem, SCH_SHEE
|
|||
// (several sheets pointing to 1 screen), this will be erroneously be
|
||||
// toggled.
|
||||
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
|
||||
if( !entry )
|
||||
LIB_PART* part = m_libs->FindLibPart( comp->GetPartName() );
|
||||
if( !part )
|
||||
continue;
|
||||
|
||||
// If component is a "multi parts per package" type
|
||||
if( entry->GetPartCount() > 1 )
|
||||
if( part->GetUnitCount() > 1 )
|
||||
{
|
||||
// test if this reference has already been processed, and if so skip
|
||||
if( m_ReferencesAlreadyFound.Lookup( ref ) )
|
||||
|
@ -537,7 +541,7 @@ SCH_COMPONENT* NETLIST_EXPORT_TOOL::findNextComponent( EDA_ITEM* aItem, SCH_SHEE
|
|||
}
|
||||
|
||||
// record the usage of this library component entry.
|
||||
m_LibParts.insert( entry ); // rejects non-unique pointers
|
||||
m_LibParts.insert( part ); // rejects non-unique pointers
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
@ -575,13 +579,13 @@ SCH_COMPONENT* NETLIST_EXPORT_TOOL::findNextComponentAndCreatePinList( EDA_ITEM*
|
|||
// (several sheets pointing to 1 screen), this will be erroneously be
|
||||
// toggled.
|
||||
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
|
||||
LIB_PART* part = m_libs->FindLibPart( comp->GetPartName() );
|
||||
|
||||
if( !entry )
|
||||
if( !part )
|
||||
continue;
|
||||
|
||||
// If component is a "multi parts per package" type
|
||||
if( entry->GetPartCount() > 1 )
|
||||
if( part->GetUnitCount() > 1 )
|
||||
{
|
||||
// test if this reference has already been processed, and if so skip
|
||||
if( m_ReferencesAlreadyFound.Lookup( ref ) )
|
||||
|
@ -590,14 +594,14 @@ SCH_COMPONENT* NETLIST_EXPORT_TOOL::findNextComponentAndCreatePinList( EDA_ITEM*
|
|||
// Collect all pins for this reference designator by searching
|
||||
// the entire design for other parts with the same reference designator.
|
||||
// This is only done once, it would be too expensive otherwise.
|
||||
findAllInstancesOfComponent( comp, entry, aSheetPath );
|
||||
findAllInstancesOfComponent( comp, part, aSheetPath );
|
||||
}
|
||||
|
||||
else // entry->GetPartCount() <= 1 means one part per package
|
||||
else // entry->GetUnitCount() <= 1 means one part per package
|
||||
{
|
||||
LIB_PINS pins; // constructed once here
|
||||
|
||||
entry->GetPins( pins, comp->GetUnitSelection( aSheetPath ), comp->GetConvert() );
|
||||
part->GetPins( pins, comp->GetUnitSelection( aSheetPath ), comp->GetConvert() );
|
||||
|
||||
for( size_t i = 0; i < pins.size(); i++ )
|
||||
{
|
||||
|
@ -617,7 +621,7 @@ SCH_COMPONENT* NETLIST_EXPORT_TOOL::findNextComponentAndCreatePinList( EDA_ITEM*
|
|||
eraseDuplicatePins( );
|
||||
|
||||
// record the usage of this library component entry.
|
||||
m_LibParts.insert( entry ); // rejects non-unique pointers
|
||||
m_LibParts.insert( part ); // rejects non-unique pointers
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
@ -690,7 +694,7 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericLibraries()
|
|||
|
||||
for( std::set<void*>::iterator it = m_Libraries.begin(); it!=m_Libraries.end(); ++it )
|
||||
{
|
||||
CMP_LIBRARY* lib = (CMP_LIBRARY*) *it;
|
||||
PART_LIB* lib = (PART_LIB*) *it;
|
||||
XNODE* xlibrary;
|
||||
|
||||
xlibs->AddChild( xlibrary = node( wxT( "library" ) ) );
|
||||
|
@ -732,8 +736,8 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericLibParts()
|
|||
|
||||
for( std::set<void*>::iterator it = m_LibParts.begin(); it!=m_LibParts.end(); ++it )
|
||||
{
|
||||
LIB_COMPONENT* lcomp = (LIB_COMPONENT*) *it;
|
||||
CMP_LIBRARY* library = lcomp->GetLibrary();
|
||||
LIB_PART* lcomp = (LIB_PART* ) *it;
|
||||
PART_LIB* library = lcomp->GetLib();
|
||||
|
||||
m_Libraries.insert( library ); // inserts component's library if unique
|
||||
|
||||
|
@ -1028,12 +1032,14 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericComponents()
|
|||
// "logical" library name, which is in anticipation of a better search
|
||||
// algorithm for parts based on "logical_lib.part" and where logical_lib
|
||||
// is merely the library name minus path and extension.
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
|
||||
if( entry )
|
||||
xlibsource->AddAttribute( sLib, entry->GetLibrary()->GetLogicalName() );
|
||||
xlibsource->AddAttribute( sPart, comp->GetLibName() );
|
||||
LIB_PART* part = m_libs->FindLibPart( comp->GetPartName() );
|
||||
if( part )
|
||||
xlibsource->AddAttribute( sLib, part->GetLib()->GetLogicalName() );
|
||||
|
||||
xlibsource->AddAttribute( sPart, comp->GetPartName() );
|
||||
|
||||
XNODE* xsheetpath;
|
||||
|
||||
xcomp->AddChild( xsheetpath = node( sSheetPath ) );
|
||||
xsheetpath->AddAttribute( sNames, path->PathHumanReadable() );
|
||||
xsheetpath->AddAttribute( sTStamps, path->Path() );
|
||||
|
@ -1410,13 +1416,13 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPCBNEW( FILE* f, bool with_pcbnew )
|
|||
|
||||
// Get the Component FootprintFilter and put the component in
|
||||
// cmpList if filter is present
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( comp->GetLibName() );
|
||||
LIB_PART* part = m_libs->FindLibPart( comp->GetPartName() );
|
||||
|
||||
if( entry )
|
||||
if( part )
|
||||
{
|
||||
if( entry->GetFootPrints().GetCount() != 0 ) // Put in list
|
||||
if( part->GetFootPrints().GetCount() != 0 ) // Put in list
|
||||
{
|
||||
cmpList.push_back( SCH_REFERENCE( comp, entry, *path ) );
|
||||
cmpList.push_back( SCH_REFERENCE( comp, part, *path ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1442,7 +1448,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPCBNEW( FILE* f, bool with_pcbnew )
|
|||
|
||||
if( with_pcbnew ) // Add the lib name for this component
|
||||
{
|
||||
field = comp->GetLibName();
|
||||
field = comp->GetPartName();
|
||||
field.Replace( wxT( " " ), wxT( "_" ) );
|
||||
ret |= fprintf( f, " {Lib=%s}", TO_UTF8( field ) );
|
||||
}
|
||||
|
@ -1482,7 +1488,7 @@ bool NETLIST_EXPORT_TOOL::WriteNetListPCBNEW( FILE* f, bool with_pcbnew )
|
|||
|
||||
for( unsigned ii = 0; ii < cmpList.size(); ii++ )
|
||||
{
|
||||
LIB_COMPONENT* entry = cmpList[ii].GetLibComponent();
|
||||
LIB_PART* entry = cmpList[ii].GetLibComponent();
|
||||
|
||||
ref = cmpList[ii].GetRef();
|
||||
|
||||
|
@ -1612,7 +1618,7 @@ void NETLIST_EXPORT_TOOL::eraseDuplicatePins( )
|
|||
|
||||
|
||||
void NETLIST_EXPORT_TOOL::findAllInstancesOfComponent( SCH_COMPONENT* aComponent,
|
||||
LIB_COMPONENT* aEntry,
|
||||
LIB_PART* aEntry,
|
||||
SCH_SHEET_PATH* aSheetPath )
|
||||
{
|
||||
wxString ref = aComponent->GetRef( aSheetPath );
|
||||
|
|
|
@ -55,7 +55,8 @@ bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
|
|||
unsigned aNetlistOptions )
|
||||
{
|
||||
SCH_SHEET_LIST sheets;
|
||||
sheets.AnnotatePowerSymbols();
|
||||
|
||||
sheets.AnnotatePowerSymbols( Prj().SchLibs() );
|
||||
|
||||
// Performs some controls:
|
||||
if( CheckAnnotate( NULL, 0 ) )
|
||||
|
@ -81,9 +82,11 @@ bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
|
|||
|
||||
// Cleanup the entire hierarchy
|
||||
SCH_SCREENS screens;
|
||||
|
||||
screens.SchematicCleanUp();
|
||||
|
||||
NETLIST_OBJECT_LIST * connectedItemsList = BuildNetListBase();
|
||||
NETLIST_OBJECT_LIST* connectedItemsList = BuildNetListBase();
|
||||
|
||||
bool success = WriteNetListFile( connectedItemsList, aFormat,
|
||||
aFullFileName, aNetlistOptions );
|
||||
|
||||
|
@ -105,10 +108,6 @@ NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Delete all objects in list and clear list
|
||||
* (free memory used to store info about NETLIST_OBJECT items)
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::FreeList()
|
||||
{
|
||||
std::vector<NETLIST_OBJECT*>::iterator iter;
|
||||
|
@ -122,21 +121,19 @@ void NETLIST_OBJECT_LIST::FreeList()
|
|||
clear();
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::SortListbyNetcode()
|
||||
{
|
||||
sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsbyNetcode );
|
||||
}
|
||||
|
||||
|
||||
void NETLIST_OBJECT_LIST::SortListbySheet()
|
||||
{
|
||||
sort( this->begin(), this->end(), NETLIST_OBJECT_LIST::sortItemsBySheet );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Build net list connection table.
|
||||
* Initializes s_NetObjectslist
|
||||
*/
|
||||
NETLIST_OBJECT_LIST * SCH_EDIT_FRAME::BuildNetListBase()
|
||||
{
|
||||
wxBusyCursor Busy;
|
||||
|
@ -163,10 +160,7 @@ NETLIST_OBJECT_LIST * SCH_EDIT_FRAME::BuildNetListBase()
|
|||
return &s_NetObjectslist;
|
||||
}
|
||||
|
||||
/* the master function of NETLIST_OBJECT_LIST class.
|
||||
* Build the list of connected objects (pins, labels ...) and
|
||||
* all info needed to generate netlists or run ERC diags
|
||||
*/
|
||||
|
||||
bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
||||
{
|
||||
s_NetObjectslist.SetOwner( true );
|
||||
|
@ -237,7 +231,7 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
|
||||
segmentToPointConnect( net_item, IS_WIRE, istart );
|
||||
|
||||
/* Control of the junction, on BUS. */
|
||||
// Control of the junction, on BUS.
|
||||
if( net_item->m_BusNetCode == 0 )
|
||||
{
|
||||
net_item->m_BusNetCode = m_lastBusNetCode;
|
||||
|
@ -265,7 +259,7 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
break;
|
||||
|
||||
case NET_BUS:
|
||||
/* Control type connections point to point mode bus */
|
||||
// Control type connections point to point mode bus
|
||||
if( net_item->m_BusNetCode == 0 )
|
||||
{
|
||||
net_item->m_BusNetCode = m_lastBusNetCode;
|
||||
|
@ -278,7 +272,7 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
case NET_BUSLABELMEMBER:
|
||||
case NET_HIERBUSLABELMEMBER:
|
||||
case NET_GLOBBUSLABELMEMBER:
|
||||
/* Control connections similar has on BUS */
|
||||
// Control connections similar has on BUS
|
||||
if( net_item->GetNet() == 0 )
|
||||
{
|
||||
net_item->m_BusNetCode = m_lastBusNetCode;
|
||||
|
@ -295,10 +289,10 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
DumpNetTable();
|
||||
#endif
|
||||
|
||||
/* Updating the Bus Labels Netcode connected by Bus */
|
||||
// Updating the Bus Labels Netcode connected by Bus
|
||||
connectBusLabels();
|
||||
|
||||
/* Group objects by label. */
|
||||
// Group objects by label.
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
switch( GetItem( ii )->m_Type )
|
||||
|
@ -350,7 +344,7 @@ bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
|
|||
DumpNetTable();
|
||||
#endif
|
||||
|
||||
/* Compress numbers of Netcode having consecutive values. */
|
||||
// Compress numbers of Netcode having consecutive values.
|
||||
int NetCode = 0;
|
||||
m_lastNetCode = 0;
|
||||
|
||||
|
@ -392,6 +386,7 @@ static int getPriority( const NETLIST_OBJECT* Objet )
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* function evalLabelsPriority used by findBestNetNameForEachNet()
|
||||
* evalLabelsPriority calculates the priority of alabel1 and aLabel2
|
||||
* return true if alabel1 has a highter priority than aLabel2
|
||||
|
@ -434,17 +429,6 @@ static bool evalLabelsPriority( const NETLIST_OBJECT* aLabel1,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function findBestNetNameForEachNet
|
||||
* fill the .m_NetNameCandidate member of each item of aNetItemBuffer
|
||||
* with a reference to the "best" NETLIST_OBJECT usable to give a name to the net
|
||||
* If no suitable object found, .m_NetNameCandidate is filled with 0.
|
||||
* The "best" NETLIST_OBJECT is a NETLIST_OBJECT that have the type label
|
||||
* and by priority order:
|
||||
* the label is global or local
|
||||
* the label is in the first sheet in a hierarchy (the root sheet has the most priority)
|
||||
* alphabetic order.
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
|
||||
{
|
||||
int netcode = 0; // current netcode for tested items
|
||||
|
@ -582,10 +566,6 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Propagate net codes from a parent sheet to an include sheet,
|
||||
* from a pin sheet connection
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::sheetLabelConnect( NETLIST_OBJECT* SheetLabel )
|
||||
{
|
||||
if( SheetLabel->GetNet() == 0 )
|
||||
|
@ -616,13 +596,6 @@ void NETLIST_OBJECT_LIST::sheetLabelConnect( NETLIST_OBJECT* SheetLabel )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Analyzes the labels type bus member (<BUS_NAME><member_number>
|
||||
* Propagate net codes between the corresponding labels (ie when
|
||||
* the <member_number> is the same) when they are connected
|
||||
* uqsually by their BusNetCode
|
||||
* Uses and updates the variable m_lastNetCode
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::connectBusLabels()
|
||||
{
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
|
@ -663,12 +636,6 @@ void NETLIST_OBJECT_LIST::connectBusLabels()
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* propageNetCode propagates the net code NewNetCode to all elements
|
||||
* having previously the net code OldNetCode
|
||||
* If IsBus == false, m_Netcode is used to propagate the new net code
|
||||
* If IsBus == true, m_BusNetCode is used to propagate the new net code
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::propageNetCode( int aOldNetCode, int aNewNetCode, bool aIsBus )
|
||||
{
|
||||
if( aOldNetCode == aNewNetCode )
|
||||
|
@ -678,44 +645,25 @@ void NETLIST_OBJECT_LIST::propageNetCode( int aOldNetCode, int aNewNetCode, bool
|
|||
{
|
||||
for( unsigned jj = 0; jj < size(); jj++ )
|
||||
{
|
||||
NETLIST_OBJECT* objet = GetItem( jj );
|
||||
NETLIST_OBJECT* object = GetItem( jj );
|
||||
|
||||
if( objet->GetNet() == aOldNetCode )
|
||||
objet->SetNet( aNewNetCode );
|
||||
if( object->GetNet() == aOldNetCode )
|
||||
object->SetNet( aNewNetCode );
|
||||
}
|
||||
}
|
||||
else // Propagate BusNetCode
|
||||
{
|
||||
for( unsigned jj = 0; jj < size(); jj++ )
|
||||
{
|
||||
NETLIST_OBJECT* objet = GetItem( jj );
|
||||
NETLIST_OBJECT* object = GetItem( jj );
|
||||
|
||||
if( objet->m_BusNetCode == aOldNetCode )
|
||||
objet->m_BusNetCode = aNewNetCode;
|
||||
if( object->m_BusNetCode == aOldNetCode )
|
||||
object->m_BusNetCode = aNewNetCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check if Ref element is connected to other elements of the list of objects
|
||||
* in the schematic, by mode point
|
||||
* A point (end superimposed)
|
||||
*
|
||||
* If IsBus:
|
||||
* The connection involves elements such as bus
|
||||
* (Or BUS or BUSLABEL JUNCTION)
|
||||
* Otherwise
|
||||
* The connection involves elements such as non-bus
|
||||
* (Other than BUS or BUSLABEL)
|
||||
*
|
||||
* The Ref object must have a valid Netcode.
|
||||
*
|
||||
* The list of objects is SUPPOSED class by SheetPath Croissants,
|
||||
* And research is done from the start element, 1st element
|
||||
* Leaf schema
|
||||
* (There can be no physical connection between elements of different sheets)
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus,
|
||||
int start )
|
||||
{
|
||||
|
@ -765,13 +713,13 @@ void NETLIST_OBJECT_LIST::pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus
|
|||
}
|
||||
}
|
||||
}
|
||||
else /* Object type BUS, BUSLABELS, and junctions. */
|
||||
else // Object type BUS, BUSLABELS, and junctions.
|
||||
{
|
||||
netCode = aRef->m_BusNetCode;
|
||||
|
||||
for( unsigned i = start; i < size(); i++ )
|
||||
{
|
||||
NETLIST_OBJECT* item = GetItem( i );
|
||||
NETLIST_OBJECT* item = GetItem( i );
|
||||
|
||||
if( item->m_SheetPath != aRef->m_SheetPath )
|
||||
continue;
|
||||
|
@ -812,13 +760,6 @@ void NETLIST_OBJECT_LIST::pointToPointConnect( NETLIST_OBJECT* aRef, bool aIsBus
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Search connections betweena junction and segments
|
||||
* Propagate the junction net code to objects connected by this junction.
|
||||
* The junction must have a valid net code
|
||||
* The list of objects is expected sorted by sheets.
|
||||
* Search is done from index aIdxStart to the last element of list
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::segmentToPointConnect( NETLIST_OBJECT* aJonction,
|
||||
bool aIsBus, int aIdxStart )
|
||||
{
|
||||
|
@ -863,11 +804,6 @@ void NETLIST_OBJECT_LIST::segmentToPointConnect( NETLIST_OBJECT* aJonction,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function merges the net codes of groups of objects already connected
|
||||
* to labels (wires, bus, pins ... ) when 2 labels are equivalents
|
||||
* (i.e. group objects connected by labels)
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::labelConnect( NETLIST_OBJECT* aLabelRef )
|
||||
{
|
||||
if( aLabelRef->GetNet() == 0 )
|
||||
|
@ -911,12 +847,6 @@ void NETLIST_OBJECT_LIST::labelConnect( NETLIST_OBJECT* aLabelRef )
|
|||
}
|
||||
|
||||
|
||||
/* Set the m_ConnectionType member of items in list
|
||||
* depending on the connection type:
|
||||
* UNCONNECTED, PAD_CONNECT or NOCONNECT_SYMBOL_PRESENT
|
||||
* The list is expected sorted by order of net code,
|
||||
* i.e. items having the same net code are grouped
|
||||
*/
|
||||
void NETLIST_OBJECT_LIST::setUnconnectedFlag()
|
||||
{
|
||||
NETLIST_OBJECT* NetItemRef;
|
||||
|
@ -931,13 +861,13 @@ void NETLIST_OBJECT_LIST::setUnconnectedFlag()
|
|||
if( NetItemRef->m_Type == NET_NOCONNECT && StateFlag != PAD_CONNECT )
|
||||
StateFlag = NOCONNECT_SYMBOL_PRESENT;
|
||||
|
||||
/* Analysis of current net. */
|
||||
// Analysis of current net.
|
||||
unsigned idxtoTest = ii + 1;
|
||||
|
||||
if( ( idxtoTest >= size() )
|
||||
|| ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
|
||||
{
|
||||
/* Net analysis to update m_ConnectionType */
|
||||
// Net analysis to update m_ConnectionType
|
||||
NetEnd = idxtoTest;
|
||||
|
||||
/* set m_ConnectionType member to StateFlag for all items of
|
||||
|
@ -948,7 +878,7 @@ void NETLIST_OBJECT_LIST::setUnconnectedFlag()
|
|||
if( idxtoTest >= size() )
|
||||
return;
|
||||
|
||||
/* Start Analysis next Net */
|
||||
// Start Analysis next Net
|
||||
StateFlag = UNCONNECTED;
|
||||
NetStart = idxtoTest;
|
||||
continue;
|
||||
|
@ -962,7 +892,7 @@ void NETLIST_OBJECT_LIST::setUnconnectedFlag()
|
|||
* StateFlag is already set to PAD_CONNECT this state is kept (the
|
||||
* no connect symbol was surely an error and an ERC will report this)
|
||||
*/
|
||||
for( ; ; idxtoTest++ )
|
||||
for( ; ; idxtoTest++ )
|
||||
{
|
||||
if( ( idxtoTest >= size() )
|
||||
|| ( NetItemRef->GetNet() != GetItem( idxtoTest )->GetNet() ) )
|
||||
|
@ -1003,4 +933,3 @@ void NETLIST_OBJECT_LIST::setUnconnectedFlag()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,11 +84,10 @@ class SCH_REFERENC_LIST;
|
|||
*/
|
||||
class SCH_REFERENCE
|
||||
{
|
||||
private:
|
||||
/// Component reference prefix, without number (for IC1, this is IC) )
|
||||
std::string m_Ref; // it's private, use the accessors please
|
||||
UTF8 m_Ref; // it's private, use the accessors please
|
||||
SCH_COMPONENT* m_RootCmp; ///< The component associated the reference object.
|
||||
LIB_COMPONENT* m_Entry; ///< The source component from a library.
|
||||
LIB_PART* m_Entry; ///< The source component from a library.
|
||||
wxPoint m_CmpPos; ///< The physical position of the component in schematic
|
||||
///< used to annotate by X or Y position
|
||||
int m_Unit; ///< The unit number for components with multiple parts
|
||||
|
@ -104,9 +103,11 @@ private:
|
|||
|
||||
friend class SCH_REFERENCE_LIST;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
SCH_REFERENCE()
|
||||
SCH_REFERENCE() :
|
||||
m_SheetPath()
|
||||
{
|
||||
m_RootCmp = NULL;
|
||||
m_Entry = NULL;
|
||||
|
@ -119,16 +120,16 @@ public:
|
|||
m_SheetNum = 0;
|
||||
}
|
||||
|
||||
SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_COMPONENT* aLibComponent,
|
||||
SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent,
|
||||
SCH_SHEET_PATH& aSheetPath );
|
||||
|
||||
SCH_COMPONENT* GetComponent() const { return m_RootCmp; }
|
||||
SCH_COMPONENT* GetComp() const { return m_RootCmp; }
|
||||
|
||||
LIB_COMPONENT* GetLibComponent() const { return m_Entry; }
|
||||
LIB_PART* GetLibComponent() const { return m_Entry; }
|
||||
|
||||
SCH_SHEET_PATH GetSheetPath() const { return m_SheetPath; }
|
||||
SCH_SHEET_PATH GetSheetPath() const { return m_SheetPath; }
|
||||
|
||||
int GetUnit() const { return m_Unit; }
|
||||
int GetUnit() const { return m_Unit; }
|
||||
|
||||
void SetSheetNumber( int aSheetNumber ) { m_SheetNum = aSheetNumber; }
|
||||
|
||||
|
@ -153,12 +154,12 @@ public:
|
|||
|
||||
void SetRef( const wxString& aReference )
|
||||
{
|
||||
m_Ref = TO_UTF8( aReference );
|
||||
m_Ref = aReference;
|
||||
}
|
||||
|
||||
wxString GetRef() const
|
||||
{
|
||||
return FROM_UTF8( m_Ref.c_str() );
|
||||
return m_Ref;
|
||||
}
|
||||
void SetRefStr( const std::string& aReference )
|
||||
{
|
||||
|
@ -171,7 +172,7 @@ public:
|
|||
|
||||
int CompareValue( const SCH_REFERENCE& item ) const
|
||||
{
|
||||
return m_Value->GetText().CmpNoCase( item.m_Value->GetText() );
|
||||
return Cmp_KEEPCASE( m_Value->GetText(), item.m_Value->GetText() );
|
||||
}
|
||||
|
||||
int CompareRef( const SCH_REFERENCE& item ) const
|
||||
|
@ -181,10 +182,10 @@ public:
|
|||
|
||||
int CompareLibName( const SCH_REFERENCE& item ) const
|
||||
{
|
||||
return m_RootCmp->GetLibName().CmpNoCase( item.m_RootCmp->GetLibName() );
|
||||
return Cmp_KEEPCASE( m_RootCmp->GetPartName(), item.m_RootCmp->GetPartName() );
|
||||
}
|
||||
|
||||
bool IsPartsLocked()
|
||||
bool IsUnitsLocked()
|
||||
{
|
||||
return m_Entry->UnitsLocked();
|
||||
}
|
||||
|
|
|
@ -59,29 +59,24 @@ static void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text );
|
|||
static void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label );
|
||||
static void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel );
|
||||
static void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* GLabel );
|
||||
static void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component );
|
||||
static void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component );
|
||||
static void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, PART_LIBS* aLibs );
|
||||
static void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, PART_LIBS* aLibs );
|
||||
static void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field );
|
||||
static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame );
|
||||
static void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap );
|
||||
static void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY_BASE * aBusEntry );
|
||||
|
||||
|
||||
|
||||
/* Prepare context menu when a click on the right mouse button occurs.
|
||||
*
|
||||
* This menu is then added to the list of zoom commands.
|
||||
*/
|
||||
bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
||||
{
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
bool BlockActive = GetScreen()->IsBlockActive();
|
||||
wxString msg;
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
bool blockActive = GetScreen()->IsBlockActive();
|
||||
wxString msg;
|
||||
|
||||
// Do not start a block command on context menu.
|
||||
m_canvas->SetCanStartBlock( -1 );
|
||||
|
||||
if( BlockActive )
|
||||
if( blockActive )
|
||||
{
|
||||
AddMenusForBlock( PopMenu, this );
|
||||
PopMenu->AppendSeparator();
|
||||
|
@ -92,45 +87,45 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
|||
{
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_COMPONENT_T:
|
||||
AddMenusForEditComponent( PopMenu, (SCH_COMPONENT *) item );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
case SCH_COMPONENT_T:
|
||||
AddMenusForEditComponent( PopMenu, (SCH_COMPONENT *) item, Prj().SchLibs() );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
case SCH_TEXT_T:
|
||||
msg = AddHotkeyName( _( "Edit Text" ), s_Schematic_Hokeys_Descr, HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
case SCH_TEXT_T:
|
||||
msg = AddHotkeyName( _( "Edit Text" ), s_Schematic_Hokeys_Descr, HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
case SCH_LABEL_T:
|
||||
msg = AddHotkeyName( _( "Edit Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
case SCH_LABEL_T:
|
||||
msg = AddHotkeyName( _( "Edit Label" ), s_Schematic_Hokeys_Descr, HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
msg = AddHotkeyName( _( "Edit Global Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
msg = AddHotkeyName( _( "Edit Global Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
case SCH_HIERARCHICAL_LABEL_T:
|
||||
msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
case SCH_HIERARCHICAL_LABEL_T:
|
||||
msg = AddHotkeyName( _( "Edit Hierarchical Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_text_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
case SCH_BITMAP_T:
|
||||
msg = AddHotkeyName( _( "Edit Image" ), s_Schematic_Hokeys_Descr, HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( image_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
case SCH_BITMAP_T:
|
||||
msg = AddHotkeyName( _( "Edit Image" ), s_Schematic_Hokeys_Descr, HK_EDIT );
|
||||
AddMenuItem( PopMenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( image_xpm ) );
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -168,20 +163,20 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
|||
|
||||
switch( GetToolId() )
|
||||
{
|
||||
case ID_WIRE_BUTT:
|
||||
AddMenusForWire( PopMenu, NULL, this );
|
||||
if( item == NULL )
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
case ID_WIRE_BUTT:
|
||||
AddMenusForWire( PopMenu, NULL, this );
|
||||
if( item == NULL )
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
case ID_BUS_BUTT:
|
||||
AddMenusForBus( PopMenu, NULL, this );
|
||||
if( item == NULL )
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
case ID_BUS_BUTT:
|
||||
AddMenusForBus( PopMenu, NULL, this );
|
||||
if( item == NULL )
|
||||
PopMenu->AppendSeparator();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -210,7 +205,6 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
|||
switch( item->Type() )
|
||||
{
|
||||
case SCH_NO_CONNECT_T:
|
||||
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete No Connect" ),
|
||||
KiBitmap( delete_xpm ) );
|
||||
break;
|
||||
|
@ -249,7 +243,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
|||
break;
|
||||
|
||||
case SCH_COMPONENT_T:
|
||||
AddMenusForComponent( PopMenu, (SCH_COMPONENT*) item );
|
||||
AddMenusForComponent( PopMenu, (SCH_COMPONENT*) item, Prj().SchLibs() );
|
||||
break;
|
||||
|
||||
case SCH_BITMAP_T:
|
||||
|
@ -353,7 +347,7 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
|
|||
}
|
||||
|
||||
|
||||
void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
||||
void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, PART_LIBS* aLibs )
|
||||
{
|
||||
if( Component->Type() != SCH_COMPONENT_T )
|
||||
{
|
||||
|
@ -362,9 +356,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
}
|
||||
|
||||
wxString msg;
|
||||
LIB_ALIAS* libEntry;
|
||||
|
||||
libEntry = CMP_LIBRARY::FindLibraryEntry( Component->GetLibName() );
|
||||
LIB_ALIAS* libEntry = aLibs->FindLibraryEntry( Component->GetPartName() );
|
||||
|
||||
if( !Component->GetFlags() )
|
||||
{
|
||||
|
@ -391,7 +383,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
AddMenuItem( PopMenu, orientmenu, ID_POPUP_SCH_GENERIC_ORIENT_CMP,
|
||||
_( "Orient Component" ), KiBitmap( orient_xpm ) );
|
||||
|
||||
AddMenusForEditComponent( PopMenu, Component );
|
||||
AddMenusForEditComponent( PopMenu, Component, aLibs );
|
||||
|
||||
if( !Component->GetFlags() )
|
||||
{
|
||||
|
@ -407,7 +399,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
}
|
||||
|
||||
|
||||
void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
||||
void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, PART_LIBS* aLibs )
|
||||
{
|
||||
if( Component->Type() != SCH_COMPONENT_T )
|
||||
{
|
||||
|
@ -415,20 +407,18 @@ void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
return;
|
||||
}
|
||||
|
||||
wxString msg;
|
||||
LIB_ALIAS* libEntry;
|
||||
LIB_COMPONENT* libComponent = NULL;
|
||||
|
||||
libEntry = CMP_LIBRARY::FindLibraryEntry( Component->GetLibName() );
|
||||
wxString msg;
|
||||
LIB_PART* part = NULL;
|
||||
LIB_ALIAS* libEntry = aLibs->FindLibraryEntry( Component->GetPartName() );
|
||||
|
||||
if( libEntry )
|
||||
libComponent = libEntry->GetComponent();
|
||||
part = libEntry->GetPart();
|
||||
|
||||
wxMenu* editmenu = new wxMenu;
|
||||
msg = AddHotkeyName( _( "Edit" ), s_Schematic_Hokeys_Descr, HK_EDIT );
|
||||
AddMenuItem( editmenu, ID_SCH_EDIT_ITEM, msg, KiBitmap( edit_component_xpm ) );
|
||||
|
||||
if( libComponent && libComponent->IsNormal() )
|
||||
if( part && part->IsNormal() )
|
||||
{
|
||||
msg = AddHotkeyName( _( "Value" ), s_Schematic_Hokeys_Descr,
|
||||
HK_EDIT_COMPONENT_VALUE );
|
||||
|
@ -446,15 +436,15 @@ void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
KiBitmap( edit_comp_footprint_xpm ) );
|
||||
}
|
||||
|
||||
if( libComponent && libComponent->HasConversion() )
|
||||
if( part && part->HasConversion() )
|
||||
AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_CONVERT_CMP, _( "Convert" ),
|
||||
KiBitmap( component_select_alternate_shape_xpm ) );
|
||||
|
||||
if( libComponent && ( libComponent->GetPartCount() >= 2 ) )
|
||||
if( part && part->GetUnitCount() >= 2 )
|
||||
{
|
||||
wxMenu* sel_unit_menu = new wxMenu; int ii;
|
||||
|
||||
for( ii = 0; ii < libComponent->GetPartCount(); ii++ )
|
||||
for( ii = 0; ii < part->GetUnitCount(); ii++ )
|
||||
{
|
||||
wxString num_unit;
|
||||
int unit = Component->GetUnit();
|
||||
|
@ -480,7 +470,6 @@ void AddMenusForEditComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
|
||||
AddMenuItem( PopMenu, editmenu, ID_SCH_EDIT_ITEM,
|
||||
_( "Edit Component" ), KiBitmap( edit_component_xpm ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -863,6 +852,7 @@ void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME*
|
|||
KiBitmap( info_xpm ) );
|
||||
}
|
||||
|
||||
|
||||
void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap )
|
||||
{
|
||||
wxString msg;
|
||||
|
@ -892,6 +882,7 @@ void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void AddMenusForBusEntry( wxMenu* aPopMenu, SCH_BUS_ENTRY_BASE* aBusEntry )
|
||||
{
|
||||
wxString msg;
|
||||
|
|
|
@ -222,14 +222,13 @@ static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
|||
*/
|
||||
void LIB_EDIT_FRAME::PlacePin()
|
||||
{
|
||||
LIB_PIN* Pin;
|
||||
LIB_PIN* CurrentPin = (LIB_PIN*) m_drawItem;
|
||||
LIB_PIN* cur_pin = (LIB_PIN*) m_drawItem;
|
||||
bool ask_for_pin = true;
|
||||
wxPoint newpos;
|
||||
bool status;
|
||||
|
||||
// Some tests
|
||||
if( (CurrentPin == NULL) || (CurrentPin->Type() != LIB_PIN_T) )
|
||||
if( !cur_pin || cur_pin->Type() != LIB_PIN_T )
|
||||
{
|
||||
wxMessageBox( wxT( "LIB_EDIT_FRAME::PlacePin() error" ) );
|
||||
return;
|
||||
|
@ -237,18 +236,20 @@ void LIB_EDIT_FRAME::PlacePin()
|
|||
|
||||
newpos = GetCrossHairPosition( true );
|
||||
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
// Test for an other pin in same new position:
|
||||
for( Pin = m_component->GetNextPin(); Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
|
||||
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
||||
{
|
||||
if( Pin == CurrentPin || newpos != Pin->GetPosition() || Pin->GetFlags() )
|
||||
if( pin == cur_pin || newpos != pin->GetPosition() || pin->GetFlags() )
|
||||
continue;
|
||||
|
||||
if( ask_for_pin && SynchronizePins() )
|
||||
{
|
||||
m_canvas->SetIgnoreMouseEvents( true );
|
||||
status =
|
||||
IsOK( this, _( "This position is already occupied by \
|
||||
another pin. Continue?" ) );
|
||||
|
||||
status = IsOK( this, _( "This position is already occupied by another pin. Continue?" ) );
|
||||
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
m_canvas->SetIgnoreMouseEvents( false );
|
||||
|
||||
|
@ -264,33 +265,33 @@ another pin. Continue?" ) );
|
|||
if( GetTempCopyComponent() )
|
||||
SaveCopyInUndoList( GetTempCopyComponent() );
|
||||
else
|
||||
SaveCopyInUndoList( m_component );
|
||||
SaveCopyInUndoList( part );
|
||||
|
||||
m_canvas->SetMouseCapture( NULL, NULL );
|
||||
OnModify();
|
||||
CurrentPin->Move( newpos );
|
||||
cur_pin->Move( newpos );
|
||||
|
||||
if( CurrentPin->IsNew() )
|
||||
if( cur_pin->IsNew() )
|
||||
{
|
||||
LastPinOrient = CurrentPin->GetOrientation();
|
||||
LastPinType = CurrentPin->GetType();
|
||||
LastPinShape = CurrentPin->GetShape();
|
||||
LastPinOrient = cur_pin->GetOrientation();
|
||||
LastPinType = cur_pin->GetType();
|
||||
LastPinShape = cur_pin->GetShape();
|
||||
|
||||
if( SynchronizePins() )
|
||||
CreateImagePins( CurrentPin, m_unit, m_convert, m_showDeMorgan );
|
||||
CreateImagePins( cur_pin, m_unit, m_convert, m_showDeMorgan );
|
||||
|
||||
m_lastDrawItem = CurrentPin;
|
||||
m_component->AddDrawItem( m_drawItem );
|
||||
m_lastDrawItem = cur_pin;
|
||||
part->AddDrawItem( m_drawItem );
|
||||
}
|
||||
|
||||
// Put linked pins in new position, and clear flags
|
||||
for( Pin = m_component->GetNextPin(); Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
|
||||
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
||||
{
|
||||
if( Pin->GetFlags() == 0 )
|
||||
if( pin->GetFlags() == 0 )
|
||||
continue;
|
||||
|
||||
Pin->Move( CurrentPin->GetPosition() );
|
||||
Pin->ClearFlags();
|
||||
pin->Move( cur_pin->GetPosition() );
|
||||
pin->ClearFlags();
|
||||
}
|
||||
|
||||
m_drawItem = NULL;
|
||||
|
@ -307,37 +308,41 @@ another pin. Continue?" ) );
|
|||
*/
|
||||
void LIB_EDIT_FRAME::StartMovePin( wxDC* DC )
|
||||
{
|
||||
LIB_PIN* currentPin = (LIB_PIN*) m_drawItem;
|
||||
LIB_PIN* cur_pin = (LIB_PIN*) m_drawItem;
|
||||
wxPoint startPos;
|
||||
|
||||
TempCopyComponent();
|
||||
|
||||
// Mark pins for moving.
|
||||
LIB_PIN* pin = m_component->GetNextPin();
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
for( ; pin != NULL; pin = m_component->GetNextPin( pin ) )
|
||||
// Mark pins for moving.
|
||||
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
||||
{
|
||||
pin->ClearFlags();
|
||||
|
||||
if( pin == currentPin )
|
||||
if( pin == cur_pin )
|
||||
continue;
|
||||
|
||||
if( ( pin->GetPosition() == currentPin->GetPosition() )
|
||||
&& ( pin->GetOrientation() == currentPin->GetOrientation() )
|
||||
&& SynchronizePins() )
|
||||
if( pin->GetPosition() == cur_pin->GetPosition() &&
|
||||
pin->GetOrientation() == cur_pin->GetOrientation() && SynchronizePins() )
|
||||
{
|
||||
pin->SetFlags( IS_LINKED | IS_MOVED );
|
||||
}
|
||||
}
|
||||
|
||||
currentPin->SetFlags( IS_LINKED | IS_MOVED );
|
||||
PinPreviousPos = OldPos = currentPin->GetPosition();
|
||||
cur_pin->SetFlags( IS_LINKED | IS_MOVED );
|
||||
|
||||
PinPreviousPos = OldPos = cur_pin->GetPosition();
|
||||
startPos.x = OldPos.x;
|
||||
startPos.y = -OldPos.y;
|
||||
|
||||
// m_canvas->CrossHairOff( DC );
|
||||
SetCrossHairPosition( startPos );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
|
||||
MSG_PANEL_ITEMS items;
|
||||
currentPin->GetMsgPanelInfo( items );
|
||||
|
||||
cur_pin->GetMsgPanelInfo( items );
|
||||
SetMsgPanel( items );
|
||||
m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove );
|
||||
// m_canvas->CrossHairOn( DC );
|
||||
|
@ -358,33 +363,33 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
|
|||
if( parent == NULL )
|
||||
return;
|
||||
|
||||
LIB_PIN* CurrentPin = (LIB_PIN*) parent->GetDrawItem();
|
||||
LIB_PIN* cur_pin = (LIB_PIN*) parent->GetDrawItem();
|
||||
|
||||
if( CurrentPin == NULL || CurrentPin->Type() != LIB_PIN_T )
|
||||
if( cur_pin == NULL || cur_pin->Type() != LIB_PIN_T )
|
||||
return;
|
||||
|
||||
wxPoint pinpos = CurrentPin->GetPosition();
|
||||
wxPoint pinpos = cur_pin->GetPosition();
|
||||
bool showPinText = true;
|
||||
|
||||
// Erase pin in old position
|
||||
if( aErase )
|
||||
{
|
||||
CurrentPin->Move( PinPreviousPos );
|
||||
CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
|
||||
cur_pin->Move( PinPreviousPos );
|
||||
cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
|
||||
&showPinText, DefaultTransform );
|
||||
}
|
||||
|
||||
// Redraw pin in new position
|
||||
CurrentPin->Move( aPanel->GetParent()->GetCrossHairPosition( true ) );
|
||||
CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
|
||||
cur_pin->Move( aPanel->GetParent()->GetCrossHairPosition( true ) );
|
||||
cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
|
||||
&showPinText, DefaultTransform );
|
||||
|
||||
PinPreviousPos = CurrentPin->GetPosition();
|
||||
PinPreviousPos = cur_pin->GetPosition();
|
||||
|
||||
/* Keep the original position for existing pin (for Undo command)
|
||||
* and the current position for a new pin */
|
||||
if( !CurrentPin->IsNew() )
|
||||
CurrentPin->Move( pinpos );
|
||||
if( !cur_pin->IsNew() )
|
||||
cur_pin->Move( pinpos );
|
||||
}
|
||||
|
||||
|
||||
|
@ -393,15 +398,16 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
|
|||
*/
|
||||
void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
|
||||
{
|
||||
LIB_PIN* pin;
|
||||
bool showPinText = true;
|
||||
|
||||
if( m_component == NULL )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
||||
m_component->ClearStatus();
|
||||
part->ClearStatus();
|
||||
|
||||
pin = new LIB_PIN( m_component );
|
||||
LIB_PIN* pin = new LIB_PIN( part );
|
||||
|
||||
m_drawItem = pin;
|
||||
|
||||
|
@ -469,7 +475,7 @@ void LIB_EDIT_FRAME::CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bo
|
|||
aPin->GetParent()->AddDrawItem( NewPin );
|
||||
}
|
||||
|
||||
for( ii = 1; ii <= aPin->GetParent()->GetPartCount(); ii++ )
|
||||
for( ii = 1; ii <= aPin->GetParent()->GetUnitCount(); ii++ )
|
||||
{
|
||||
if( ii == aUnit || aPin->GetUnit() == 0 )
|
||||
continue; // Pin common to all units.
|
||||
|
@ -513,7 +519,9 @@ void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId )
|
|||
{
|
||||
bool selected = aMasterPin->IsSelected();
|
||||
|
||||
if( ( m_component == NULL ) || ( aMasterPin == NULL ) )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part || !aMasterPin )
|
||||
return;
|
||||
|
||||
if( aMasterPin->Type() != LIB_PIN_T )
|
||||
|
@ -521,11 +529,9 @@ void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId )
|
|||
|
||||
OnModify( );
|
||||
|
||||
LIB_PIN* pin = m_component->GetNextPin();
|
||||
|
||||
for( ; pin != NULL; pin = m_component->GetNextPin( pin ) )
|
||||
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
||||
{
|
||||
if( ( pin->GetConvert() ) && ( pin->GetConvert() != m_convert ) )
|
||||
if( pin->GetConvert() && pin->GetConvert() != m_convert )
|
||||
continue;
|
||||
|
||||
// Is it the "selected mode" ?
|
||||
|
@ -557,45 +563,47 @@ void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId )
|
|||
// Create a new pin based on the previous pin with an incremented pin number.
|
||||
void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
|
||||
{
|
||||
LIB_PIN* Pin;
|
||||
wxString msg;
|
||||
|
||||
if( m_component == NULL || SourcePin == NULL || SourcePin->Type() != LIB_PIN_T )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part || !SourcePin || SourcePin->Type() != LIB_PIN_T )
|
||||
return;
|
||||
|
||||
Pin = (LIB_PIN*) SourcePin->Clone();
|
||||
Pin->ClearFlags();
|
||||
Pin->SetFlags( IS_NEW );
|
||||
Pin->Move( Pin->GetPosition() + wxPoint( g_RepeatStep.x, -g_RepeatStep.y ) );
|
||||
wxString nextName = Pin->GetName();
|
||||
LIB_PIN* pin = (LIB_PIN*) SourcePin->Clone();
|
||||
|
||||
pin->ClearFlags();
|
||||
pin->SetFlags( IS_NEW );
|
||||
pin->Move( pin->GetPosition() + wxPoint( g_RepeatStep.x, -g_RepeatStep.y ) );
|
||||
wxString nextName = pin->GetName();
|
||||
IncrementLabelMember( nextName );
|
||||
Pin->SetName( nextName );
|
||||
pin->SetName( nextName );
|
||||
|
||||
Pin->PinStringNum( msg );
|
||||
pin->PinStringNum( msg );
|
||||
IncrementLabelMember( msg );
|
||||
Pin->SetPinNumFromString( msg );
|
||||
pin->SetPinNumFromString( msg );
|
||||
|
||||
m_drawItem = Pin;
|
||||
m_drawItem = pin;
|
||||
|
||||
if( SynchronizePins() )
|
||||
Pin->SetFlags( IS_LINKED );
|
||||
pin->SetFlags( IS_LINKED );
|
||||
|
||||
wxPoint savepos = GetCrossHairPosition();
|
||||
m_canvas->CrossHairOff( DC );
|
||||
|
||||
SetCrossHairPosition( wxPoint( Pin->GetPosition().x, -Pin->GetPosition().y ) );
|
||||
SetCrossHairPosition( wxPoint( pin->GetPosition().x, -pin->GetPosition().y ) );
|
||||
|
||||
// Add this new pin in list, and creates pins for others parts if needed
|
||||
m_drawItem = Pin;
|
||||
m_drawItem = pin;
|
||||
ClearTempCopyComponent();
|
||||
PlacePin();
|
||||
m_lastDrawItem = Pin;
|
||||
m_lastDrawItem = pin;
|
||||
|
||||
SetCrossHairPosition( savepos );
|
||||
m_canvas->CrossHairOn( DC );
|
||||
|
||||
MSG_PANEL_ITEMS items;
|
||||
Pin->GetMsgPanelInfo( items );
|
||||
pin->GetMsgPanelInfo( items );
|
||||
SetMsgPanel( items );
|
||||
OnModify( );
|
||||
}
|
||||
|
@ -620,20 +628,18 @@ bool sort_by_pin_number( const LIB_PIN* ref, const LIB_PIN* tst )
|
|||
}
|
||||
|
||||
|
||||
/* Test for duplicate pins and off grid pins:
|
||||
* Pins are considered off grid when they are not on the 25 mils grid
|
||||
* A grid smaller than 25 mils must be used only to build graphic shapes.
|
||||
*/
|
||||
void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
|
||||
{
|
||||
if( m_component == NULL )
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
||||
const int MIN_GRID_SIZE = 25;
|
||||
|
||||
LIB_PINS pinList;
|
||||
|
||||
m_component->GetPins( pinList );
|
||||
part->GetPins( pinList );
|
||||
|
||||
if( pinList.size() == 0 )
|
||||
{
|
||||
|
@ -672,18 +678,20 @@ void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
|
|||
this thing! Lorenzo */
|
||||
curr_pin->PinStringNum( stringCurrPinNum );
|
||||
|
||||
wxString msg = wxString::Format( _( "<b>Duplicate pin %s</b> \"%s\" at location <b>(%.3f, \
|
||||
%.3f)</b> conflicts with pin %s \"%s\" at location <b>(%.3f, %.3f)</b>" ),
|
||||
GetChars( stringCurrPinNum ),
|
||||
GetChars( curr_pin->GetName() ),
|
||||
curr_pin->GetPosition().x / 1000.0,
|
||||
-curr_pin->GetPosition().y / 1000.0,
|
||||
GetChars( stringPinNum ),
|
||||
GetChars( pin->GetName() ),
|
||||
pin->GetPosition().x / 1000.0,
|
||||
-pin->GetPosition().y / 1000.0 );
|
||||
wxString msg = wxString::Format( _(
|
||||
"<b>Duplicate pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>"
|
||||
" conflicts with pin %s \"%s\" at location <b>(%.3f, %.3f)</b>" ),
|
||||
GetChars( stringCurrPinNum ),
|
||||
GetChars( curr_pin->GetName() ),
|
||||
curr_pin->GetPosition().x / 1000.0,
|
||||
-curr_pin->GetPosition().y / 1000.0,
|
||||
GetChars( stringPinNum ),
|
||||
GetChars( pin->GetName() ),
|
||||
pin->GetPosition().x / 1000.0,
|
||||
-pin->GetPosition().y / 1000.0
|
||||
);
|
||||
|
||||
if( m_component->GetPartCount() > 1 )
|
||||
if( part->GetUnitCount() > 1 )
|
||||
{
|
||||
msg += wxString::Format( _( " in part %c" ), 'A' + curr_pin->GetUnit() - 1 );
|
||||
}
|
||||
|
@ -717,13 +725,15 @@ void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
|
|||
wxString stringPinNum;
|
||||
pin->PinStringNum( stringPinNum );
|
||||
|
||||
wxString msg = wxString::Format( _( "<b>Off grid pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>" ),
|
||||
GetChars( stringPinNum ),
|
||||
GetChars( pin->GetName() ),
|
||||
pin->GetPosition().x / 1000.0,
|
||||
-pin->GetPosition().y / 1000.0 );
|
||||
wxString msg = wxString::Format( _(
|
||||
"<b>Off grid pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>" ),
|
||||
GetChars( stringPinNum ),
|
||||
GetChars( pin->GetName() ),
|
||||
pin->GetPosition().x / 1000.0,
|
||||
-pin->GetPosition().y / 1000.0
|
||||
);
|
||||
|
||||
if( m_component->GetPartCount() > 1 )
|
||||
if( part->GetUnitCount() > 1 )
|
||||
{
|
||||
msg += wxString::Format( _( " in part %c" ), 'A' + pin->GetUnit() - 1 );
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <wxEeschemaStruct.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <dialog_plot_schematic.h>
|
||||
#include <project.h>
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef )
|
||||
|
@ -80,6 +81,8 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef )
|
|||
plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT(".")
|
||||
+ DXF_PLOTTER::GetDefaultFileExtension();
|
||||
|
||||
plotFileName = Prj().AbsolutePath( plotFileName );
|
||||
|
||||
wxString msg;
|
||||
|
||||
if( PlotOneSheetDXF( plotFileName, screen, plot_offset, 1.0, aPlotFrameRef ) )
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <wxEeschemaStruct.h>
|
||||
#include <base_units.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <project.h>
|
||||
|
||||
#include <dialog_plot_schematic.h>
|
||||
|
||||
|
@ -176,6 +177,8 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef )
|
|||
plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." )
|
||||
+ HPGL_PLOTTER::GetDefaultFileExtension();
|
||||
|
||||
plotFileName = Prj().AbsolutePath( plotFileName );
|
||||
|
||||
LOCALE_IO toggle;
|
||||
|
||||
wxString msg;
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include <base_units.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <dialog_plot_schematic.h>
|
||||
#include <project.h>
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef )
|
||||
{
|
||||
|
@ -87,7 +89,9 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef )
|
|||
plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." )
|
||||
+ PDF_PLOTTER::GetDefaultFileExtension();
|
||||
|
||||
if( ! plotter->OpenFile( plotFileName ) )
|
||||
plotFileName = Prj().AbsolutePath( plotFileName );
|
||||
|
||||
if( !plotter->OpenFile( plotFileName ) )
|
||||
{
|
||||
msg.Printf( _( "Unable to create <%s>\n" ), GetChars( plotFileName ) );
|
||||
m_MessagesBox->AppendText( msg );
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <base_units.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <dialog_plot_schematic.h>
|
||||
#include <project.h>
|
||||
|
||||
|
||||
void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef )
|
||||
|
@ -104,6 +105,8 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef )
|
|||
plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." )
|
||||
+ PS_PLOTTER::GetDefaultFileExtension();
|
||||
|
||||
plotFileName = Prj().AbsolutePath( plotFileName );
|
||||
|
||||
wxString msg;
|
||||
|
||||
if( plotOneSheetPS( plotFileName, screen, plotPage, plot_offset,
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <base_units.h>
|
||||
#include <libeditframe.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <project.h>
|
||||
|
||||
#include <dialog_plot_schematic.h>
|
||||
|
||||
|
@ -72,7 +73,9 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef )
|
|||
|
||||
sheetpath = SheetList.GetNext();
|
||||
|
||||
fn = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( ".svg" );
|
||||
wxString fileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( ".svg" );
|
||||
|
||||
fn = Prj().AbsolutePath( fileName );
|
||||
|
||||
bool success = plotOneSheetSVG( m_parent, fn.GetFullPath(), screen,
|
||||
getModeColor() ? false : true,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
class EDA_DRAW_PANEL;
|
||||
class EDA_DRAW_FRAME;
|
||||
class PICKED_ITEMS_LIST;
|
||||
class CMP_LIBRARY;
|
||||
class PART_LIB;
|
||||
class SCH_ITEM;
|
||||
|
||||
//void DisplayCmpDoc( wxString& Name );
|
||||
|
@ -51,7 +51,7 @@ void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC,
|
|||
* 0 if canceled order
|
||||
*/
|
||||
int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
|
||||
CMP_LIBRARY* Library,
|
||||
PART_LIB* Library,
|
||||
wxString& Buffer,
|
||||
wxString& OldName );
|
||||
|
||||
|
@ -61,7 +61,7 @@ int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
|
|||
* a library
|
||||
* This list is sorted, with the library cache always at end of the list
|
||||
*/
|
||||
CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame );
|
||||
PART_LIB* SelectLibraryFromList( EDA_DRAW_FRAME* frame );
|
||||
|
||||
/**
|
||||
* Get the name component from a library to load.
|
||||
|
@ -72,6 +72,6 @@ CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame );
|
|||
* 0 if canceled order
|
||||
* Place the name of the selected component list in BufName
|
||||
*/
|
||||
int GetNameOfPartToLoad( EDA_DRAW_FRAME* frame, CMP_LIBRARY* Lib, wxString& BufName );
|
||||
int GetNameOfPartToLoad( EDA_DRAW_FRAME* frame, PART_LIB* Lib, wxString& BufName );
|
||||
|
||||
#endif /* __PROTOS_H__ */
|
||||
|
|
|
@ -542,3 +542,23 @@ void SCH_FIND_COLLECTOR::Collect( SCH_FIND_REPLACE_DATA& aFindReplaceData,
|
|||
m_data.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SEARCH_RESULT SCH_TYPE_COLLECTOR::Inspect( EDA_ITEM* aItem, const void* aTestData )
|
||||
{
|
||||
// The Vist() function only visits the testItem if its type was in the
|
||||
// the scanList, so therefore we can collect anything given to us here.
|
||||
Append( aItem );
|
||||
|
||||
return SEARCH_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
void SCH_TYPE_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[] )
|
||||
{
|
||||
Empty(); // empty the collection
|
||||
|
||||
SetScanTypes( aFilterList );
|
||||
|
||||
EDA_ITEM::IterateForward( aItem, this, NULL, m_ScanTypes );
|
||||
}
|
||||
|
|
|
@ -352,4 +352,37 @@ public:
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class TYPE_COLLECTOR
|
||||
* merely gathers up all SCH_ITEMs of a given set of KICAD_T type(s). It does
|
||||
* no hit-testing.
|
||||
*
|
||||
* @see class COLLECTOR
|
||||
*/
|
||||
class SCH_TYPE_COLLECTOR : public SCH_COLLECTOR
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Function Inspect
|
||||
* is the examining function within the INSPECTOR which is passed to the
|
||||
* Iterate function.
|
||||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @param testData is not used in this class.
|
||||
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
||||
* else SCAN_CONTINUE;
|
||||
*/
|
||||
SEARCH_RESULT Inspect( EDA_ITEM* testItem, const void* testData );
|
||||
|
||||
/**
|
||||
* Function Collect
|
||||
* scans a BOARD_ITEM using this class's Inspector method, which does
|
||||
* the collection.
|
||||
* @param aBoard The BOARD_ITEM to scan.
|
||||
* @param aScanList The KICAD_Ts to gather up.
|
||||
*/
|
||||
void Collect( SCH_ITEM* aBoard, const KICAD_T aScanList[] );
|
||||
};
|
||||
|
||||
|
||||
#endif // _SCH_COLLECTORS_H_
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <sch_component.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
//#include <sch_collectors.h>
|
||||
#include <class_netlist_object.h>
|
||||
|
||||
#include <dialogs/dialog_schematic_find.h>
|
||||
|
@ -54,9 +55,6 @@
|
|||
|
||||
#define NULL_STRING "_NONAME_"
|
||||
|
||||
static LIB_COMPONENT* DummyCmp;
|
||||
|
||||
|
||||
/**
|
||||
* Function toUTFTildaText
|
||||
* convert a wxString to UTF8 and replace any control characters with a ~,
|
||||
|
@ -75,34 +73,42 @@ static std::string toUTFTildaText( const wxString& txt )
|
|||
}
|
||||
|
||||
|
||||
/* Descr component <DUMMY> used when a component is not found in library,
|
||||
* to draw a dummy shape
|
||||
* This component is a 400 mils square with the text ??
|
||||
* DEF DUMMY U 0 40 Y Y 1 0 N
|
||||
* F0 "U" 0 -350 60 H V
|
||||
* F1 "DUMMY" 0 350 60 H V
|
||||
* DRAW
|
||||
* T 0 0 0 150 0 0 0 ??
|
||||
* S -200 200 200 -200 0 1 0
|
||||
* ENDDRAW
|
||||
* ENDDEF
|
||||
/**
|
||||
* Used when a LIB_PART is not found in library
|
||||
* to draw a dummy shape
|
||||
* This component is a 400 mils square with the text ??
|
||||
* DEF DUMMY U 0 40 Y Y 1 0 N
|
||||
* F0 "U" 0 -350 60 H V
|
||||
* F1 "DUMMY" 0 350 60 H V
|
||||
* DRAW
|
||||
* T 0 0 0 150 0 0 0 ??
|
||||
* S -200 200 200 -200 0 1 0
|
||||
* ENDDRAW
|
||||
* ENDDEF
|
||||
*/
|
||||
void CreateDummyCmp()
|
||||
static LIB_PART* dummy()
|
||||
{
|
||||
DummyCmp = new LIB_COMPONENT( wxEmptyString );
|
||||
static LIB_PART* part;
|
||||
|
||||
LIB_RECTANGLE* Square = new LIB_RECTANGLE( DummyCmp );
|
||||
if( !part )
|
||||
{
|
||||
part = new LIB_PART( wxEmptyString );
|
||||
|
||||
Square->Move( wxPoint( -200, 200 ) );
|
||||
Square->SetEndPosition( wxPoint( 200, -200 ) );
|
||||
LIB_RECTANGLE* square = new LIB_RECTANGLE( part );
|
||||
|
||||
LIB_TEXT* Text = new LIB_TEXT( DummyCmp );
|
||||
square->Move( wxPoint( -200, 200 ) );
|
||||
square->SetEndPosition( wxPoint( 200, -200 ) );
|
||||
|
||||
Text->SetSize( wxSize( 150, 150 ) );
|
||||
Text->SetText( wxString( wxT( "??" ) ) );
|
||||
LIB_TEXT* text = new LIB_TEXT( part );
|
||||
|
||||
DummyCmp->AddDrawItem( Square );
|
||||
DummyCmp->AddDrawItem( Text );
|
||||
text->SetSize( wxSize( 150, 150 ) );
|
||||
text->SetText( wxString( wxT( "??" ) ) );
|
||||
|
||||
part->AddDrawItem( square );
|
||||
part->AddDrawItem( text );
|
||||
}
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,7 +119,7 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
|
|||
}
|
||||
|
||||
|
||||
SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet, int unit,
|
||||
SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit,
|
||||
int convert, const wxPoint& pos, bool setNewItemFlag ) :
|
||||
SCH_ITEM( NULL, SCH_COMPONENT_T )
|
||||
{
|
||||
|
@ -121,7 +127,9 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet
|
|||
|
||||
m_unit = unit;
|
||||
m_convert = convert;
|
||||
m_ChipName = libComponent.GetName();
|
||||
m_part_name = aPart.GetName();
|
||||
m_part = aPart.SharedPtr();
|
||||
|
||||
SetTimeStamp( GetNewTimeStamp() );
|
||||
|
||||
if( setNewItemFlag )
|
||||
|
@ -130,7 +138,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet
|
|||
// Import user defined fields from the library component:
|
||||
LIB_FIELDS libFields;
|
||||
|
||||
libComponent.GetFields( libFields );
|
||||
aPart.GetFields( libFields );
|
||||
|
||||
for( LIB_FIELDS::iterator it = libFields.begin(); it!=libFields.end(); ++it )
|
||||
{
|
||||
|
@ -155,7 +163,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet
|
|||
schField->SetText( it->GetText() );
|
||||
}
|
||||
|
||||
wxString msg = libComponent.GetReferenceField().GetText();
|
||||
wxString msg = aPart.GetReferenceField().GetText();
|
||||
|
||||
if( msg.IsEmpty() )
|
||||
msg = wxT( "U" );
|
||||
|
@ -166,22 +174,24 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet
|
|||
msg += wxT( "?" );
|
||||
SetRef( sheet, msg );
|
||||
|
||||
/* Use the schematic component name instead of the library value field
|
||||
* name.
|
||||
*/
|
||||
GetField( VALUE )->SetText( m_ChipName );
|
||||
// Use the schematic component name instead of the library value field
|
||||
// name.
|
||||
GetField( VALUE )->SetText( GetPartName() );
|
||||
}
|
||||
|
||||
|
||||
SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) :
|
||||
SCH_ITEM( aComponent )
|
||||
{
|
||||
m_Parent = aComponent.m_Parent;
|
||||
m_Pos = aComponent.m_Pos;
|
||||
m_unit = aComponent.m_unit;
|
||||
m_convert = aComponent.m_convert;
|
||||
m_ChipName = aComponent.m_ChipName;
|
||||
m_Parent = aComponent.m_Parent;
|
||||
m_Pos = aComponent.m_Pos;
|
||||
m_unit = aComponent.m_unit;
|
||||
m_convert = aComponent.m_convert;
|
||||
m_part_name = aComponent.m_part_name;
|
||||
m_part = aComponent.m_part;
|
||||
|
||||
SetTimeStamp( aComponent.m_TimeStamp );
|
||||
|
||||
m_transform = aComponent.m_transform;
|
||||
m_prefix = aComponent.m_prefix;
|
||||
m_PathsAndReferences = aComponent.m_PathsAndReferences;
|
||||
|
@ -230,12 +240,44 @@ EDA_ITEM* SCH_COMPONENT::Clone() const
|
|||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::SetLibName( const wxString& aName )
|
||||
void SCH_COMPONENT::SetPartName( const wxString& aName, PART_LIBS* aLibs )
|
||||
{
|
||||
if( m_ChipName != aName )
|
||||
if( m_part_name != aName )
|
||||
{
|
||||
m_ChipName = aName;
|
||||
m_part_name = aName;
|
||||
SetModified();
|
||||
|
||||
if( aLibs )
|
||||
Resolve( aLibs );
|
||||
else
|
||||
m_part.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool SCH_COMPONENT::Resolve( PART_LIBS* aLibs )
|
||||
{
|
||||
// I've never been happy that the actual individual PART_LIB is left up to
|
||||
// flimsy search path ordering. None-the-less find a part based on that design:
|
||||
if( LIB_PART* part = aLibs->FindLibPart( m_part_name ) )
|
||||
{
|
||||
m_part = part->SharedPtr();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::ResolveAll(
|
||||
const SCH_COLLECTOR& aComponents, PART_LIBS* aLibs )
|
||||
{
|
||||
for( int i = 0; i < aComponents.GetCount(); ++i )
|
||||
{
|
||||
SCH_COMPONENT* c = dynamic_cast<SCH_COMPONENT*>( aComponents[i] );
|
||||
wxASSERT( c );
|
||||
|
||||
c->Resolve( aLibs );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,38 +317,28 @@ void SCH_COMPONENT::SetTransform( const TRANSFORM& aTransform )
|
|||
}
|
||||
|
||||
|
||||
int SCH_COMPONENT::GetPartCount() const
|
||||
int SCH_COMPONENT::GetUnitCount() const
|
||||
{
|
||||
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
return part->GetUnitCount();
|
||||
}
|
||||
|
||||
if( Entry == NULL )
|
||||
return 0;
|
||||
|
||||
return Entry->GetPartCount();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
|
||||
GR_DRAWMODE DrawMode, EDA_COLOR_T Color, bool DrawPinText )
|
||||
{
|
||||
bool dummy = false;
|
||||
|
||||
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
|
||||
if( Entry == NULL )
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
/* Create a dummy component if the actual component can not be found. */
|
||||
dummy = true;
|
||||
|
||||
if( DummyCmp == NULL )
|
||||
CreateDummyCmp();
|
||||
|
||||
Entry = DummyCmp;
|
||||
part->Draw( panel, DC, m_Pos + offset, m_unit, m_convert, DrawMode, Color, m_transform, DrawPinText, false );
|
||||
}
|
||||
else // Use dummy() part if the actual cannot be found.
|
||||
{
|
||||
dummy()->Draw( panel, DC, m_Pos + offset, 0, 0, DrawMode, Color, m_transform, DrawPinText, false );
|
||||
}
|
||||
|
||||
Entry->Draw( panel, DC, m_Pos + offset, dummy ? 0 : m_unit, dummy ? 0 : m_convert,
|
||||
DrawMode, Color, m_transform, DrawPinText, false );
|
||||
|
||||
SCH_FIELD* field = GetField( REFERENCE );
|
||||
|
||||
|
@ -325,24 +357,23 @@ void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset
|
|||
field->Draw( panel, DC, offset, DrawMode );
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/* Draw the component boundary box */
|
||||
// Draw the component bounding box
|
||||
{
|
||||
EDA_RECT BoundaryBox;
|
||||
BoundaryBox = GetBoundingBox();
|
||||
GRRect( panel->GetClipBox(), DC, BoundaryBox, 0, BROWN );
|
||||
EDA_RECT boundingBox = GetBoundingBox();
|
||||
|
||||
GRRect( panel->GetClipBox(), DC, boundingBox, 0, BROWN );
|
||||
#if 1
|
||||
if( GetField( REFERENCE )->IsVisible() )
|
||||
{
|
||||
BoundaryBox = GetField( REFERENCE )->GetBoundingBox();
|
||||
GRRect( panel->GetClipBox(), DC, BoundaryBox, 0, BROWN );
|
||||
boundingBox = GetField( REFERENCE )->GetBoundingBox();
|
||||
GRRect( panel->GetClipBox(), DC, boundingBox, 0, BROWN );
|
||||
}
|
||||
|
||||
if( GetField( VALUE )->IsVisible() )
|
||||
{
|
||||
BoundaryBox = GetField( VALUE )->GetBoundingBox();
|
||||
GRRect( panel->GetClipBox(), DC, BoundaryBox, 0, BROWN );
|
||||
boundingBox = GetField( VALUE )->GetBoundingBox();
|
||||
GRRect( panel->GetClipBox(), DC, boundingBox, 0, BROWN );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -631,12 +662,11 @@ SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName )
|
|||
|
||||
LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number )
|
||||
{
|
||||
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
|
||||
if( Entry == NULL )
|
||||
return NULL;
|
||||
|
||||
return Entry->GetPin( number, m_unit, m_convert );
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
return part->GetPin( number, m_unit, m_convert );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -647,12 +677,14 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem )
|
|||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) aItem;
|
||||
|
||||
EXCHG( m_ChipName, component->m_ChipName );
|
||||
EXCHG( m_part_name, component->m_part_name );
|
||||
EXCHG( m_part, component->m_part );
|
||||
EXCHG( m_Pos, component->m_Pos );
|
||||
EXCHG( m_unit, component->m_unit );
|
||||
EXCHG( m_convert, component->m_convert );
|
||||
|
||||
TRANSFORM tmp = m_transform;
|
||||
|
||||
m_transform = component->m_transform;
|
||||
component->m_transform = tmp;
|
||||
|
||||
|
@ -677,13 +709,13 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem )
|
|||
void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
|
||||
{
|
||||
bool keepMulti = false;
|
||||
LIB_COMPONENT* Entry;
|
||||
static const wxString separators( wxT( " " ) );
|
||||
wxArrayString reference_fields;
|
||||
|
||||
Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
static const wxChar separators[] = wxT( " " );
|
||||
|
||||
if( Entry && Entry->UnitsLocked() )
|
||||
PART_SPTR part = m_part.lock();
|
||||
|
||||
if( part && part->UnitsLocked() )
|
||||
keepMulti = true;
|
||||
|
||||
// Build a reference with no annotation,
|
||||
|
@ -930,7 +962,7 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) const
|
|||
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
|
||||
<< " ref=\"" << TO_UTF8( GetField( 0 )->GetName() )
|
||||
<< '"' << " chipName=\""
|
||||
<< TO_UTF8( m_ChipName ) << '"' << m_Pos
|
||||
<< TO_UTF8( GetPartName() ) << '"' << m_Pos
|
||||
<< " layer=\"" << m_Layer
|
||||
<< '"' << ">\n";
|
||||
|
||||
|
@ -978,9 +1010,11 @@ bool SCH_COMPONENT::Save( FILE* f ) const
|
|||
name1 = toUTFTildaText( GetField( REFERENCE )->GetText() );
|
||||
}
|
||||
|
||||
if( !m_ChipName.IsEmpty() )
|
||||
wxString part_name = GetPartName();
|
||||
|
||||
if( part_name.size() )
|
||||
{
|
||||
name2 = toUTFTildaText( m_ChipName );
|
||||
name2 = toUTFTildaText( part_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -993,11 +1027,11 @@ bool SCH_COMPONENT::Save( FILE* f ) const
|
|||
if( fprintf( f, "L %s %s\n", name2.c_str(), name1.c_str() ) == EOF )
|
||||
return false;
|
||||
|
||||
/* Generate unit number, convert and time stamp*/
|
||||
// Generate unit number, convert and time stamp
|
||||
if( fprintf( f, "U %d %d %8.8lX\n", m_unit, m_convert, m_TimeStamp ) == EOF )
|
||||
return false;
|
||||
|
||||
/* Save the position */
|
||||
// Save the position
|
||||
if( fprintf( f, "P %d %d\n", m_Pos.x, m_Pos.y ) == EOF )
|
||||
return false;
|
||||
|
||||
|
@ -1058,7 +1092,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Unit number, position, box ( old standard ) */
|
||||
// Unit number, position, box ( old standard )
|
||||
if( fprintf( f, "\t%-4d %-4d %-4d\n", m_unit, m_Pos.x, m_Pos.y ) == EOF )
|
||||
return false;
|
||||
|
||||
|
@ -1109,14 +1143,14 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
name1[ii] = ' ';
|
||||
}
|
||||
|
||||
m_ChipName = FROM_UTF8( name1 );
|
||||
SetPartName( FROM_UTF8( name1 ) );
|
||||
|
||||
if( !newfmt )
|
||||
GetField( VALUE )->SetText( FROM_UTF8( name1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ChipName.Empty();
|
||||
m_part_name.Empty();
|
||||
GetField( VALUE )->Empty();
|
||||
GetField( VALUE )->SetOrientation( TEXT_ORIENT_HORIZ );
|
||||
GetField( VALUE )->SetVisible( false );
|
||||
|
@ -1385,29 +1419,27 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
|
||||
EDA_RECT SCH_COMPONENT::GetBodyBoundingBox() const
|
||||
{
|
||||
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
EDA_RECT bBox;
|
||||
int x0, xm, y0, ym;
|
||||
EDA_RECT bBox;
|
||||
|
||||
if( Entry == NULL )
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
if( DummyCmp == NULL )
|
||||
CreateDummyCmp();
|
||||
Entry = DummyCmp;
|
||||
bBox = part->GetBodyBoundingBox( m_unit, m_convert );
|
||||
}
|
||||
else
|
||||
{
|
||||
bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert );
|
||||
}
|
||||
|
||||
/* Get the basic Boundary box */
|
||||
bBox = Entry->GetBodyBoundingBox( m_unit, m_convert );
|
||||
x0 = bBox.GetX();
|
||||
xm = bBox.GetRight();
|
||||
int x0 = bBox.GetX();
|
||||
int xm = bBox.GetRight();
|
||||
|
||||
// We must reverse Y values, because matrix orientation
|
||||
// suppose Y axis normal for the library items coordinates,
|
||||
// m_transform reverse Y values, but bBox is already reversed!
|
||||
y0 = -bBox.GetY();
|
||||
ym = -bBox.GetBottom();
|
||||
int y0 = -bBox.GetY();
|
||||
int ym = -bBox.GetBottom();
|
||||
|
||||
/* Compute the real Boundary box (rotated, mirrored ...)*/
|
||||
// Compute the real Boundary box (rotated, mirrored ...)
|
||||
int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
|
||||
int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
|
||||
int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
|
||||
|
@ -1433,6 +1465,7 @@ EDA_RECT SCH_COMPONENT::GetBodyBoundingBox() const
|
|||
const EDA_RECT SCH_COMPONENT::GetBoundingBox() const
|
||||
{
|
||||
EDA_RECT bbox = GetBodyBoundingBox();
|
||||
|
||||
for( size_t i = 0; i < m_Fields.size(); i++ )
|
||||
{
|
||||
bbox.Merge( m_Fields[i].GetBoundingBox() );
|
||||
|
@ -1444,47 +1477,43 @@ const EDA_RECT SCH_COMPONENT::GetBoundingBox() const
|
|||
|
||||
void SCH_COMPONENT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
|
||||
{
|
||||
// search for the component in lib
|
||||
// Entry and root_component can differ if Entry is an alias
|
||||
LIB_ALIAS* alias = CMP_LIBRARY::FindLibraryEntry( m_ChipName );
|
||||
LIB_COMPONENT* root_component = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
// part and alias can differ if alias is not the root
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
LIB_ALIAS* alias = part->GetAlias( GetPartName() );
|
||||
|
||||
if( (alias == NULL) || (root_component == NULL) )
|
||||
return;
|
||||
if( !alias )
|
||||
return;
|
||||
|
||||
wxString msg;
|
||||
if( m_currentSheetPath )
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Reference" ),
|
||||
GetRef( m_currentSheetPath ),
|
||||
DARKCYAN ) );
|
||||
|
||||
if( m_currentSheetPath )
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Reference" ),
|
||||
GetRef( m_currentSheetPath ),
|
||||
DARKCYAN ) );
|
||||
wxString msg = part->IsPower() ? _( "Power symbol" ) : _( "Value" );
|
||||
|
||||
if( root_component->IsPower() )
|
||||
msg = _( "Power symbol" );
|
||||
else
|
||||
msg = _( "Value" );
|
||||
aList.push_back( MSG_PANEL_ITEM( msg, GetField( VALUE )->GetText(), DARKCYAN ) );
|
||||
|
||||
aList.push_back( MSG_PANEL_ITEM( msg, GetField( VALUE )->GetText(), DARKCYAN ) );
|
||||
// Display component reference in library and library
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Component" ), GetPartName(), BROWN ) );
|
||||
|
||||
// Display component reference in library and library
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Component" ), m_ChipName, BROWN ) );
|
||||
if( alias->GetName() != part->GetName() )
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), part->GetName(), BROWN ) );
|
||||
|
||||
if( alias->GetName() != root_component->GetName() )
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), root_component->GetName(), BROWN ) );
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Library" ), alias->GetLibraryName(), BROWN ) );
|
||||
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Library" ), alias->GetLibraryName(), BROWN ) );
|
||||
// Display the current associated footprint, if exists.
|
||||
if( !GetField( FOOTPRINT )->IsVoid() )
|
||||
msg = GetField( FOOTPRINT )->GetText();
|
||||
else
|
||||
msg = _( "<Unknown>" );
|
||||
|
||||
// Display the current associated footprin, if exists.
|
||||
if( ! GetField( FOOTPRINT )->IsVoid() )
|
||||
msg = GetField( FOOTPRINT )->GetText();
|
||||
else
|
||||
msg = _( "<Unknown>" );
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg, DARKRED ) );
|
||||
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg, DARKRED ) );
|
||||
|
||||
// Display description of the component, and keywords found in lib
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Description" ), alias->GetDescription(), DARKCYAN ) );
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Key words" ), alias->GetKeyWords(), DARKCYAN ) );
|
||||
// Display description of the component, and keywords found in lib
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Description" ), alias->GetDescription(), DARKCYAN ) );
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Key words" ), alias->GetKeyWords(), DARKCYAN ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1559,23 +1588,21 @@ bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData,
|
|||
|
||||
void SCH_COMPONENT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
||||
{
|
||||
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
|
||||
if( Entry == NULL )
|
||||
return;
|
||||
|
||||
for( LIB_PIN* Pin = Entry->GetNextPin(); Pin != NULL; Pin = Entry->GetNextPin( Pin ) )
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
wxASSERT( Pin->Type() == LIB_PIN_T );
|
||||
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
||||
{
|
||||
wxASSERT( pin->Type() == LIB_PIN_T );
|
||||
|
||||
if( Pin->GetUnit() && m_unit && ( m_unit != Pin->GetUnit() ) )
|
||||
continue;
|
||||
if( pin->GetUnit() && m_unit && ( m_unit != pin->GetUnit() ) )
|
||||
continue;
|
||||
|
||||
if( Pin->GetConvert() && m_convert && ( m_convert != Pin->GetConvert() ) )
|
||||
continue;
|
||||
if( pin->GetConvert() && m_convert && ( m_convert != pin->GetConvert() ) )
|
||||
continue;
|
||||
|
||||
DANGLING_END_ITEM item( PIN_END, Pin, GetPinPhysicalPosition( Pin ) );
|
||||
aItemList.push_back( item );
|
||||
DANGLING_END_ITEM item( PIN_END, pin, GetPinPhysicalPosition( pin ) );
|
||||
aItemList.push_back( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1606,42 +1633,44 @@ bool SCH_COMPONENT::IsSelectStateChanged( const wxRect& aRect )
|
|||
|
||||
void SCH_COMPONENT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
|
||||
{
|
||||
LIB_PIN* pin;
|
||||
LIB_COMPONENT* component = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
|
||||
wxCHECK_RET( component != NULL,
|
||||
wxT( "Cannot add connection points to list. Cannot find component <" ) +
|
||||
m_ChipName + wxT( "> in any of the loaded libraries." ) );
|
||||
|
||||
for( pin = component->GetNextPin(); pin != NULL; pin = component->GetNextPin( pin ) )
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
wxCHECK_RET( pin->Type() == LIB_PIN_T,
|
||||
wxT( "GetNextPin() did not return a pin object. Bad programmer!" ) );
|
||||
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
||||
{
|
||||
wxCHECK_RET( pin->Type() == LIB_PIN_T,
|
||||
wxT( "GetNextPin() did not return a pin object. Bad programmer!" ) );
|
||||
|
||||
// Skip items not used for this part.
|
||||
if( m_unit && pin->GetUnit() && ( pin->GetUnit() != m_unit ) )
|
||||
continue;
|
||||
// Skip items not used for this part.
|
||||
if( m_unit && pin->GetUnit() && ( pin->GetUnit() != m_unit ) )
|
||||
continue;
|
||||
|
||||
if( m_convert && pin->GetConvert() && ( pin->GetConvert() != m_convert ) )
|
||||
continue;
|
||||
if( m_convert && pin->GetConvert() && ( pin->GetConvert() != m_convert ) )
|
||||
continue;
|
||||
|
||||
// Calculate the pin position relative to the component position and orientation.
|
||||
aPoints.push_back( m_transform.TransformCoordinate( pin->GetPosition() ) + m_Pos );
|
||||
// Calculate the pin position relative to the component position and orientation.
|
||||
aPoints.push_back( m_transform.TransformCoordinate( pin->GetPosition() ) + m_Pos );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wxCHECK_RET( 0,
|
||||
wxT( "Cannot add connection points to list. Cannot find component <" ) +
|
||||
GetPartName() + wxT( "> in any of the loaded libraries." ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LIB_ITEM* SCH_COMPONENT::GetDrawItem( const wxPoint& aPosition, KICAD_T aType )
|
||||
{
|
||||
LIB_COMPONENT* component = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
// Calculate the position relative to the component.
|
||||
wxPoint libPosition = aPosition - m_Pos;
|
||||
|
||||
if( component == NULL )
|
||||
return NULL;
|
||||
return part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
|
||||
}
|
||||
|
||||
// Calculate the position relative to the component.
|
||||
wxPoint libPosition = aPosition - m_Pos;
|
||||
|
||||
return component->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1649,7 +1678,7 @@ wxString SCH_COMPONENT::GetSelectMenuText() const
|
|||
{
|
||||
wxString tmp;
|
||||
tmp.Printf( _( "Component %s, %s" ),
|
||||
GetChars( m_ChipName ),
|
||||
GetChars( GetPartName() ),
|
||||
GetChars( GetField( REFERENCE )->GetText() ) );
|
||||
return tmp;
|
||||
}
|
||||
|
@ -1658,8 +1687,7 @@ wxString SCH_COMPONENT::GetSelectMenuText() const
|
|||
SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData,
|
||||
const KICAD_T aFilterTypes[] )
|
||||
{
|
||||
KICAD_T stype;
|
||||
LIB_COMPONENT* component;
|
||||
KICAD_T stype;
|
||||
|
||||
for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
|
||||
{
|
||||
|
@ -1669,50 +1697,51 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData
|
|||
if( SEARCH_QUIT == aInspector->Inspect( this, aTestData ) )
|
||||
return SEARCH_QUIT;
|
||||
}
|
||||
|
||||
switch( stype )
|
||||
{
|
||||
case SCH_FIELD_T:
|
||||
// Test the bounding boxes of fields if they are visible and not empty.
|
||||
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
||||
case SCH_FIELD_T:
|
||||
// Test the bounding boxes of fields if they are visible and not empty.
|
||||
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
||||
{
|
||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( ii ), (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
}
|
||||
break;
|
||||
|
||||
case SCH_FIELD_LOCATE_REFERENCE_T:
|
||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( REFERENCE ), (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
break;
|
||||
|
||||
case SCH_FIELD_LOCATE_VALUE_T:
|
||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( VALUE ), (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
break;
|
||||
|
||||
case SCH_FIELD_LOCATE_FOOTPRINT_T:
|
||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( FOOTPRINT ), (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
break;
|
||||
|
||||
|
||||
case LIB_PIN_T:
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
LIB_PINS pins;
|
||||
|
||||
part->GetPins( pins, m_unit, m_convert );
|
||||
|
||||
for( size_t i = 0; i < pins.size(); i++ )
|
||||
{
|
||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( ii ), (void*) this ) )
|
||||
if( SEARCH_QUIT == aInspector->Inspect( pins[ i ], (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SCH_FIELD_LOCATE_REFERENCE_T:
|
||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( REFERENCE ), (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
break;
|
||||
|
||||
case SCH_FIELD_LOCATE_VALUE_T:
|
||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( VALUE ), (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
break;
|
||||
|
||||
case SCH_FIELD_LOCATE_FOOTPRINT_T:
|
||||
if( SEARCH_QUIT == aInspector->Inspect( GetField( FOOTPRINT ), (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
break;
|
||||
|
||||
|
||||
case LIB_PIN_T:
|
||||
component = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
|
||||
|
||||
if( component != NULL )
|
||||
{
|
||||
LIB_PINS pins;
|
||||
component->GetPins( pins, m_unit, m_convert );
|
||||
for( size_t i = 0; i < pins.size(); i++ )
|
||||
{
|
||||
if( SEARCH_QUIT == aInspector->Inspect( pins[ i ], (void*) this ) )
|
||||
return SEARCH_QUIT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1723,49 +1752,47 @@ SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR* aInspector, const void* aTestData
|
|||
void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
||||
SCH_SHEET_PATH* aSheetPath )
|
||||
{
|
||||
LIB_COMPONENT* component = CMP_LIBRARY::FindLibraryComponent( GetLibName() );
|
||||
|
||||
if( component == NULL )
|
||||
return;
|
||||
|
||||
for( LIB_PIN* pin = component->GetNextPin(); pin; pin = component->GetNextPin( pin ) )
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
wxASSERT( pin->Type() == LIB_PIN_T );
|
||||
|
||||
if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath ) ) )
|
||||
continue;
|
||||
|
||||
if( pin->GetConvert() && ( pin->GetConvert() != GetConvert() ) )
|
||||
continue;
|
||||
|
||||
wxPoint pos = GetTransform().TransformCoordinate( pin->GetPosition() ) + m_Pos;
|
||||
|
||||
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
||||
item->m_SheetPathInclude = *aSheetPath;
|
||||
item->m_Comp = (SCH_ITEM*) pin;
|
||||
item->m_SheetPath = *aSheetPath;
|
||||
item->m_Type = NET_PIN;
|
||||
item->m_Link = (SCH_ITEM*) this;
|
||||
item->m_ElectricalType = pin->GetType();
|
||||
item->m_PinNum = pin->GetNumber();
|
||||
item->m_Label = pin->GetName();
|
||||
item->m_Start = item->m_End = pos;
|
||||
|
||||
aNetListItems.push_back( item );
|
||||
|
||||
if( ( (int) pin->GetType() == (int) PIN_POWER_IN ) && !pin->IsVisible() )
|
||||
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
||||
{
|
||||
/* There is an associated PIN_LABEL. */
|
||||
item = new NETLIST_OBJECT();
|
||||
wxASSERT( pin->Type() == LIB_PIN_T );
|
||||
|
||||
if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath ) ) )
|
||||
continue;
|
||||
|
||||
if( pin->GetConvert() && ( pin->GetConvert() != GetConvert() ) )
|
||||
continue;
|
||||
|
||||
wxPoint pos = GetTransform().TransformCoordinate( pin->GetPosition() ) + m_Pos;
|
||||
|
||||
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
||||
item->m_SheetPathInclude = *aSheetPath;
|
||||
item->m_Comp = NULL;
|
||||
item->m_Comp = (SCH_ITEM*) pin;
|
||||
item->m_SheetPath = *aSheetPath;
|
||||
item->m_Type = NET_PINLABEL;
|
||||
item->m_Type = NET_PIN;
|
||||
item->m_Link = (SCH_ITEM*) this;
|
||||
item->m_ElectricalType = pin->GetType();
|
||||
item->m_PinNum = pin->GetNumber();
|
||||
item->m_Label = pin->GetName();
|
||||
item->m_Start = pos;
|
||||
item->m_End = item->m_Start;
|
||||
item->m_Start = item->m_End = pos;
|
||||
|
||||
aNetListItems.push_back( item );
|
||||
|
||||
if( ( (int) pin->GetType() == (int) PIN_POWER_IN ) && !pin->IsVisible() )
|
||||
{
|
||||
// There is an associated PIN_LABEL.
|
||||
item = new NETLIST_OBJECT();
|
||||
item->m_SheetPathInclude = *aSheetPath;
|
||||
item->m_Comp = NULL;
|
||||
item->m_SheetPath = *aSheetPath;
|
||||
item->m_Type = NET_PINLABEL;
|
||||
item->m_Label = pin->GetName();
|
||||
item->m_Start = pos;
|
||||
item->m_End = item->m_Start;
|
||||
|
||||
aNetListItems.push_back( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1824,15 +1851,18 @@ SCH_ITEM& SCH_COMPONENT::operator=( const SCH_ITEM& aItem )
|
|||
{
|
||||
SCH_ITEM::operator=( aItem );
|
||||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) &aItem;
|
||||
m_ChipName = component->m_ChipName;
|
||||
m_Pos = component->m_Pos;
|
||||
m_unit = component->m_unit;
|
||||
m_convert = component->m_convert;
|
||||
m_transform = component->m_transform;
|
||||
m_PathsAndReferences = component->m_PathsAndReferences;
|
||||
SCH_COMPONENT* c = (SCH_COMPONENT*) &aItem;
|
||||
|
||||
m_Fields = component->m_Fields; // std::vector's assignment operator.
|
||||
m_part_name = c->m_part_name;
|
||||
m_part = c->m_part;
|
||||
m_Pos = c->m_Pos;
|
||||
m_unit = c->m_unit;
|
||||
m_convert = c->m_convert;
|
||||
m_transform = c->m_transform;
|
||||
|
||||
m_PathsAndReferences = c->m_PathsAndReferences;
|
||||
|
||||
m_Fields = c->m_Fields; // std::vector's assignment operator.
|
||||
|
||||
// Reparent fields after assignment to new component.
|
||||
for( int ii = 0; ii < GetFieldCount(); ++ii )
|
||||
|
@ -1888,10 +1918,7 @@ bool SCH_COMPONENT::doIsConnected( const wxPoint& aPosition ) const
|
|||
return false;
|
||||
}
|
||||
|
||||
/* return true if the component is in netlist
|
||||
* which means this is not a power component, or something
|
||||
* like a component reference starting by #
|
||||
*/
|
||||
|
||||
bool SCH_COMPONENT::IsInNetlist() const
|
||||
{
|
||||
SCH_FIELD* rf = GetField( REFERENCE );
|
||||
|
@ -1901,20 +1928,17 @@ bool SCH_COMPONENT::IsInNetlist() const
|
|||
|
||||
void SCH_COMPONENT::Plot( PLOTTER* aPlotter )
|
||||
{
|
||||
LIB_COMPONENT* Entry;
|
||||
TRANSFORM temp = TRANSFORM();
|
||||
TRANSFORM temp;
|
||||
|
||||
Entry = CMP_LIBRARY::FindLibraryComponent( GetLibName() );
|
||||
|
||||
if( Entry == NULL )
|
||||
return;
|
||||
|
||||
temp = GetTransform();
|
||||
|
||||
Entry->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp );
|
||||
|
||||
for( size_t i = 0; i < m_Fields.size(); i++ )
|
||||
if( PART_SPTR part = m_part.lock() )
|
||||
{
|
||||
m_Fields[i].Plot( aPlotter );
|
||||
temp = GetTransform();
|
||||
|
||||
part->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp );
|
||||
|
||||
for( size_t i = 0; i < m_Fields.size(); i++ )
|
||||
{
|
||||
m_Fields[i].Plot( aPlotter );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,16 +34,23 @@
|
|||
#include <sch_field.h>
|
||||
#include <transform.h>
|
||||
#include <general.h>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
|
||||
class SCH_SHEET_PATH;
|
||||
class LIB_ITEM;
|
||||
class LIB_PIN;
|
||||
class LIB_COMPONENT;
|
||||
class LIB_PART;
|
||||
class NETLIST_OBJECT_LIST;
|
||||
class LIB_PART;
|
||||
class PART_LIBS;
|
||||
class SCH_COLLECTOR;
|
||||
|
||||
|
||||
/// A container for several SCH_FIELD items
|
||||
typedef std::vector<SCH_FIELD> SCH_FIELDS;
|
||||
typedef std::vector<SCH_FIELD> SCH_FIELDS;
|
||||
|
||||
typedef boost::weak_ptr<LIB_PART> PART_REF;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -54,18 +61,21 @@ class SCH_COMPONENT : public SCH_ITEM
|
|||
{
|
||||
friend class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC;
|
||||
|
||||
wxPoint m_Pos;
|
||||
wxString m_ChipName; ///< Name to look for in the library, i.e. "74LS00".
|
||||
int m_unit; ///< The unit for multiple part per package components.
|
||||
int m_convert; ///< The alternate body style for components that have more than
|
||||
///< one body style defined. Primarily used for components that
|
||||
///< have a De Morgan conversion.
|
||||
wxString m_prefix; ///< C, R, U, Q etc - the first character which typically indicates
|
||||
///< what the component is. Determined, upon placement, from the
|
||||
///< library component. Created upon file load, by the first
|
||||
///< non-digits in the reference fields.
|
||||
TRANSFORM m_transform; ///< The rotation/mirror transformation matrix.
|
||||
SCH_FIELDS m_Fields; ///< Variable length list of fields.
|
||||
wxPoint m_Pos;
|
||||
wxString m_part_name; ///< Name to look for in the library, i.e. "74LS00".
|
||||
|
||||
int m_unit; ///< The unit for multiple part per package components.
|
||||
int m_convert; ///< The alternate body style for components that have more than
|
||||
///< one body style defined. Primarily used for components that
|
||||
///< have a De Morgan conversion.
|
||||
wxString m_prefix; ///< C, R, U, Q etc - the first character which typically indicates
|
||||
///< what the component is. Determined, upon placement, from the
|
||||
///< library component. Created upon file load, by the first
|
||||
///< non-digits in the reference fields.
|
||||
TRANSFORM m_transform; ///< The rotation/mirror transformation matrix.
|
||||
SCH_FIELDS m_Fields; ///< Variable length list of fields.
|
||||
|
||||
PART_REF m_part; ///< points into the PROJECT's libraries to the LIB_PART for this component
|
||||
|
||||
/**
|
||||
* A temporary sheet path is required to generate the correct reference designator string
|
||||
|
@ -93,9 +103,8 @@ public:
|
|||
/**
|
||||
* Create schematic component from library component object.
|
||||
*
|
||||
* @param libComponent - Component library object to create schematic
|
||||
* component from.
|
||||
* @param sheet - Schematic sheet the component is place into.
|
||||
* @param aPart - library part to create schematic component from.
|
||||
* @param aSheet - Schematic sheet the component is place into.
|
||||
* @param unit - Part for components that have multiple parts per
|
||||
* package.
|
||||
* @param convert - Use the alternate body style for the schematic
|
||||
|
@ -103,7 +112,7 @@ public:
|
|||
* @param pos - Position to place new component.
|
||||
* @param setNewItemFlag - Set the component IS_NEW and IS_MOVED flags.
|
||||
*/
|
||||
SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet,
|
||||
SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* aSheet,
|
||||
int unit = 0, int convert = 0,
|
||||
const wxPoint& pos = wxPoint( 0, 0 ),
|
||||
bool setNewItemFlag = false );
|
||||
|
@ -124,9 +133,18 @@ public:
|
|||
return wxT( "SCH_COMPONENT" );
|
||||
}
|
||||
|
||||
wxString GetLibName() const { return m_ChipName; }
|
||||
void SetPartName( const wxString& aName, PART_LIBS* aLibs=NULL );
|
||||
const wxString& GetPartName() const { return m_part_name; }
|
||||
|
||||
void SetLibName( const wxString& aName );
|
||||
/**
|
||||
* Function Resolve
|
||||
* [re-]assigns the current LIB_PART from aLibs which this component
|
||||
* is based on.
|
||||
* @param aLibs is the current set of LIB_PARTs to choose from.
|
||||
*/
|
||||
bool Resolve( PART_LIBS* aLibs );
|
||||
|
||||
static void ResolveAll( const SCH_COLLECTOR& aComponents, PART_LIBS* aLibs );
|
||||
|
||||
int GetUnit() const { return m_unit; }
|
||||
|
||||
|
@ -158,12 +176,12 @@ public:
|
|||
void SetTransform( const TRANSFORM& aTransform );
|
||||
|
||||
/**
|
||||
* Function GetPartCount
|
||||
* Function GetUnitCount
|
||||
* returns the number of parts per package of the component.
|
||||
*
|
||||
* @return The number of parts per package or zero if the library entry cannot be found.
|
||||
*/
|
||||
int GetPartCount() const;
|
||||
int GetUnitCount() const;
|
||||
|
||||
bool Save( FILE* aFile ) const;
|
||||
|
||||
|
|
|
@ -90,8 +90,8 @@ const wxString SCH_FIELD::GetFullyQualifiedText() const
|
|||
wxCHECK_MSG( component != NULL, text,
|
||||
wxT( "No component associated with field" ) + text );
|
||||
|
||||
if( component->GetPartCount() > 1 )
|
||||
text << LIB_COMPONENT::SubReference( component->GetUnit() );
|
||||
if( component->GetUnitCount() > 1 )
|
||||
text << LIB_PART::SubReference( component->GetUnit() );
|
||||
}
|
||||
|
||||
return text;
|
||||
|
@ -393,8 +393,8 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint
|
|||
|
||||
text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
|
||||
|
||||
if( component->GetPartCount() > 1 )
|
||||
text << LIB_COMPONENT::SubReference( component->GetUnit() );
|
||||
if( component->GetUnitCount() > 1 )
|
||||
text << LIB_PART::SubReference( component->GetUnit() );
|
||||
}
|
||||
|
||||
match = SCH_ITEM::Matches( text, aSearchData );
|
||||
|
@ -431,8 +431,8 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
|
|||
|
||||
text = component->GetRef( (SCH_SHEET_PATH*) aAuxData );
|
||||
|
||||
// if( component->GetPartCount() > 1 )
|
||||
// text << LIB_COMPONENT::SubReference( component->GetUnit() );
|
||||
// if( component->GetUnitCount() > 1 )
|
||||
// text << LIB_PART::SubReference( component->GetUnit() );
|
||||
|
||||
isReplaced = EDA_ITEM::Replace( aSearchData, text );
|
||||
|
||||
|
@ -565,7 +565,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter )
|
|||
|
||||
int thickness = GetPenSize();
|
||||
|
||||
if( (parent->GetPartCount() <= 1) || (m_id != REFERENCE) )
|
||||
if( (parent->GetUnitCount() <= 1) || (m_id != REFERENCE) )
|
||||
{
|
||||
aPlotter->Text( textpos, color, m_Text, orient, m_Size, hjustify, vjustify,
|
||||
thickness, m_Italic, m_Bold );
|
||||
|
@ -573,7 +573,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter )
|
|||
else /* We plot the reference, for a multiple parts per package */
|
||||
{
|
||||
/* Adding A, B ... to the reference */
|
||||
wxString Text = m_Text + LIB_COMPONENT::SubReference( parent->GetUnit() );
|
||||
wxString Text = m_Text + LIB_PART::SubReference( parent->GetUnit() );
|
||||
|
||||
aPlotter->Text( textpos, color, Text, orient, m_Size, hjustify, vjustify,
|
||||
thickness, m_Italic, m_Bold );
|
||||
|
|
|
@ -74,7 +74,6 @@ static double SchematicZoomList[] =
|
|||
12.0, 16.0, 23.0, 32.0, 48.0, 64.0, 80.0, 128.0
|
||||
};
|
||||
|
||||
#define SCHEMATIC_ZOOM_LIST_CNT ( sizeof( SchematicZoomList ) / sizeof( SchematicZoomList[0] ) )
|
||||
#define MM_TO_SCH_UNITS 1000.0 / 25.4 //schematic internal unites are mils
|
||||
|
||||
|
||||
|
@ -97,20 +96,18 @@ static GRID_TYPE SchematicGridList[] = {
|
|||
{ ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) },
|
||||
};
|
||||
|
||||
#define SCHEMATIC_GRID_LIST_CNT ( sizeof( SchematicGridList ) / sizeof( GRID_TYPE ) )
|
||||
|
||||
|
||||
SCH_SCREEN::SCH_SCREEN() : BASE_SCREEN( SCH_SCREEN_T ),
|
||||
SCH_SCREEN::SCH_SCREEN( KIWAY* aKiway ) :
|
||||
BASE_SCREEN( SCH_SCREEN_T ),
|
||||
KIWAY_HOLDER( aKiway ),
|
||||
m_paper( wxT( "A4" ) )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
SetZoom( 32 );
|
||||
|
||||
for( i = 0; i < SCHEMATIC_ZOOM_LIST_CNT; i++ )
|
||||
for( unsigned i = 0; i < DIM( SchematicZoomList ); i++ )
|
||||
m_ZoomList.push_back( SchematicZoomList[i] );
|
||||
|
||||
for( i = 0; i < SCHEMATIC_GRID_LIST_CNT; i++ )
|
||||
for( unsigned i = 0; i < DIM( SchematicGridList ); i++ )
|
||||
AddGrid( SchematicGridList[i] );
|
||||
|
||||
SetGrid( wxRealPoint( 50, 50 ) ); // Default grid size.
|
||||
|
@ -169,7 +166,7 @@ void SCH_SCREEN::Remove( SCH_ITEM* aItem )
|
|||
|
||||
void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem )
|
||||
{
|
||||
wxCHECK_RET( aItem != NULL, wxT( "Cannot delete invalid item from screen." ) );
|
||||
wxCHECK_RET( aItem, wxT( "Cannot delete invalid item from screen." ) );
|
||||
|
||||
SetModify();
|
||||
|
||||
|
@ -178,7 +175,7 @@ void SCH_SCREEN::DeleteItem( SCH_ITEM* aItem )
|
|||
// This structure is attached to a sheet, get the parent sheet object.
|
||||
SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aItem;
|
||||
SCH_SHEET* sheet = sheetPin->GetParent();
|
||||
wxCHECK_RET( sheet != NULL,
|
||||
wxCHECK_RET( sheet,
|
||||
wxT( "Sheet label parent not properly set, bad programmer!" ) );
|
||||
sheet->RemovePin( sheetPin );
|
||||
return;
|
||||
|
@ -208,7 +205,7 @@ bool SCH_SCREEN::CheckIfOnDrawList( SCH_ITEM* aItem )
|
|||
|
||||
SCH_ITEM* SCH_SCREEN::GetItem( const wxPoint& aPosition, int aAccuracy, KICAD_T aType ) const
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->HitTest( aPosition, aAccuracy ) && (aType == NOT_USED) )
|
||||
return item;
|
||||
|
@ -249,7 +246,7 @@ void SCH_SCREEN::ExtractWires( DLIST< SCH_ITEM >& aList, bool aCreateCopy )
|
|||
SCH_ITEM* item;
|
||||
SCH_ITEM* next_item;
|
||||
|
||||
for( item = m_drawList.begin(); item != NULL; item = next_item )
|
||||
for( item = m_drawList.begin(); item; item = next_item )
|
||||
{
|
||||
next_item = item->Next();
|
||||
|
||||
|
@ -277,7 +274,7 @@ void SCH_SCREEN::ReplaceWires( DLIST< SCH_ITEM >& aWireList )
|
|||
SCH_ITEM* item;
|
||||
SCH_ITEM* next_item;
|
||||
|
||||
for( item = m_drawList.begin(); item != NULL; item = next_item )
|
||||
for( item = m_drawList.begin(); item; item = next_item )
|
||||
{
|
||||
next_item = item->Next();
|
||||
|
||||
|
@ -300,10 +297,10 @@ void SCH_SCREEN::ReplaceWires( DLIST< SCH_ITEM >& aWireList )
|
|||
|
||||
void SCH_SCREEN::MarkConnections( SCH_LINE* aSegment )
|
||||
{
|
||||
wxCHECK_RET( (aSegment != NULL) && (aSegment->Type() == SCH_LINE_T),
|
||||
wxCHECK_RET( (aSegment) && (aSegment->Type() == SCH_LINE_T),
|
||||
wxT( "Invalid object pointer." ) );
|
||||
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->GetFlags() & CANDIDATE )
|
||||
continue;
|
||||
|
@ -436,7 +433,7 @@ bool SCH_SCREEN::SchematicCleanUp( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
|
|||
|
||||
item = m_drawList.begin();
|
||||
|
||||
for( ; item != NULL; item = item->Next() )
|
||||
for( ; item; item = item->Next() )
|
||||
{
|
||||
if( ( item->Type() != SCH_LINE_T ) && ( item->Type() != SCH_JUNCTION_T ) )
|
||||
continue;
|
||||
|
@ -500,7 +497,7 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
|
|||
SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) < 0 )
|
||||
return false;
|
||||
|
||||
BOOST_FOREACH( const CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
|
||||
BOOST_FOREACH( const PART_LIB& lib, *Prj().SchLibs() )
|
||||
{
|
||||
if( fprintf( aFile, "LIBS:%s\n", TO_UTF8( lib.GetName() ) ) < 0 )
|
||||
return false;
|
||||
|
@ -549,13 +546,33 @@ bool SCH_SCREEN::Save( FILE* aFile ) const
|
|||
return true;
|
||||
}
|
||||
|
||||
/* note: SCH_SCREEN::Draw is useful only for schematic.
|
||||
* library editor and library viewer do not use a draw list, and therefore
|
||||
* SCH_SCREEN::Draw draws nothing
|
||||
*/
|
||||
|
||||
void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
/* note: SCH_SCREEN::Draw is useful only for schematic.
|
||||
* library editor and library viewer do not use m_drawList, and therefore
|
||||
* their SCH_SCREEN::Draw() draws nothing
|
||||
*/
|
||||
|
||||
if( m_drawList.GetCount() )
|
||||
{
|
||||
PART_LIBS* libs = Prj().SchLibs();
|
||||
int mod_hash = libs->GetModifyHash();
|
||||
|
||||
// Must we resolve?
|
||||
if( m_modification_sync != mod_hash )
|
||||
{
|
||||
SCH_TYPE_COLLECTOR c;
|
||||
|
||||
c.Collect( GetDrawItems(), SCH_COLLECTOR::ComponentsOnly );
|
||||
|
||||
SCH_COMPONENT::ResolveAll( c, libs );
|
||||
|
||||
m_modification_sync = mod_hash; // note the last mod_hash
|
||||
}
|
||||
}
|
||||
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->IsMoving() || item->IsResized() )
|
||||
continue;
|
||||
|
@ -609,7 +626,7 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
|
|||
|
||||
void SCH_SCREEN::ClearDrawingState()
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
item->ClearFlags();
|
||||
}
|
||||
|
||||
|
@ -617,11 +634,11 @@ void SCH_SCREEN::ClearDrawingState()
|
|||
LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent,
|
||||
bool aEndPointOnly ) const
|
||||
{
|
||||
SCH_ITEM* item;
|
||||
SCH_COMPONENT* component = NULL;
|
||||
LIB_PIN* pin = NULL;
|
||||
SCH_ITEM* item;
|
||||
SCH_COMPONENT* component = NULL;
|
||||
LIB_PIN* pin = NULL;
|
||||
|
||||
for( item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() != SCH_COMPONENT_T )
|
||||
continue;
|
||||
|
@ -631,12 +648,13 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
|
|||
if( aEndPointOnly )
|
||||
{
|
||||
pin = NULL;
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() );
|
||||
|
||||
if( entry == NULL )
|
||||
LIB_PART* part = Prj().SchLibs()->FindLibPart( component->GetPartName() );
|
||||
|
||||
if( !part )
|
||||
continue;
|
||||
|
||||
for( pin = entry->GetNextPin(); pin != NULL; pin = entry->GetNextPin( pin ) )
|
||||
for( pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
||||
{
|
||||
// Skip items not used for this part.
|
||||
if( component->GetUnit() && pin->GetUnit() &&
|
||||
|
@ -671,7 +689,7 @@ LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponen
|
|||
|
||||
SCH_SHEET* SCH_SCREEN::GetSheet( const wxString& aName )
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() != SCH_SHEET_T )
|
||||
continue;
|
||||
|
@ -690,7 +708,7 @@ SCH_SHEET_PIN* SCH_SCREEN::GetSheetLabel( const wxPoint& aPosition )
|
|||
{
|
||||
SCH_SHEET_PIN* sheetPin = NULL;
|
||||
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() != SCH_SHEET_T )
|
||||
continue;
|
||||
|
@ -711,7 +729,7 @@ int SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions )
|
|||
SCH_ITEM* item;
|
||||
int count = 0;
|
||||
|
||||
for( item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() == SCH_JUNCTION_T && !aTestJunctions )
|
||||
continue;
|
||||
|
@ -726,7 +744,7 @@ int SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions )
|
|||
|
||||
void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() == SCH_COMPONENT_T )
|
||||
{
|
||||
|
@ -826,7 +844,7 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position )
|
|||
ITEM_PICKER picker;
|
||||
bool addinlist = true;
|
||||
|
||||
for( item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
picker.SetItem( item );
|
||||
|
||||
|
@ -874,7 +892,7 @@ int SCH_SCREEN::UpdatePickList()
|
|||
area.SetSize( m_BlockLocate.GetSize() );
|
||||
area.Normalize();
|
||||
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
// An item is picked if its bounding box intersects the reference area.
|
||||
if( item->HitTest( area ) )
|
||||
|
@ -906,12 +924,12 @@ bool SCH_SCREEN::TestDanglingEnds( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
|
|||
std::vector< DANGLING_END_ITEM > endPoints;
|
||||
bool hasDanglingEnds = false;
|
||||
|
||||
for( item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
item->GetEndPoints( endPoints );
|
||||
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->IsDanglingStateChanged( endPoints ) && ( aCanvas != NULL ) && ( aDC != NULL ) )
|
||||
if( item->IsDanglingStateChanged( endPoints ) && ( aCanvas ) && ( aDC ) )
|
||||
{
|
||||
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
|
@ -931,7 +949,7 @@ bool SCH_SCREEN::BreakSegment( const wxPoint& aPoint )
|
|||
SCH_LINE* newSegment;
|
||||
bool brokenSegments = false;
|
||||
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( (item->Type() != SCH_LINE_T) || (item->GetLayer() == LAYER_NOTES) )
|
||||
continue;
|
||||
|
@ -958,7 +976,7 @@ bool SCH_SCREEN::BreakSegmentsOnJunctions()
|
|||
{
|
||||
bool brokenSegments = false;
|
||||
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() == SCH_JUNCTION_T )
|
||||
{
|
||||
|
@ -985,7 +1003,7 @@ bool SCH_SCREEN::BreakSegmentsOnJunctions()
|
|||
|
||||
int SCH_SCREEN::GetNode( const wxPoint& aPosition, EDA_ITEMS& aList )
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() == SCH_LINE_T && item->HitTest( aPosition )
|
||||
&& (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) )
|
||||
|
@ -1004,7 +1022,7 @@ int SCH_SCREEN::GetNode( const wxPoint& aPosition, EDA_ITEMS& aList )
|
|||
|
||||
SCH_LINE* SCH_SCREEN::GetWireOrBus( const wxPoint& aPosition )
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( (item->Type() == SCH_LINE_T) && item->HitTest( aPosition )
|
||||
&& (item->GetLayer() == LAYER_BUS || item->GetLayer() == LAYER_WIRE) )
|
||||
|
@ -1020,7 +1038,7 @@ SCH_LINE* SCH_SCREEN::GetWireOrBus( const wxPoint& aPosition )
|
|||
SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLayer,
|
||||
SCH_LINE_TEST_T aSearchType )
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() != SCH_LINE_T )
|
||||
continue;
|
||||
|
@ -1053,7 +1071,7 @@ SCH_LINE* SCH_SCREEN::GetLine( const wxPoint& aPosition, int aAccuracy, int aLay
|
|||
|
||||
SCH_TEXT* SCH_SCREEN::GetLabel( const wxPoint& aPosition, int aAccuracy )
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
switch( item->Type() )
|
||||
{
|
||||
|
@ -1078,7 +1096,7 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri
|
|||
SCH_COMPONENT* component;
|
||||
bool found = false;
|
||||
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() != SCH_COMPONENT_T )
|
||||
continue;
|
||||
|
@ -1147,7 +1165,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
|
|||
{
|
||||
SCH_LINE* segment;
|
||||
|
||||
for( item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( !(item->GetFlags() & SELECTEDNODE) )
|
||||
continue;
|
||||
|
@ -1159,7 +1177,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
|
|||
}
|
||||
|
||||
// Search all attached wires (i.e wire with one new dangling end )
|
||||
for( item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
bool noconnect = false;
|
||||
|
||||
|
@ -1178,7 +1196,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
|
|||
|
||||
/* If the wire start point is connected to a wire that was already found
|
||||
* and now is not connected, add the wire to the list. */
|
||||
for( tmp = m_drawList.begin(); tmp != NULL; tmp = tmp->Next() )
|
||||
for( tmp = m_drawList.begin(); tmp; tmp = tmp->Next() )
|
||||
{
|
||||
// Ensure tmp is a previously deleted segment:
|
||||
if( ( tmp->GetFlags() & STRUCT_DELETED ) == 0 )
|
||||
|
@ -1202,7 +1220,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
|
|||
|
||||
/* If the wire end point is connected to a wire that has already been found
|
||||
* and now is not connected, add the wire to the list. */
|
||||
for( tmp = m_drawList.begin(); tmp != NULL; tmp = tmp->Next() )
|
||||
for( tmp = m_drawList.begin(); tmp; tmp = tmp->Next() )
|
||||
{
|
||||
// Ensure tmp is a previously deleted segment:
|
||||
if( ( tmp->GetFlags() & STRUCT_DELETED ) == 0 )
|
||||
|
@ -1239,7 +1257,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
|
|||
|
||||
// Get redundant junctions (junctions which connect < 3 end wires
|
||||
// and no pin)
|
||||
for( item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->GetFlags() & STRUCT_DELETED )
|
||||
continue;
|
||||
|
@ -1261,7 +1279,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis
|
|||
}
|
||||
}
|
||||
|
||||
for( item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
if( item->GetFlags() & STRUCT_DELETED )
|
||||
continue;
|
||||
|
@ -1462,9 +1480,9 @@ void SCH_SCREENS::DeleteAllMarkers( int aMarkerType )
|
|||
SCH_MARKER* marker;
|
||||
SCH_SCREEN* screen;
|
||||
|
||||
for( screen = GetFirst(); screen != NULL; screen = GetNext() )
|
||||
for( screen = GetFirst(); screen; screen = GetNext() )
|
||||
{
|
||||
for( item = screen->GetDrawItems(); item != NULL; item = nextItem )
|
||||
for( item = screen->GetDrawItems(); item; item = nextItem )
|
||||
{
|
||||
nextItem = item->Next();
|
||||
|
||||
|
@ -1490,9 +1508,9 @@ int SCH_SCREENS::GetMarkerCount( int aMarkerType )
|
|||
SCH_SCREEN* screen;
|
||||
int count = 0;
|
||||
|
||||
for( screen = GetFirst(); screen != NULL; screen = GetNext() )
|
||||
for( screen = GetFirst(); screen; screen = GetNext() )
|
||||
{
|
||||
for( item = screen->GetDrawItems(); item != NULL; item = nextItem )
|
||||
for( item = screen->GetDrawItems(); item; item = nextItem )
|
||||
{
|
||||
nextItem = item->Next();
|
||||
|
||||
|
@ -1517,7 +1535,7 @@ void SCH_SCREEN::Show( int nestLevel, std::ostream& os ) const
|
|||
// for now, make it look like XML, expand on this later.
|
||||
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
|
||||
|
||||
for( EDA_ITEM* item = m_drawList.begin(); item != NULL; item = item->Next() )
|
||||
for( EDA_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
item->Show( nestLevel+1, os );
|
||||
}
|
||||
|
|
|
@ -768,7 +768,8 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
|
|||
}
|
||||
else
|
||||
{
|
||||
SetScreen( new SCH_SCREEN() );
|
||||
SetScreen( new SCH_SCREEN( &aFrame->Kiway() ) );
|
||||
|
||||
success = aFrame->LoadOneEEFile( m_screen, m_fileName );
|
||||
|
||||
if( success )
|
||||
|
@ -777,7 +778,7 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
|
|||
|
||||
while( bs )
|
||||
{
|
||||
if( bs->Type() == SCH_SHEET_T )
|
||||
if( bs->Type() == SCH_SHEET_T )
|
||||
{
|
||||
SCH_SHEET* sheetstruct = (SCH_SHEET*) bs;
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ SCH_ITEM* SCH_SHEET_PATH::FirstDrawList() const
|
|||
*/
|
||||
SCH_ITEM* lastItem = NULL;
|
||||
|
||||
while( item != NULL )
|
||||
while( item )
|
||||
{
|
||||
lastItem = item;
|
||||
item = item->Next();
|
||||
|
@ -242,22 +242,22 @@ void SCH_SHEET_PATH::UpdateAllScreenReferences()
|
|||
}
|
||||
|
||||
|
||||
void SCH_SHEET_PATH::AnnotatePowerSymbols( int* aReference )
|
||||
void SCH_SHEET_PATH::AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference )
|
||||
{
|
||||
int ref = 1;
|
||||
|
||||
if( aReference != NULL )
|
||||
if( aReference )
|
||||
ref = *aReference;
|
||||
|
||||
for( EDA_ITEM* item = LastDrawList(); item != NULL; item = item->Next() )
|
||||
for( EDA_ITEM* item = LastDrawList(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() != SCH_COMPONENT_T )
|
||||
continue;
|
||||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() );
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
||||
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
|
||||
|
||||
if( ( entry == NULL ) || !entry->IsPower() )
|
||||
if( !part || !part->IsPower() )
|
||||
continue;
|
||||
|
||||
wxString refstr = component->GetPrefix();
|
||||
|
@ -274,25 +274,25 @@ void SCH_SHEET_PATH::AnnotatePowerSymbols( int* aReference )
|
|||
ref++;
|
||||
}
|
||||
|
||||
if( aReference != NULL )
|
||||
if( aReference )
|
||||
*aReference = ref;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols )
|
||||
void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols )
|
||||
{
|
||||
// Search to sheet path number:
|
||||
int sheetnumber = 1; // 1 = root
|
||||
|
||||
SCH_SHEET_LIST sheetList;
|
||||
|
||||
for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path != NULL;
|
||||
path = sheetList.GetNext(), sheetnumber++ )
|
||||
for( SCH_SHEET_PATH* path = sheetList.GetFirst(); path; path = sheetList.GetNext(), sheetnumber++ )
|
||||
{
|
||||
if( Cmp(*path) == 0 )
|
||||
if( Cmp( *path ) == 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
for( SCH_ITEM* item = LastDrawList(); item != NULL; item = item->Next() )
|
||||
for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() == SCH_COMPONENT_T )
|
||||
{
|
||||
|
@ -303,14 +303,12 @@ void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aInclu
|
|||
if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
|
||||
continue;
|
||||
|
||||
LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() );
|
||||
|
||||
if( entry == NULL )
|
||||
continue;
|
||||
|
||||
SCH_REFERENCE reference = SCH_REFERENCE( component, entry, *this );
|
||||
reference.SetSheetNumber( sheetnumber );
|
||||
aReferences.AddItem( reference );
|
||||
if( LIB_PART* part = aLibs->FindLibPart( component->GetPartName() ) )
|
||||
{
|
||||
SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this );
|
||||
reference.SetSheetNumber( sheetnumber );
|
||||
aReferences.AddItem( reference );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -322,11 +320,11 @@ SCH_ITEM* SCH_SHEET_PATH::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool
|
|||
bool firstItemFound = false;
|
||||
SCH_ITEM* drawItem = LastDrawList();
|
||||
|
||||
while( drawItem != NULL )
|
||||
while( drawItem )
|
||||
{
|
||||
if( drawItem->Type() == aType )
|
||||
{
|
||||
if( aLastItem == NULL || firstItemFound )
|
||||
if( !aLastItem || firstItemFound )
|
||||
{
|
||||
return drawItem;
|
||||
}
|
||||
|
@ -338,7 +336,7 @@ SCH_ITEM* SCH_SHEET_PATH::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool
|
|||
|
||||
drawItem = drawItem->Next();
|
||||
|
||||
if( drawItem == NULL && aLastItem && aWrap && !hasWrapped )
|
||||
if( !drawItem && aLastItem && aWrap && !hasWrapped )
|
||||
{
|
||||
hasWrapped = true;
|
||||
drawItem = LastDrawList();
|
||||
|
@ -355,7 +353,7 @@ SCH_ITEM* SCH_SHEET_PATH::FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem,
|
|||
bool firstItemFound = false;
|
||||
SCH_ITEM* drawItem = FirstDrawList();
|
||||
|
||||
while( drawItem != NULL )
|
||||
while( drawItem )
|
||||
{
|
||||
if( drawItem->Type() == aType )
|
||||
{
|
||||
|
@ -503,7 +501,7 @@ SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheet( const wxString aPath, bool aHumanReada
|
|||
SCH_SHEET_PATH* sheet = GetFirst();
|
||||
wxString sheetPath;
|
||||
|
||||
while( sheet != NULL )
|
||||
while( sheet )
|
||||
{
|
||||
sheetPath = ( aHumanReadable ) ? sheet->PathHumanReadable() : sheet->Path();
|
||||
|
||||
|
@ -525,6 +523,7 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
|
|||
if( m_List == NULL )
|
||||
{
|
||||
int count = aSheet->CountSheets();
|
||||
|
||||
m_count = count;
|
||||
m_index = 0;
|
||||
m_List = new SCH_SHEET_PATH[ count ];
|
||||
|
@ -535,7 +534,7 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
|
|||
m_List[m_index] = m_currList;
|
||||
m_index++;
|
||||
|
||||
if( aSheet->GetScreen() != NULL )
|
||||
if( aSheet->GetScreen() )
|
||||
{
|
||||
EDA_ITEM* strct = m_currList.LastDrawList();
|
||||
|
||||
|
@ -557,7 +556,7 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
|
|||
|
||||
bool SCH_SHEET_LIST::IsModified()
|
||||
{
|
||||
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet != NULL; sheet = GetNext() )
|
||||
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet; sheet = GetNext() )
|
||||
{
|
||||
if( sheet->LastScreen() && sheet->LastScreen()->IsModify() )
|
||||
return true;
|
||||
|
@ -569,7 +568,7 @@ bool SCH_SHEET_LIST::IsModified()
|
|||
|
||||
bool SCH_SHEET_LIST::IsAutoSaveRequired()
|
||||
{
|
||||
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet != NULL; sheet = GetNext() )
|
||||
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet; sheet = GetNext() )
|
||||
{
|
||||
if( sheet->LastScreen() && sheet->LastScreen()->IsSave() )
|
||||
return true;
|
||||
|
@ -581,7 +580,7 @@ bool SCH_SHEET_LIST::IsAutoSaveRequired()
|
|||
|
||||
void SCH_SHEET_LIST::ClearModifyStatus()
|
||||
{
|
||||
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet != NULL; sheet = GetNext() )
|
||||
for( SCH_SHEET_PATH* sheet = GetFirst(); sheet; sheet = GetNext() )
|
||||
{
|
||||
if( sheet->LastScreen() )
|
||||
sheet->LastScreen()->ClrModify();
|
||||
|
@ -589,20 +588,20 @@ void SCH_SHEET_LIST::ClearModifyStatus()
|
|||
}
|
||||
|
||||
|
||||
void SCH_SHEET_LIST::AnnotatePowerSymbols()
|
||||
void SCH_SHEET_LIST::AnnotatePowerSymbols( PART_LIBS* aLibs )
|
||||
{
|
||||
int ref = 1;
|
||||
|
||||
for( SCH_SHEET_PATH* path = GetFirst(); path != NULL; path = GetNext() )
|
||||
path->AnnotatePowerSymbols( &ref );
|
||||
for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() )
|
||||
path->AnnotatePowerSymbols( aLibs, &ref );
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHEET_LIST::GetComponents( SCH_REFERENCE_LIST& aReferences,
|
||||
bool aIncludePowerSymbols )
|
||||
void SCH_SHEET_LIST::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
|
||||
bool aIncludePowerSymbols )
|
||||
{
|
||||
for( SCH_SHEET_PATH* path = GetFirst(); path != NULL; path = GetNext() )
|
||||
path->GetComponents( aReferences, aIncludePowerSymbols );
|
||||
for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() )
|
||||
path->GetComponents( aLibs, aReferences, aIncludePowerSymbols );
|
||||
}
|
||||
|
||||
|
||||
|
@ -611,14 +610,15 @@ SCH_ITEM* SCH_SHEET_LIST::FindNextItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFo
|
|||
{
|
||||
bool hasWrapped = false;
|
||||
bool firstItemFound = false;
|
||||
SCH_ITEM* drawItem = NULL;
|
||||
|
||||
SCH_ITEM* drawItem = NULL;
|
||||
SCH_SHEET_PATH* sheet = GetFirst();
|
||||
|
||||
while( sheet != NULL )
|
||||
while( sheet )
|
||||
{
|
||||
drawItem = sheet->LastDrawList();
|
||||
|
||||
while( drawItem != NULL )
|
||||
while( drawItem )
|
||||
{
|
||||
if( drawItem->Type() == aType )
|
||||
{
|
||||
|
@ -659,11 +659,11 @@ SCH_ITEM* SCH_SHEET_LIST::FindPreviousItem( KICAD_T aType, SCH_SHEET_PATH** aShe
|
|||
SCH_ITEM* drawItem = NULL;
|
||||
SCH_SHEET_PATH* sheet = GetLast();
|
||||
|
||||
while( sheet != NULL )
|
||||
while( sheet )
|
||||
{
|
||||
drawItem = sheet->FirstDrawList();
|
||||
|
||||
while( drawItem != NULL )
|
||||
while( drawItem )
|
||||
{
|
||||
if( drawItem->Type() == aType )
|
||||
{
|
||||
|
@ -701,7 +701,7 @@ bool SCH_SHEET_LIST::SetComponentFootprint( const wxString& aReference,
|
|||
{
|
||||
bool found = false;
|
||||
|
||||
for( SCH_SHEET_PATH* path = GetFirst(); path != NULL; path = GetNext() )
|
||||
for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() )
|
||||
found = path->SetComponentFootprint( aReference, aFootPrint, aSetVisible );
|
||||
|
||||
return found;
|
||||
|
|
|
@ -83,6 +83,7 @@ class SCH_MARKER;
|
|||
class SCH_SHEET;
|
||||
class SCH_ITEM;
|
||||
class SCH_REFERENCE_LIST;
|
||||
class PART_LIBS;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -215,7 +216,7 @@ public:
|
|||
* the annotation starts at 1. The number is incremented for
|
||||
* each power symbol annotated.
|
||||
*/
|
||||
void AnnotatePowerSymbols( int* aReference );
|
||||
void AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference );
|
||||
|
||||
/**
|
||||
* Function GetComponents
|
||||
|
@ -223,7 +224,7 @@ public:
|
|||
* @param aReferences List of references to populate.
|
||||
* @param aIncludePowerSymbols Set to false to only get normal components.
|
||||
*/
|
||||
void GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true );
|
||||
void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true );
|
||||
|
||||
/**
|
||||
* Function SetFootprintField
|
||||
|
@ -391,7 +392,7 @@ public:
|
|||
* Function AnnotatePowerSymbols
|
||||
* clear and annotates the entire hierarchy of the sheet path list.
|
||||
*/
|
||||
void AnnotatePowerSymbols();
|
||||
void AnnotatePowerSymbols( PART_LIBS* aLib );
|
||||
|
||||
/**
|
||||
* Function GetComponents
|
||||
|
@ -400,7 +401,7 @@ public:
|
|||
* @param aReferences List of references to populate.
|
||||
* @param aIncludePowerSymbols Set to false to only get normal components.
|
||||
*/
|
||||
void GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true );
|
||||
void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true );
|
||||
|
||||
/**
|
||||
* Function FindNextItem
|
||||
|
|
|
@ -192,32 +192,32 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_POPUP_SCH_BREAK_WIRE:
|
||||
{
|
||||
DLIST< SCH_ITEM > oldWires;
|
||||
|
||||
oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor.
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
screen->ExtractWires( oldWires, true );
|
||||
screen->BreakSegment( GetCrossHairPosition() );
|
||||
|
||||
if( oldWires.GetCount() != 0 )
|
||||
{
|
||||
PICKED_ITEMS_LIST oldItems;
|
||||
DLIST< SCH_ITEM > oldWires;
|
||||
|
||||
oldItems.m_Status = UR_WIRE_IMAGE;
|
||||
oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor.
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
screen->ExtractWires( oldWires, true );
|
||||
screen->BreakSegment( GetCrossHairPosition() );
|
||||
|
||||
while( oldWires.GetCount() != 0 )
|
||||
if( oldWires.GetCount() != 0 )
|
||||
{
|
||||
ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
|
||||
oldItems.PushItem( picker );
|
||||
PICKED_ITEMS_LIST oldItems;
|
||||
|
||||
oldItems.m_Status = UR_WIRE_IMAGE;
|
||||
|
||||
while( oldWires.GetCount() != 0 )
|
||||
{
|
||||
ITEM_PICKER picker = ITEM_PICKER( oldWires.PopFront(), UR_WIRE_IMAGE );
|
||||
oldItems.PushItem( picker );
|
||||
}
|
||||
|
||||
SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
|
||||
}
|
||||
|
||||
SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE );
|
||||
screen->TestDanglingEnds( m_canvas, &dc );
|
||||
}
|
||||
|
||||
screen->TestDanglingEnds( m_canvas, &dc );
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_DELETE_CMP:
|
||||
case ID_POPUP_SCH_DELETE:
|
||||
|
@ -290,14 +290,16 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
// Ensure the struct is a component (could be a piece of a component, like Field, text..)
|
||||
if( item && item->Type() == SCH_COMPONENT_T )
|
||||
{
|
||||
LIB_ALIAS* LibEntry;
|
||||
LibEntry = CMP_LIBRARY::FindLibraryEntry( ( (SCH_COMPONENT*) item )->GetLibName() );
|
||||
|
||||
if( LibEntry && LibEntry->GetDocFileName() != wxEmptyString )
|
||||
if( PART_LIBS* libs = Prj().SchLibs() )
|
||||
{
|
||||
SEARCH_STACK* lib_search = &Prj().SchSearchS();
|
||||
LIB_ALIAS* entry = libs->FindLibraryEntry( ( (SCH_COMPONENT*) item )->GetPartName() );
|
||||
|
||||
GetAssociatedDocument( this, LibEntry->GetDocFileName(), lib_search );
|
||||
if( entry && !!entry->GetDocFileName() )
|
||||
{
|
||||
SEARCH_STACK* lib_search = Prj().SchSearchS();
|
||||
|
||||
GetAssociatedDocument( this, entry->GetDocFileName(), lib_search );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <confirm.h>
|
||||
#include <base_units.h>
|
||||
#include <msgpanel.h>
|
||||
#include <html_messagebox.h>
|
||||
|
||||
#include <general.h>
|
||||
#include <eeschema_id.h>
|
||||
|
@ -60,6 +61,132 @@
|
|||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
|
||||
// non-member so it can be moved easily, and kept REALLY private.
|
||||
// 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 );
|
||||
}
|
||||
|
||||
|
||||
// non-member so it can be moved easily, and kept REALLY private.
|
||||
// Do NOT Clear() in here.
|
||||
static void add_search_paths( SEARCH_STACK* aDst, wxConfigBase* aCfg, int aIndex )
|
||||
{
|
||||
for( int i=1; true; ++i )
|
||||
{
|
||||
wxString key = wxString::Format( wxT( "LibraryPath%d" ), i );
|
||||
wxString upath = aCfg->Read( key, wxEmptyString );
|
||||
|
||||
if( !upath )
|
||||
break;
|
||||
|
||||
aDst->AddPaths( upath, aIndex );
|
||||
}
|
||||
}
|
||||
|
||||
//-----<SCH "data on demand" functions>-------------------------------------------
|
||||
|
||||
SEARCH_STACK* PROJECT::SchSearchS()
|
||||
{
|
||||
SEARCH_STACK* ss = (SEARCH_STACK*) GetElem( PROJECT::ELEM_SCH_SEARCH_STACK );
|
||||
|
||||
wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
|
||||
|
||||
if( !ss )
|
||||
{
|
||||
ss = new SEARCH_STACK();
|
||||
|
||||
// Make PROJECT the new SEARCH_STACK owner.
|
||||
SetElem( PROJECT::ELEM_SCH_SEARCH_STACK, ss );
|
||||
|
||||
// to the empty SEARCH_STACK for SchSearchS(), add project dir as first
|
||||
ss->AddPaths( m_project_name.GetPath() );
|
||||
|
||||
// next add the paths found in *.pro, variable "LibDir"
|
||||
wxString libDir;
|
||||
|
||||
try
|
||||
{
|
||||
PART_LIBS::LibNamesAndPaths( this, false, &libDir );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.errorText ) );)
|
||||
}
|
||||
|
||||
if( !!libDir )
|
||||
{
|
||||
wxArrayString paths;
|
||||
|
||||
SEARCH_STACK::Split( &paths, libDir );
|
||||
|
||||
for( unsigned i =0; i<paths.GetCount(); ++i )
|
||||
{
|
||||
wxString path = AbsolutePath( paths[i] );
|
||||
|
||||
ss->AddPaths( path ); // at the end
|
||||
}
|
||||
}
|
||||
|
||||
// append all paths from aSList
|
||||
add_search_paths( ss, Kiface().KifaceSearch(), -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( ss, Pgm().CommonSettings(), -1 );
|
||||
}
|
||||
|
||||
return ss;
|
||||
}
|
||||
|
||||
|
||||
PART_LIBS* PROJECT::SchLibs()
|
||||
{
|
||||
PART_LIBS* libs = (PART_LIBS*) GetElem( PROJECT::ELEM_SCH_PART_LIBS );
|
||||
|
||||
wxASSERT( !libs || dynamic_cast<PART_LIBS*>( libs ) );
|
||||
|
||||
if( !libs )
|
||||
{
|
||||
libs = new PART_LIBS();
|
||||
|
||||
// Make PROJECT the new PART_LIBS owner.
|
||||
SetElem( PROJECT::ELEM_SCH_PART_LIBS, libs );
|
||||
|
||||
try
|
||||
{
|
||||
libs->LoadAllLibraries( this );
|
||||
}
|
||||
catch( const PARSE_ERROR& pe )
|
||||
{
|
||||
wxString lib_list = UTF8( pe.inputLine );
|
||||
wxWindow* parent = 0; // Pgm().App().GetTopWindow();
|
||||
|
||||
// parent of this dialog cannot be NULL since that breaks the Kiway() chain.
|
||||
HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
|
||||
|
||||
dlg.MessageSet( _( "The following libraries were not found:" ) );
|
||||
|
||||
dlg.ListSet( lib_list );
|
||||
|
||||
dlg.Layout();
|
||||
|
||||
dlg.ShowModal();
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DisplayError( NULL, ioe.errorText );
|
||||
}
|
||||
}
|
||||
|
||||
return libs;
|
||||
}
|
||||
|
||||
//-----</SCH "data on demand" functions>------------------------------------------
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
||||
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, EDA_DRAW_FRAME::OnSockRequestServer )
|
||||
|
@ -96,14 +223,14 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
EVT_MENU( ID_COLORS_SETUP, SCH_EDIT_FRAME::OnColorConfig )
|
||||
EVT_TOOL( wxID_PREFERENCES, SCH_EDIT_FRAME::OnSetOptions )
|
||||
|
||||
EVT_TOOL( ID_TO_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
|
||||
EVT_TOOL( ID_RUN_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
|
||||
EVT_TOOL( ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP, SCH_EDIT_FRAME::OnOpenLibraryEditor )
|
||||
EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
|
||||
|
||||
EVT_TOOL( ID_TO_PCB, SCH_EDIT_FRAME::OnOpenPcbnew )
|
||||
EVT_TOOL( ID_TO_PCB_MODULE_EDITOR, SCH_EDIT_FRAME::OnOpenPcbModuleEditor )
|
||||
EVT_TOOL( ID_RUN_PCB, SCH_EDIT_FRAME::OnOpenPcbnew )
|
||||
EVT_TOOL( ID_RUN_PCB_MODULE_EDITOR, SCH_EDIT_FRAME::OnOpenPcbModuleEditor )
|
||||
|
||||
EVT_TOOL( ID_TO_CVPCB, SCH_EDIT_FRAME::OnOpenCvpcb )
|
||||
EVT_TOOL( ID_RUN_CVPCB, SCH_EDIT_FRAME::OnOpenCvpcb )
|
||||
|
||||
EVT_TOOL( ID_SHEET_SET, EDA_DRAW_FRAME::Process_PageSettings )
|
||||
EVT_TOOL( ID_HIERARCHY, SCH_EDIT_FRAME::Process_Special_Functions )
|
||||
|
@ -183,7 +310,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
|||
m_FrameName = SCH_EDIT_FRAME_NAME;
|
||||
m_showAxis = false; // true to show axis
|
||||
m_showBorderAndTitleBlock = true; // true to show sheet references
|
||||
m_CurrentSheet = new SCH_SHEET_PATH();
|
||||
m_CurrentSheet = new SCH_SHEET_PATH;
|
||||
m_DefaultSchematicFileName = NAMELESS_PROJECT;
|
||||
m_DefaultSchematicFileName += wxT( ".sch" );
|
||||
m_showAllPins = false;
|
||||
|
@ -270,6 +397,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
|||
|
||||
// Now Drawpanel is sized, we can use BestZoom to show the component (if any)
|
||||
GetScreen()->SetZoom( BestZoom() );
|
||||
|
||||
Zoom_Automatique( true );
|
||||
}
|
||||
|
||||
|
||||
|
@ -278,18 +407,18 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
|
|||
delete m_item_to_repeat; // we own the cloned object, see this->SetRepeatItem()
|
||||
|
||||
SetScreen( NULL );
|
||||
|
||||
delete m_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
|
||||
delete m_undoItem;
|
||||
delete g_RootSheet;
|
||||
delete m_findReplaceData;
|
||||
|
||||
m_CurrentSheet = NULL;
|
||||
m_undoItem = NULL;
|
||||
g_RootSheet = NULL;
|
||||
m_findReplaceData = NULL;
|
||||
CMP_LIBRARY::RemoveAllLibraries();
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::SetRepeatItem( SCH_ITEM* aItem )
|
||||
{
|
||||
// we cannot store a pointer to an item in the display list here since
|
||||
|
@ -326,13 +455,13 @@ void SCH_EDIT_FRAME::SetSheetNumberAndCount()
|
|||
int sheet_count = g_RootSheet->CountSheets();
|
||||
int SheetNumber = 1;
|
||||
wxString current_sheetpath = m_CurrentSheet->Path();
|
||||
SCH_SHEET_LIST SheetList;
|
||||
SCH_SHEET_LIST sheetList;
|
||||
|
||||
// Examine all sheets path to find the current sheets path,
|
||||
// and count them from root to the current sheet path:
|
||||
SCH_SHEET_PATH* sheet;
|
||||
|
||||
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
|
||||
for( sheet = sheetList.GetFirst(); sheet != NULL; sheet = sheetList.GetNext() )
|
||||
{
|
||||
wxString sheetpath = sheet->Path();
|
||||
|
||||
|
@ -376,7 +505,7 @@ void SCH_EDIT_FRAME::CreateScreens()
|
|||
|
||||
if( g_RootSheet->GetScreen() == NULL )
|
||||
{
|
||||
g_RootSheet->SetScreen( new SCH_SCREEN() );
|
||||
g_RootSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
|
||||
SetScreen( g_RootSheet->GetScreen() );
|
||||
}
|
||||
|
||||
|
@ -386,7 +515,7 @@ void SCH_EDIT_FRAME::CreateScreens()
|
|||
m_CurrentSheet->Push( g_RootSheet );
|
||||
|
||||
if( GetScreen() == NULL )
|
||||
SetScreen( new SCH_SCREEN() );
|
||||
SetScreen( new SCH_SCREEN( &Kiway() ) );
|
||||
|
||||
GetScreen()->SetZoom( 32.0 );
|
||||
GetScreen()->m_UndoRedoCountMax = 10;
|
||||
|
@ -458,13 +587,15 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
|||
return;
|
||||
}
|
||||
|
||||
SCH_SHEET_LIST SheetList;
|
||||
SCH_SHEET_LIST sheetList;
|
||||
|
||||
if( SheetList.IsModified() )
|
||||
if( sheetList.IsModified() )
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _("Save the changes in\n<%s>\nbefore closing?"),
|
||||
GetChars( g_RootSheet->GetScreen()->GetFileName() ) );
|
||||
wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
|
||||
wxString msg = wxString::Format( _(
|
||||
"Save the changes in\n'%s'\nbefore closing?"),
|
||||
GetChars( fileName )
|
||||
);
|
||||
|
||||
int ii = DisplayExitDialog( this, msg );
|
||||
|
||||
|
@ -500,7 +631,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
|||
|
||||
for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
|
||||
{
|
||||
fn = screen->GetFileName();
|
||||
fn = Prj().AbsolutePath( screen->GetFileName() );
|
||||
|
||||
// Auto save file name is the normal file name prepended with $.
|
||||
fn.SetName( wxT( "$" ) + fn.GetName() );
|
||||
|
@ -509,11 +640,15 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
|||
wxRemoveFile( fn.GetFullPath() );
|
||||
}
|
||||
|
||||
SheetList.ClearModifyStatus();
|
||||
sheetList.ClearModifyStatus();
|
||||
|
||||
if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty()
|
||||
&& (g_RootSheet->GetScreen()->GetDrawItems() != NULL) )
|
||||
UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() );
|
||||
wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
|
||||
|
||||
if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty() &&
|
||||
g_RootSheet->GetScreen()->GetDrawItems() != NULL )
|
||||
{
|
||||
UpdateFileHistory( fileName );
|
||||
}
|
||||
|
||||
g_RootSheet->GetScreen()->Clear();
|
||||
|
||||
|
@ -552,9 +687,8 @@ wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
|
|||
{
|
||||
wxFileName fn = GetScreen()->GetFileName();
|
||||
|
||||
/* Name is <root sheet filename>-<sheet path> and has no extension.
|
||||
* However if filename is too long name is <sheet filename>-<sheet number>
|
||||
*/
|
||||
// Name is <root sheet filename>-<sheet path> and has no extension.
|
||||
// However if filename is too long name is <sheet filename>-<sheet number>
|
||||
|
||||
#define FN_LEN_MAX 80 // A reasonable value for the short filename len
|
||||
|
||||
|
@ -738,22 +872,43 @@ void SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile( wxCommandEvent& event )
|
|||
|
||||
void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event )
|
||||
{
|
||||
wxFileDialog dlg( this, _( "New Schematic" ), wxGetCwd(),
|
||||
// wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
|
||||
wxString pro_dir = wxGetCwd();
|
||||
|
||||
wxFileDialog dlg( this, _( "New Schematic" ), pro_dir,
|
||||
wxEmptyString, SchematicFileWildcard,
|
||||
wxFD_SAVE );
|
||||
|
||||
if( dlg.ShowModal() != wxID_CANCEL )
|
||||
{
|
||||
OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ), 1 );
|
||||
// Enforce the extension, wxFileDialog is inept.
|
||||
wxFileName create_me = dlg.GetPath();
|
||||
create_me.SetExt( SchematicFileExtension );
|
||||
|
||||
if( create_me.FileExists() )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Schematic file '%s' already exists, use Open instead" ),
|
||||
GetChars( create_me.GetFullName() )
|
||||
);
|
||||
DisplayError( this, msg );
|
||||
return ;
|
||||
}
|
||||
|
||||
// OpenProjectFiles() requires absolute
|
||||
wxASSERT_MSG( create_me.IsAbsolute(), wxT( "wxFileDialog returned non-absolute" ) );
|
||||
|
||||
OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event )
|
||||
{
|
||||
// LoadOneEEProject( wxEmptyString, false );
|
||||
// wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
|
||||
wxString pro_dir = wxGetCwd();
|
||||
|
||||
wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(),
|
||||
wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir,
|
||||
wxEmptyString, SchematicFileWildcard,
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
||||
|
||||
|
@ -766,7 +921,7 @@ void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event )
|
|||
|
||||
void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
|
||||
|
||||
if( fn.IsOk() )
|
||||
{
|
||||
|
@ -801,7 +956,7 @@ void SCH_EDIT_FRAME::OnOpenPcbModuleEditor( wxCommandEvent& event )
|
|||
{
|
||||
if( !Kiface().IsSingle() )
|
||||
{
|
||||
wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
|
||||
|
||||
if( fn.IsOk() )
|
||||
{
|
||||
|
@ -815,32 +970,25 @@ void SCH_EDIT_FRAME::OnOpenPcbModuleEditor( wxCommandEvent& event )
|
|||
|
||||
void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
|
||||
|
||||
fn.SetExt( NetlistFileExtension );
|
||||
|
||||
if( fn.IsOk() && fn.FileExists() )
|
||||
if( Kiface().IsSingle() )
|
||||
{
|
||||
if( Kiface().IsSingle() )
|
||||
{
|
||||
ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
|
||||
|
||||
if( !player )
|
||||
{
|
||||
player = Kiway().Player( FRAME_CVPCB, true );
|
||||
player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
|
||||
player->Show( true );
|
||||
}
|
||||
player->Raise();
|
||||
}
|
||||
ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ExecuteFile( this, CVPCB_EXE );
|
||||
KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
|
||||
|
||||
if( !player )
|
||||
{
|
||||
player = Kiway().Player( FRAME_CVPCB, true );
|
||||
player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
|
||||
player->Show( true );
|
||||
}
|
||||
player->Raise();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -863,46 +1011,28 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
|
||||
|
||||
if( !libeditFrame )
|
||||
{
|
||||
libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
|
||||
libeditFrame->Show( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
// if( libeditFrame->IsIconized() )
|
||||
// libeditFrame->Iconize( false );
|
||||
}
|
||||
|
||||
libeditFrame->Raise();
|
||||
|
||||
#if 0
|
||||
if( libeditFrame )
|
||||
{
|
||||
if( libeditFrame->IsIconized() )
|
||||
libeditFrame->Iconize( false );
|
||||
|
||||
libeditFrame->Raise();
|
||||
}
|
||||
else
|
||||
{
|
||||
KIFACE_I& kf = Kiface();
|
||||
|
||||
wxWindow* w = kf.CreateWindow( this, FRAME_SCH_LIB_EDITOR, &Kiway(), kf.StartFlags() );
|
||||
libeditFrame = dynamic_cast<LIB_EDIT_FRAME*>( w );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if( component )
|
||||
{
|
||||
LIB_ALIAS* entry = CMP_LIBRARY::FindLibraryEntry( component->GetLibName() );
|
||||
if( PART_LIBS* libs = Prj().SchLibs() )
|
||||
{
|
||||
LIB_ALIAS* entry = libs->FindLibraryEntry( component->GetPartName() );
|
||||
|
||||
if( entry == NULL ) // Should not occur
|
||||
return;
|
||||
if( !entry ) // Should not occur
|
||||
return;
|
||||
|
||||
CMP_LIBRARY* library = entry->GetLibrary();
|
||||
libeditFrame->LoadComponentAndSelectLib( entry, library );
|
||||
PART_LIB* library = entry->GetLib();
|
||||
|
||||
libeditFrame->LoadComponentAndSelectLib( entry, library );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -915,21 +1045,14 @@ void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
|
|||
|
||||
void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn;
|
||||
|
||||
InvokeDialogPrintUsingPrinter( this );
|
||||
|
||||
fn = g_RootSheet->GetScreen()->GetFileName();
|
||||
wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
|
||||
|
||||
wxString default_name = NAMELESS_PROJECT wxT( ".sch" );
|
||||
|
||||
if( fn.GetFullName() != default_name )
|
||||
if( fn.GetName() != NAMELESS_PROJECT )
|
||||
{
|
||||
fn.SetExt( ProjectFileExtension );
|
||||
|
||||
// was: wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParametersList() );
|
||||
Prj().ConfigSave( Kiface().KifaceSearch(),
|
||||
fn.GetFullPath(), GROUP_SCH, GetProjectFileParametersList() );
|
||||
Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH, GetProjectFileParametersList() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -937,9 +1060,10 @@ void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
|
|||
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode,
|
||||
void* aData )
|
||||
{
|
||||
wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
|
||||
|
||||
GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );
|
||||
DrawWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS,
|
||||
GetScreen()->GetFileName() );
|
||||
DrawWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, fileName );
|
||||
}
|
||||
|
||||
|
||||
|
@ -960,9 +1084,9 @@ void SCH_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
|
|||
|
||||
bool SCH_EDIT_FRAME::isAutoSaveRequired() const
|
||||
{
|
||||
SCH_SHEET_LIST SheetList;
|
||||
SCH_SHEET_LIST sheetList;
|
||||
|
||||
return SheetList.IsAutoSaveRequired();
|
||||
return sheetList.IsAutoSaveRequired();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1078,12 +1202,9 @@ void SCH_EDIT_FRAME::UpdateTitle()
|
|||
}
|
||||
else
|
||||
{
|
||||
wxFileName fn( GetScreen()->GetFileName() );
|
||||
wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
|
||||
wxFileName fn = fileName;
|
||||
|
||||
// Often the /path/to/filedir is blank because of the FullFileName argument
|
||||
// passed to LoadOneEEFile() which omits the path on non-root schematics.
|
||||
// Making the path absolute solves this problem.
|
||||
fn.MakeAbsolute();
|
||||
title.Printf( wxT( "[ %s %s] (%s)" ),
|
||||
GetChars( fn.GetName() ),
|
||||
GetChars( m_CurrentSheet->PathHumanReadable() ),
|
||||
|
@ -1092,11 +1213,10 @@ void SCH_EDIT_FRAME::UpdateTitle()
|
|||
if( fn.FileExists() )
|
||||
{
|
||||
if( !fn.IsFileWritable() )
|
||||
title << _( " [Read Only]" );
|
||||
title += _( " [Read Only]" );
|
||||
}
|
||||
else
|
||||
title << _( " [no file]" );
|
||||
|
||||
title += _( " [no file]" );
|
||||
}
|
||||
|
||||
SetTitle( title );
|
||||
|
|
|
@ -13,54 +13,65 @@
|
|||
#include <dialog_helpers.h>
|
||||
|
||||
|
||||
CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame )
|
||||
PART_LIB* SelectLibraryFromList( EDA_DRAW_FRAME* aFrame )
|
||||
{
|
||||
static wxString OldLibName;
|
||||
wxArrayString libNamesList;
|
||||
CMP_LIBRARY* Lib = NULL;
|
||||
PROJECT& prj = aFrame->Prj();
|
||||
|
||||
int count = CMP_LIBRARY::GetLibraryCount();
|
||||
if( count == 0 )
|
||||
if( PART_LIBS* libs = prj.SchLibs() )
|
||||
{
|
||||
DisplayError( frame, _( "No component libraries are loaded." ) );
|
||||
return NULL;
|
||||
if( !libs->GetLibraryCount() )
|
||||
{
|
||||
DisplayError( aFrame, _( "No component libraries are loaded." ) );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wxArrayString headers;
|
||||
|
||||
headers.Add( wxT( "Library" ) );
|
||||
|
||||
wxArrayString libNamesList = libs->GetLibraryNames();
|
||||
|
||||
std::vector<wxArrayString> itemsToDisplay;
|
||||
|
||||
// Conversion from wxArrayString to vector of ArrayString
|
||||
for( unsigned i = 0; i < libNamesList.GetCount(); i++ )
|
||||
{
|
||||
wxArrayString item;
|
||||
|
||||
item.Add( libNamesList[i] );
|
||||
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
|
||||
wxString old_lib_name = prj.GetRString( PROJECT::SCH_LIB_SELECT );
|
||||
|
||||
EDA_LIST_DIALOG dlg( aFrame, _( "Select Library" ), headers, itemsToDisplay, old_lib_name );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return NULL;
|
||||
|
||||
wxString libname = dlg.GetTextSelection();
|
||||
|
||||
if( !libname )
|
||||
return NULL;
|
||||
|
||||
PART_LIB* lib = libs->FindLibrary( libname );
|
||||
|
||||
if( lib )
|
||||
prj.SetRString( PROJECT::SCH_LIB_SELECT, libname );
|
||||
|
||||
return lib;
|
||||
}
|
||||
|
||||
wxArrayString headers;
|
||||
headers.Add( wxT("Library") );
|
||||
|
||||
libNamesList = CMP_LIBRARY::GetLibraryNames();
|
||||
std::vector<wxArrayString> itemsToDisplay;
|
||||
|
||||
// Conversion from wxArrayString to vector of ArrayString
|
||||
for( unsigned i = 0; i < libNamesList.GetCount(); i++ )
|
||||
{
|
||||
wxArrayString item;
|
||||
item.Add( libNamesList[i] );
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
EDA_LIST_DIALOG dlg( frame, _( "Select Library" ), headers, itemsToDisplay, OldLibName );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return NULL;
|
||||
|
||||
wxString libname = dlg.GetTextSelection();
|
||||
|
||||
if( libname.IsEmpty() )
|
||||
return NULL;
|
||||
|
||||
Lib = CMP_LIBRARY::FindLibrary( libname );
|
||||
|
||||
if( Lib != NULL )
|
||||
OldLibName = libname;
|
||||
|
||||
return Lib;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern void DisplayCmpDocAndKeywords( wxString& Name );
|
||||
|
||||
void DisplayCmpDocAndKeywords( wxString& aName, void* aData );
|
||||
|
||||
|
||||
int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
|
||||
CMP_LIBRARY* Library,
|
||||
PART_LIB* Library,
|
||||
wxString& Buffer, wxString& OldName )
|
||||
{
|
||||
wxArrayString nameList;
|
||||
|
@ -86,8 +97,9 @@ int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
|
|||
item.Add( Library->GetLogicalName() );
|
||||
itemsToDisplay.push_back( item );
|
||||
}
|
||||
|
||||
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), headers, itemsToDisplay,
|
||||
OldName, DisplayCmpDocAndKeywords );
|
||||
OldName, DisplayCmpDocAndKeywords, frame->Prj().SchLibs() );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return 0;
|
||||
|
@ -98,7 +110,7 @@ int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
|
|||
}
|
||||
|
||||
|
||||
int GetNameOfPartToLoad( EDA_DRAW_FRAME* frame, CMP_LIBRARY* Library, wxString& BufName )
|
||||
int GetNameOfPartToLoad( EDA_DRAW_FRAME* frame, PART_LIB* Library, wxString& BufName )
|
||||
{
|
||||
int ii;
|
||||
static wxString OldCmpName;
|
||||
|
|
|
@ -109,12 +109,12 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
|
|||
{
|
||||
if( useScreen != NULL )
|
||||
{
|
||||
msg.Printf( _( "A file named <%s> already exists in the current schematic hierarchy." ),
|
||||
msg.Printf( _( "A file named '%s' already exists in the current schematic hierarchy." ),
|
||||
GetChars( newFullFilename ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Printf( _( "A file named <%s> already exists." ),
|
||||
msg.Printf( _( "A file named '%s' already exists." ),
|
||||
GetChars( newFullFilename ) );
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
|
|||
}
|
||||
else // New file.
|
||||
{
|
||||
aSheet->SetScreen( new SCH_SCREEN() );
|
||||
aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
|
||||
aSheet->GetScreen()->SetFileName( newFullFilename );
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue