2011-10-31 20:49:48 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2014-09-14 15:43:18 +00:00
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2011-10-31 20:49:48 +00:00
|
|
|
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file class_libentry.cpp
|
|
|
|
*/
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <plot_common.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_sch_screen.h>
|
|
|
|
#include <richio.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <template_fieldnames.h>
|
|
|
|
#include <transform.h>
|
|
|
|
#include <class_library.h>
|
|
|
|
#include <class_libentry.h>
|
|
|
|
#include <lib_pin.h>
|
|
|
|
#include <lib_arc.h>
|
|
|
|
#include <lib_bezier.h>
|
|
|
|
#include <lib_circle.h>
|
|
|
|
#include <lib_polyline.h>
|
|
|
|
#include <lib_rectangle.h>
|
|
|
|
#include <lib_text.h>
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
#include <boost/foreach.hpp>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2013-05-19 19:35:49 +00:00
|
|
|
// the separator char between the subpart id and the reference
|
|
|
|
// 0 (no separator) or '.' or some other character
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
int LIB_PART::m_subpartIdSeparator = 0;
|
|
|
|
|
2013-05-19 19:35:49 +00:00
|
|
|
// 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
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
int LIB_PART::m_subpartFirstId = 'A';
|
2013-05-19 19:35:49 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_PART* aRootPart ):
|
|
|
|
EDA_ITEM( LIB_ALIAS_T ),
|
|
|
|
shared( aRootPart )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
name = aName;
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_ALIAS::LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_PART* aRootPart ) :
|
|
|
|
EDA_ITEM( aAlias ),
|
|
|
|
shared( aRootPart )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
name = aAlias.name;
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
description = aAlias.description;
|
|
|
|
keyWords = aAlias.keyWords;
|
|
|
|
docFileName = aAlias.docFileName;
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
LIB_ALIAS::~LIB_ALIAS()
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
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() );
|
2010-10-25 15:43:42 +00:00
|
|
|
#endif
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
if( shared )
|
|
|
|
shared->RemoveAlias( this );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
const wxString LIB_ALIAS::GetLibraryName()
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
wxASSERT_MSG( shared, wxT( "LIB_ALIAS without a LIB_PART" ) );
|
|
|
|
|
|
|
|
if( shared )
|
|
|
|
return shared->GetLibraryName();
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
return wxString( _( "none" ) );
|
|
|
|
}
|
|
|
|
|
2010-10-12 10:28:30 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
bool LIB_ALIAS::IsRoot() const
|
2010-10-12 10:28:30 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
return Cmp_KEEPCASE( name, shared->GetName() ) == 0;
|
2010-10-12 10:28:30 +00:00
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
PART_LIB* LIB_ALIAS::GetLib()
|
2011-05-28 18:51:32 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
return shared->GetLib();
|
2011-05-28 18:51:32 +00:00
|
|
|
}
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
|
2011-11-11 20:10:24 +00:00
|
|
|
bool LIB_ALIAS::SaveDoc( OUTPUTFORMATTER& aFormatter )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
if( description.IsEmpty() && keyWords.IsEmpty() && docFileName.IsEmpty() )
|
2009-09-25 18:49:04 +00:00
|
|
|
return true;
|
|
|
|
|
2011-11-11 20:10:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
aFormatter.Print( 0, "#\n$CMP %s\n", TO_UTF8( name ) );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2011-11-11 20:10:24 +00:00
|
|
|
if( !description.IsEmpty() )
|
|
|
|
aFormatter.Print( 0, "D %s\n", TO_UTF8( description ) );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2011-11-11 20:10:24 +00:00
|
|
|
if( !keyWords.IsEmpty() )
|
|
|
|
aFormatter.Print( 0, "K %s\n", TO_UTF8( keyWords ) );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2011-11-11 20:10:24 +00:00
|
|
|
if( !docFileName.IsEmpty() )
|
|
|
|
aFormatter.Print( 0, "F %s\n", TO_UTF8( docFileName ) );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2011-11-11 20:10:24 +00:00
|
|
|
aFormatter.Print( 0, "$ENDCMP\n" );
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2011-11-11 20:10:24 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
return false;
|
2011-11-11 20:10:24 +00:00
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
return true;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
bool LIB_ALIAS::operator==( const wxChar* aName ) const
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
return Cmp_KEEPCASE( name, aName ) == 0;
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
bool operator<( const LIB_ALIAS& aItem1, const LIB_ALIAS& aItem2 )
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
return Cmp_KEEPCASE( aItem1.GetName(), aItem2.GetName() ) < 0;
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
int LibraryEntryCompare( const LIB_ALIAS* aItem1, const LIB_ALIAS* aItem2 )
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
return Cmp_KEEPCASE( aItem1->GetName(), aItem2->GetName() );
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
/// 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() )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
m_name = aName;
|
|
|
|
m_library = aLibrary;
|
2010-06-24 18:31:43 +00:00
|
|
|
m_dateModified = 0;
|
2010-10-25 15:43:42 +00:00
|
|
|
m_unitCount = 1;
|
2010-06-24 18:31:43 +00:00
|
|
|
m_pinNameOffset = 40;
|
2010-02-16 17:49:17 +00:00
|
|
|
m_options = ENTRY_NORMAL;
|
2012-01-22 17:20:22 +00:00
|
|
|
m_unitsLocked = false;
|
2010-06-24 18:31:43 +00:00
|
|
|
m_showPinNumbers = true;
|
|
|
|
m_showPinNames = true;
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
// Create the default alias if the name parameter is not empty.
|
2010-10-04 18:54:14 +00:00
|
|
|
if( !aName.IsEmpty() )
|
|
|
|
m_aliases.push_back( new LIB_ALIAS( aName, this ) );
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
|
|
|
|
// when the field editors are invoked.
|
2009-10-21 20:02:25 +00:00
|
|
|
LIB_FIELD* value = new LIB_FIELD( this, VALUE );
|
2013-03-18 19:36:07 +00:00
|
|
|
value->SetText( aName );
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.push_back( value );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.push_back( new LIB_FIELD( this, REFERENCE ) );
|
2010-06-17 16:30:10 +00:00
|
|
|
drawings.push_back( new LIB_FIELD( this, FOOTPRINT ) );
|
|
|
|
drawings.push_back( new LIB_FIELD( this, DATASHEET ) );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_PART::LIB_PART( LIB_PART& aPart, PART_LIB* aLibrary ) :
|
|
|
|
EDA_ITEM( aPart ),
|
|
|
|
m_me( this, null_deleter() )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* newItem;
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
m_library = aLibrary;
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
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, aPart.GetDrawItemList() )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
if( oldItem.IsNew() )
|
2009-09-25 18:49:04 +00:00
|
|
|
continue;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
newItem = (LIB_ITEM*) oldItem.Clone();
|
2009-09-25 18:49:04 +00:00
|
|
|
newItem->SetParent( this );
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.push_back( newItem );
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
2010-10-04 18:54:14 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
for( size_t i = 0; i < aPart.m_aliases.size(); i++ )
|
2010-10-04 18:54:14 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_ALIAS* alias = new LIB_ALIAS( *aPart.m_aliases[i], this );
|
2010-10-04 18:54:14 +00:00
|
|
|
m_aliases.push_back( alias );
|
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_PART::~LIB_PART()
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
#if defined(DEBUG) && 1
|
2010-10-04 18:54:14 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
if( m_aliases.size() )
|
2010-10-04 18:54:14 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
int breakhere = 1;
|
|
|
|
(void) breakhere;
|
|
|
|
}
|
2010-10-04 18:54:14 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
printf( "%s: destroying part '%s' with alias list count of %zd\n",
|
|
|
|
__func__, TO_UTF8( GetName() ), m_aliases.size() );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// If the part is being deleted directly rather than through the library,
|
|
|
|
// delete all of the aliases.
|
|
|
|
while( m_aliases.size() )
|
|
|
|
{
|
|
|
|
LIB_ALIAS* alias = m_aliases.back();
|
|
|
|
m_aliases.pop_back();
|
|
|
|
delete alias;
|
2010-10-04 18:54:14 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
const wxString LIB_PART::GetLibraryName()
|
2010-10-25 15:43:42 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
if( m_library )
|
2010-10-25 15:43:42 +00:00
|
|
|
return m_library->GetName();
|
|
|
|
|
|
|
|
return wxString( _( "none" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator )
|
2010-04-24 11:27:38 +00:00
|
|
|
{
|
|
|
|
wxString subRef;
|
2013-05-19 19:35:49 +00:00
|
|
|
|
|
|
|
if( m_subpartIdSeparator != 0 && aAddSeparator )
|
|
|
|
subRef << wxChar( m_subpartIdSeparator );
|
|
|
|
|
|
|
|
if( m_subpartFirstId >= '0' && m_subpartFirstId <= '9' )
|
|
|
|
subRef << aUnit;
|
|
|
|
else
|
|
|
|
subRef << wxChar( m_subpartFirstId + aUnit - 1);
|
|
|
|
|
2010-04-24 11:27:38 +00:00
|
|
|
return subRef;
|
|
|
|
}
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::SetName( const wxString& aName )
|
2010-10-22 12:11:52 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
m_name = aName;
|
2013-03-18 19:36:07 +00:00
|
|
|
GetValueField().SetText( aName );
|
2010-10-22 12:11:52 +00:00
|
|
|
m_aliases[0]->SetName( aName );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, int aMulti,
|
2012-09-02 12:06:47 +00:00
|
|
|
int aConvert, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor, const TRANSFORM& aTransform,
|
2010-10-20 20:24:26 +00:00
|
|
|
bool aShowPinText, bool aDrawFields, bool aOnlySelected )
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2014-02-19 16:44:48 +00:00
|
|
|
BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
GRSetDrawMode( aDc, aDrawMode );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2010-03-28 14:46:49 +00:00
|
|
|
/* draw background for filled items using background option
|
|
|
|
* Solid lines will be drawn after the background
|
|
|
|
* Note also, background is not drawn when:
|
|
|
|
* printing in black and white
|
|
|
|
* If the color is not the default color (aColor != -1 )
|
|
|
|
*/
|
2014-02-19 16:44:48 +00:00
|
|
|
if( ! (screen && screen->m_IsPrinting && GetGRForceBlackPenState())
|
2012-09-02 12:06:47 +00:00
|
|
|
&& (aColor == UNSPECIFIED_COLOR) )
|
2010-03-28 14:46:49 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& drawItem, drawings )
|
2010-03-28 14:46:49 +00:00
|
|
|
{
|
|
|
|
if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR )
|
|
|
|
continue;
|
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( aOnlySelected && !drawItem.IsSelected() )
|
2010-03-28 14:46:49 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Do not draw an item while moving (the cursor handler does that)
|
|
|
|
if( drawItem.m_Flags & IS_MOVED )
|
|
|
|
continue;
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// Do not draw items not attached to the current part
|
2010-03-28 14:46:49 +00:00
|
|
|
if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
|
|
|
|
continue;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( drawItem.Type() == LIB_FIELD_T )
|
2010-03-28 14:46:49 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( drawItem.Type() == LIB_FIELD_T )
|
2010-03-28 14:46:49 +00:00
|
|
|
{
|
2010-11-20 19:53:00 +00:00
|
|
|
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, (void*) NULL, aTransform );
|
2010-03-28 14:46:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now, draw only the background for items with
|
|
|
|
// m_Fill == FILLED_WITH_BG_BODYCOLOR:
|
2010-11-20 19:53:00 +00:00
|
|
|
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, (void*) false, aTransform );
|
2010-03-28 14:46:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& drawItem, drawings )
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( aOnlySelected && !drawItem.IsSelected() )
|
2009-09-04 18:57:37 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Do not draw an item while moving (the cursor handler does that)
|
2009-10-05 17:52:41 +00:00
|
|
|
if( drawItem.m_Flags & IS_MOVED )
|
2009-09-04 18:57:37 +00:00
|
|
|
continue;
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// Do not draw items not attached to the current part
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
|
2009-09-04 18:57:37 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
|
2009-09-04 18:57:37 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( !aDrawFields && drawItem.Type() == LIB_FIELD_T )
|
2009-10-21 20:02:25 +00:00
|
|
|
continue;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( drawItem.Type() == LIB_PIN_T )
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2010-10-20 20:24:26 +00:00
|
|
|
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, (void*) aShowPinText,
|
|
|
|
aTransform );
|
2009-09-04 18:57:37 +00:00
|
|
|
}
|
2010-12-10 19:47:44 +00:00
|
|
|
else if( drawItem.Type() == LIB_FIELD_T )
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2010-10-20 20:24:26 +00:00
|
|
|
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, (void*) NULL, aTransform );
|
2009-09-04 18:57:37 +00:00
|
|
|
}
|
2009-10-21 20:02:25 +00:00
|
|
|
else
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2010-03-28 14:46:49 +00:00
|
|
|
bool forceNoFill = drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR;
|
2010-10-20 20:24:26 +00:00
|
|
|
drawItem.Draw( aPanel, aDc, aOffset, aColor, aDrawMode, (void*) forceNoFill,
|
|
|
|
aTransform );
|
2009-09-04 18:57:37 +00:00
|
|
|
}
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
}
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// Enable this to draw the anchor of the component.
|
2009-09-17 17:48:40 +00:00
|
|
|
#if 0
|
2010-02-08 18:15:42 +00:00
|
|
|
int len = aDc->DeviceToLogicalXRel( 3 );
|
2014-02-19 16:44:48 +00:00
|
|
|
EDA_RECT* const clipbox = aPanel ? aPanel->GetClipBox() : NULL;
|
2011-01-30 22:22:38 +00:00
|
|
|
|
2014-02-19 16:44:48 +00:00
|
|
|
GRLine( clipbox, aDc, aOffset.x, aOffset.y - len, aOffset.x,
|
2009-12-15 21:11:05 +00:00
|
|
|
aOffset.y + len, 0, aColor );
|
2014-02-19 16:44:48 +00:00
|
|
|
GRLine( clipbox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len,
|
2009-12-15 21:11:05 +00:00
|
|
|
aOffset.y, 0, aColor );
|
2009-09-17 17:48:40 +00:00
|
|
|
#endif
|
2009-09-04 18:57:37 +00:00
|
|
|
|
|
|
|
/* Enable this to draw the bounding box around the component to validate
|
|
|
|
* the bounding box calculations. */
|
|
|
|
#if 0
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT bBox = GetBoundingBox( aMulti, aConvert );
|
2014-02-19 16:44:48 +00:00
|
|
|
GRRect( aPanel ? aPanel->GetClipBox() : NULL, aDc, bBox.GetOrigin().x, bBox.GetOrigin().y,
|
2009-09-04 18:57:37 +00:00
|
|
|
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
|
2010-10-20 20:24:26 +00:00
|
|
|
const wxPoint& aOffset, const TRANSFORM& aTransform )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
wxASSERT( aPlotter != NULL );
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2013-05-18 09:38:23 +00:00
|
|
|
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
|
|
|
|
bool fill = aPlotter->GetColorMode();
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2013-05-18 09:38:23 +00:00
|
|
|
// Lib Fields not are plotted here, because this plot function
|
|
|
|
// is used to plot schematic items, which have they own fields
|
|
|
|
if( item.Type() == LIB_FIELD_T )
|
|
|
|
continue;
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
|
2009-10-05 17:52:41 +00:00
|
|
|
continue;
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
|
2009-10-05 17:52:41 +00:00
|
|
|
continue;
|
|
|
|
|
2013-05-18 09:38:23 +00:00
|
|
|
item.Plot( aPlotter, aOffset, fill, aTransform );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
|
2013-05-18 09:38:23 +00:00
|
|
|
const wxPoint& aOffset, const TRANSFORM& aTransform )
|
|
|
|
{
|
|
|
|
wxASSERT( aPlotter != NULL );
|
|
|
|
|
|
|
|
aPlotter->SetColor( GetLayerColor( LAYER_FIELDS ) );
|
|
|
|
bool fill = aPlotter->GetColorMode();
|
|
|
|
|
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
|
|
|
{
|
|
|
|
if( item.Type() != LIB_FIELD_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
|
|
|
|
continue;
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2013-05-18 09:38:23 +00:00
|
|
|
if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// The reference is a special case: we shoud change the basic text
|
|
|
|
// to add '?' and the part id
|
|
|
|
LIB_FIELD& field = (LIB_FIELD&) item;
|
2014-09-13 18:15:45 +00:00
|
|
|
wxString tmp = field.GetShownText();
|
2013-05-18 09:38:23 +00:00
|
|
|
if( field.GetId() == REFERENCE )
|
|
|
|
{
|
|
|
|
wxString text = field.GetFullText( aUnit );
|
|
|
|
field.SetText( text );
|
|
|
|
}
|
2009-12-15 21:11:05 +00:00
|
|
|
item.Plot( aPlotter, aOffset, fill, aTransform );
|
2013-05-18 09:38:23 +00:00
|
|
|
field.SetText( tmp );
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc )
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
wxASSERT( aItem != NULL );
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// none of the MANDATOR_FIELDS may be removed in RAM, but they may be
|
|
|
|
// omitted when saving to disk.
|
2010-12-10 19:47:44 +00:00
|
|
|
if( aItem->Type() == LIB_FIELD_T )
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
LIB_FIELD* field = (LIB_FIELD*) aItem;
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( field->GetId() < MANDATORY_FIELDS )
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
wxLogWarning( _(
|
|
|
|
"An attempt was made to remove the %s field from component %s in library %s." ),
|
|
|
|
GetChars( field->GetName() ), GetChars( GetName() ),
|
|
|
|
GetChars( GetLibraryName() ) );
|
2009-10-21 20:02:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEMS::iterator i;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
for( i = drawings.begin(); i < drawings.end(); i++ )
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
if( *i == aItem )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2011-02-24 22:29:43 +00:00
|
|
|
if( aDc != NULL )
|
2012-09-02 12:06:47 +00:00
|
|
|
aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform );
|
2011-02-24 22:29:43 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.erase( i );
|
2011-02-24 22:29:43 +00:00
|
|
|
SetModified();
|
2009-10-21 20:02:25 +00:00
|
|
|
break;
|
2009-09-04 18:57:37 +00:00
|
|
|
}
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::AddDrawItem( LIB_ITEM* aItem )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
wxASSERT( aItem != NULL );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.push_back( aItem );
|
|
|
|
drawings.sort();
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_ITEM* LIB_PART::GetNextDrawItem( LIB_ITEM* aItem, KICAD_T aType )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2009-10-08 16:45:59 +00:00
|
|
|
/* Return the next draw object pointer.
|
|
|
|
* If item is NULL return the first item of type in the list.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
if( drawings.empty() )
|
2009-10-05 17:52:41 +00:00
|
|
|
return NULL;
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aItem == NULL && aType == TYPE_NOT_INIT ) // type is unspecified
|
|
|
|
return &drawings[0];
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-10-08 16:45:59 +00:00
|
|
|
// Search for last item
|
|
|
|
size_t idx = 0;
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aItem )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
for( ; idx < drawings.size(); idx++ )
|
2009-10-08 16:45:59 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aItem == &drawings[idx] )
|
2009-10-08 16:45:59 +00:00
|
|
|
{
|
|
|
|
idx++; // Prepare the next item search
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-10-08 16:45:59 +00:00
|
|
|
// Search the next item
|
2009-12-15 21:11:05 +00:00
|
|
|
for( ; idx < drawings.size(); idx++ )
|
2009-10-08 16:45:59 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aType == TYPE_NOT_INIT || drawings[ idx ].Type() == aType )
|
|
|
|
return &drawings[ idx ];
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
return NULL;
|
2009-09-04 18:57:37 +00:00
|
|
|
}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
|
2009-10-14 19:43:31 +00:00
|
|
|
{
|
2009-10-26 12:01:46 +00:00
|
|
|
/* Notes:
|
2009-12-15 21:11:05 +00:00
|
|
|
* when aUnit == 0: no unit filtering
|
|
|
|
* when aConvert == 0: no convert (shape selection) filtering
|
2009-10-26 12:01:46 +00:00
|
|
|
* when .m_Unit == 0, the body item is common to units
|
2009-10-26 19:00:46 +00:00
|
|
|
* when .m_Convert == 0, the body item is common to shapes
|
2009-10-26 12:01:46 +00:00
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2009-10-14 19:43:31 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( item.Type() != LIB_PIN_T ) // we search pins only
|
2009-10-26 12:01:46 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Unit filtering:
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
|
2009-10-26 12:01:46 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Shape filtering:
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
|
2009-10-14 19:43:31 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
aList.push_back( (LIB_PIN*) &item );
|
2009-10-14 19:43:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert )
|
2009-10-30 19:26:25 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
wxString pNumber;
|
|
|
|
LIB_PINS pinList;
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
GetPins( pinList, aUnit, aConvert );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
|
|
|
for( size_t i = 0; i < pinList.size(); i++ )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
wxASSERT( pinList[i]->Type() == LIB_PIN_T );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
pinList[i]->PinStringNum( pNumber );
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aNumber == pNumber )
|
2009-10-30 19:26:25 +00:00
|
|
|
return pinList[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
bool LIB_PART::Save( OUTPUTFORMATTER& aFormatter )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
LIB_FIELD& value = GetValueField();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// First line: it s a comment (component name for readers)
|
2013-03-18 19:36:07 +00:00
|
|
|
aFormatter.Print( 0, "#\n# %s\n#\n", TO_UTF8( value.GetText() ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// Save data
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, "DEF" );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2014-01-29 18:02:02 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2013-05-24 23:58:29 +00:00
|
|
|
if( value.GetText() == wxT( "R" ) )
|
|
|
|
{
|
|
|
|
int breakhere = 1;
|
|
|
|
(void) breakhere;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-12-30 18:06:12 +00:00
|
|
|
if( value.IsVisible() )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
aFormatter.Print( 0, " %s", TO_UTF8( value.GetText() ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
else
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
aFormatter.Print( 0, " ~%s", TO_UTF8( value.GetText() ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-10-21 20:02:25 +00:00
|
|
|
LIB_FIELD& reference = GetReferenceField();
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( !reference.GetText().IsEmpty() )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
aFormatter.Print( 0, " %s", TO_UTF8( reference.GetText() ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
else
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, " ~" );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, " %d %d %c %c %d %c %c\n",
|
|
|
|
0, m_pinNameOffset,
|
|
|
|
m_showPinNumbers ? 'Y' : 'N',
|
|
|
|
m_showPinNames ? 'Y' : 'N',
|
|
|
|
m_unitCount, m_unitsLocked ? 'L' : 'F',
|
|
|
|
m_options == ENTRY_POWER ? 'P' : 'N' );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
if( !SaveDateAndTime( aFormatter ) )
|
2009-09-14 13:24:17 +00:00
|
|
|
return false;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_FIELDS fields;
|
2009-10-21 20:02:25 +00:00
|
|
|
GetFields( fields );
|
|
|
|
|
2013-05-24 21:30:27 +00:00
|
|
|
// Mandatory fields:
|
2010-06-17 16:30:10 +00:00
|
|
|
// may have their own save policy so there is a separate loop for them.
|
2013-02-11 18:50:55 +00:00
|
|
|
// Empty fields are saved, because the user may have set visibility,
|
|
|
|
// size and orientation
|
2013-05-24 23:58:29 +00:00
|
|
|
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2013-02-11 18:50:55 +00:00
|
|
|
if( !fields[i].Save( aFormatter ) )
|
|
|
|
return false;
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// User defined fields:
|
|
|
|
// may have their own save policy so there is a separate loop for them.
|
|
|
|
|
|
|
|
int fieldId = MANDATORY_FIELDS; // really wish this would go away.
|
|
|
|
|
2013-05-24 23:58:29 +00:00
|
|
|
for( unsigned i = MANDATORY_FIELDS; i < fields.size(); ++i )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
|
|
|
// There is no need to save empty fields, i.e. no reason to preserve field
|
|
|
|
// names now that fields names come in dynamically through the template
|
|
|
|
// fieldnames.
|
2013-03-18 19:36:07 +00:00
|
|
|
if( !fields[i].GetText().IsEmpty() )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
fields[i].SetId( fieldId++ );
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
if( !fields[i].Save( aFormatter ) )
|
2010-06-17 16:30:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
// Save the alias list: a line starting by "ALIAS". The first alias is the root
|
|
|
|
// and has the same name as the component. In the old library file format this
|
|
|
|
// alias does not get added to the alias list.
|
|
|
|
if( m_aliases.size() > 1 )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, "ALIAS" );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2013-05-24 23:58:29 +00:00
|
|
|
for( unsigned i = 1; i < m_aliases.size(); i++ )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, " %s", TO_UTF8( m_aliases[i]->GetName() ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, "\n" );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// Write the footprint filter list
|
2009-04-05 20:49:15 +00:00
|
|
|
if( m_FootprintList.GetCount() != 0 )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, "$FPLIST\n" );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2013-05-24 23:58:29 +00:00
|
|
|
for( unsigned i = 0; i < m_FootprintList.GetCount(); i++ )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, " %s\n", TO_UTF8( m_FootprintList[i] ) );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, "$ENDFPLIST\n" );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// Save graphics items (including pins)
|
2009-12-15 21:11:05 +00:00
|
|
|
if( !drawings.empty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
/* we sort the draw items, in order to have an edition more easy,
|
|
|
|
* when a file editing "by hand" is made */
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.sort();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, "DRAW\n" );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( item.Type() == LIB_FIELD_T )
|
2009-10-21 20:02:25 +00:00
|
|
|
continue;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
if( !item.Save( aFormatter ) )
|
2009-09-14 13:24:17 +00:00
|
|
|
return false;
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, "ENDDRAW\n" );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, "ENDDEF\n" );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
bool LIB_PART::Load( LINE_READER& aLineReader, wxString& aErrorMsg )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
int unused;
|
|
|
|
char* p;
|
2009-12-15 21:11:05 +00:00
|
|
|
char* componentName;
|
2009-04-05 20:49:15 +00:00
|
|
|
char* prefix = NULL;
|
2011-10-31 20:49:48 +00:00
|
|
|
char* line;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2013-05-24 23:58:29 +00:00
|
|
|
bool result;
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString Msg;
|
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
line = aLineReader.Line();
|
|
|
|
|
|
|
|
p = strtok( line, " \t\r\n" );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
if( strcmp( p, "DEF" ) != 0 )
|
|
|
|
{
|
2011-10-31 20:49:48 +00:00
|
|
|
aErrorMsg.Printf( wxT( "DEF command expected in line %d, aborted." ),
|
|
|
|
aLineReader.LineNumber() );
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// Read DEF line:
|
2009-04-05 20:49:15 +00:00
|
|
|
char drawnum = 0;
|
|
|
|
char drawname = 0;
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
if( ( componentName = strtok( NULL, " \t\n" ) ) == NULL // Part name:
|
|
|
|
|| ( prefix = strtok( NULL, " \t\n" ) ) == NULL // Prefix name:
|
|
|
|
|| ( p = strtok( NULL, " \t\n" ) ) == NULL // NumOfPins:
|
2009-04-05 20:49:15 +00:00
|
|
|
|| sscanf( p, "%d", &unused ) != 1
|
2012-06-06 14:12:39 +00:00
|
|
|
|| ( p = strtok( NULL, " \t\n" ) ) == NULL // TextInside:
|
2010-06-24 18:31:43 +00:00
|
|
|
|| sscanf( p, "%d", &m_pinNameOffset ) != 1
|
2012-06-06 14:12:39 +00:00
|
|
|
|| ( p = strtok( NULL, " \t\n" ) ) == NULL // DrawNums:
|
2009-04-05 20:49:15 +00:00
|
|
|
|| sscanf( p, "%c", &drawnum ) != 1
|
2012-06-06 14:12:39 +00:00
|
|
|
|| ( p = strtok( NULL, " \t\n" ) ) == NULL // DrawNums:
|
2009-04-05 20:49:15 +00:00
|
|
|
|| sscanf( p, "%c", &drawname ) != 1
|
2012-06-06 14:12:39 +00:00
|
|
|
|| ( p = strtok( NULL, " \t\n" ) ) == NULL // m_unitCount:
|
2010-10-25 15:43:42 +00:00
|
|
|
|| sscanf( p, "%d", &m_unitCount ) != 1 )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-10-31 20:49:48 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Wrong DEF format in line %d, skipped." ),
|
|
|
|
aLineReader.LineNumber() );
|
|
|
|
|
2013-05-24 23:58:29 +00:00
|
|
|
while( (line = aLineReader.ReadLine()) != NULL )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2011-10-31 20:49:48 +00:00
|
|
|
p = strtok( line, " \t\n" );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( stricmp( p, "ENDDEF" ) == 0 )
|
|
|
|
break;
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
// Ensure m_unitCount is >= 1 (could be read as 0 in old libraries)
|
|
|
|
if( m_unitCount < 1 )
|
|
|
|
m_unitCount = 1;
|
2009-12-17 11:03:26 +00:00
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
m_showPinNumbers = ( drawnum == 'N' ) ? false : true;
|
|
|
|
m_showPinNames = ( drawname == 'N' ) ? false : true;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// Copy part name and prefix.
|
2009-10-21 20:02:25 +00:00
|
|
|
LIB_FIELD& value = GetValueField();
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( componentName[0] != '~' )
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
m_name = FROM_UTF8( componentName );
|
|
|
|
value.SetText( m_name );
|
2009-10-21 20:02:25 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
else
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
m_name = FROM_UTF8( &componentName[1] );
|
|
|
|
value.SetText( m_name );
|
|
|
|
value.SetVisible( false );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
// Add the root alias to the alias list.
|
2010-10-25 15:43:42 +00:00
|
|
|
m_aliases.push_back( new LIB_ALIAS( m_name, this ) );
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2009-10-21 20:02:25 +00:00
|
|
|
LIB_FIELD& reference = GetReferenceField();
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( strcmp( prefix, "~" ) == 0 )
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
reference.Empty();
|
|
|
|
reference.SetVisible( false );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
else
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
reference.SetText( FROM_UTF8( prefix ) );
|
2009-10-21 20:02:25 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
// Copy optional infos
|
|
|
|
if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'L' )
|
2010-06-24 18:31:43 +00:00
|
|
|
m_unitsLocked = true;
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'P' )
|
2010-02-16 17:49:17 +00:00
|
|
|
m_options = ENTRY_POWER;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-12-30 19:04:40 +00:00
|
|
|
// Read next lines, until "ENDDEF" is found
|
2013-05-24 23:58:29 +00:00
|
|
|
while( ( line = aLineReader.ReadLine() ) != NULL )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-10-31 20:49:48 +00:00
|
|
|
p = strtok( line, " \t\r\n" );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2013-05-24 23:58:29 +00:00
|
|
|
// This is the error flag ( if an error occurs, result = false)
|
|
|
|
result = true;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-12-30 19:04:40 +00:00
|
|
|
if( *line == '#' ) // a comment
|
|
|
|
continue;
|
|
|
|
|
2013-05-24 23:58:29 +00:00
|
|
|
if( line[0] == 'T' && line[1] == 'i' )
|
|
|
|
result = LoadDateAndTime( aLineReader );
|
2011-10-31 20:49:48 +00:00
|
|
|
else if( *line == 'F' )
|
2013-05-24 23:58:29 +00:00
|
|
|
result = LoadField( aLineReader, Msg );
|
2011-12-30 19:04:40 +00:00
|
|
|
else if( strcmp( p, "ENDDEF" ) == 0 ) // End of component description
|
2013-05-24 23:58:29 +00:00
|
|
|
goto ok;
|
2009-04-05 20:49:15 +00:00
|
|
|
else if( strcmp( p, "DRAW" ) == 0 )
|
2013-05-24 23:58:29 +00:00
|
|
|
result = LoadDrawEntries( aLineReader, Msg );
|
2009-04-05 20:49:15 +00:00
|
|
|
else if( strncmp( p, "ALIAS", 5 ) == 0 )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
p = strtok( NULL, "\r\n" );
|
2013-05-24 23:58:29 +00:00
|
|
|
result = LoadAliases( p, aErrorMsg );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
else if( strncmp( p, "$FPLIST", 5 ) == 0 )
|
2013-05-24 23:58:29 +00:00
|
|
|
result = LoadFootprints( aLineReader, Msg );
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// End line or block analysis: test for an error
|
2013-05-24 23:58:29 +00:00
|
|
|
if( !result )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2009-08-19 19:34:03 +00:00
|
|
|
if( Msg.IsEmpty() )
|
2011-10-31 20:49:48 +00:00
|
|
|
aErrorMsg.Printf( wxT( "error occurred at line %d " ), aLineReader.LineNumber() );
|
2009-04-05 20:49:15 +00:00
|
|
|
else
|
2009-12-15 21:11:05 +00:00
|
|
|
aErrorMsg.Printf( wxT( "error <%s> occurred at line %d " ),
|
2011-10-31 20:49:48 +00:00
|
|
|
GetChars( Msg ), aLineReader.LineNumber() );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2013-05-24 23:58:29 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
ok:
|
2012-06-06 14:12:39 +00:00
|
|
|
// If we are here, this part is O.k. - put it in:
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.sort();
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-12-31 09:27:19 +00:00
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
bool LIB_PART::LoadDrawEntries( LINE_READER& aLineReader, wxString& aErrorMsg )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-10-31 20:49:48 +00:00
|
|
|
char* line;
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* newEntry = NULL;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
while( true )
|
|
|
|
{
|
2013-05-24 23:58:29 +00:00
|
|
|
if( !( line = aLineReader.ReadLine() ) )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
aErrorMsg = wxT( "file ended prematurely loading component draw element" );
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
if( strncmp( line, "ENDDRAW", 7 ) == 0 )
|
2008-12-31 09:27:19 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
newEntry = NULL;
|
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
switch( line[0] )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2012-06-06 14:12:39 +00:00
|
|
|
case 'A': // Arc
|
2011-04-27 19:44:32 +00:00
|
|
|
newEntry = ( LIB_ITEM* ) new LIB_ARC( this );
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
case 'C': // Circle
|
2011-04-27 19:44:32 +00:00
|
|
|
newEntry = ( LIB_ITEM* ) new LIB_CIRCLE( this );
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
case 'T': // Text
|
2011-04-27 19:44:32 +00:00
|
|
|
newEntry = ( LIB_ITEM* ) new LIB_TEXT( this );
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
case 'S': // Square
|
2011-04-27 19:44:32 +00:00
|
|
|
newEntry = ( LIB_ITEM* ) new LIB_RECTANGLE( this );
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
case 'X': // Pin Description
|
2011-04-27 19:44:32 +00:00
|
|
|
newEntry = ( LIB_ITEM* ) new LIB_PIN( this );
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
case 'P': // Polyline
|
2011-04-27 19:44:32 +00:00
|
|
|
newEntry = ( LIB_ITEM* ) new LIB_POLYLINE( this );
|
2009-04-05 20:49:15 +00:00
|
|
|
break;
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
case 'B': // Bezier Curves
|
2011-04-27 19:44:32 +00:00
|
|
|
newEntry = ( LIB_ITEM* ) new LIB_BEZIER( this );
|
2009-08-27 19:44:13 +00:00
|
|
|
break;
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
case '#': // Comment
|
|
|
|
continue;
|
2012-06-06 14:12:39 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
default:
|
2011-10-31 20:49:48 +00:00
|
|
|
aErrorMsg.Printf( wxT( "undefined DRAW command %c" ), line[0] );
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
if( !newEntry->Load( aLineReader, aErrorMsg ) )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
aErrorMsg.Printf( wxT( "error '%s' in DRAW command %c" ),
|
2011-10-31 20:49:48 +00:00
|
|
|
GetChars( aErrorMsg ), line[0] );
|
2013-04-28 14:28:13 +00:00
|
|
|
delete newEntry;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// Flush till end of draw section
|
2009-04-05 20:49:15 +00:00
|
|
|
do
|
|
|
|
{
|
2011-10-31 20:49:48 +00:00
|
|
|
if( !aLineReader.ReadLine() )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2013-05-24 23:58:29 +00:00
|
|
|
aErrorMsg = wxT( "file ended prematurely while attempting "
|
|
|
|
"to flush to end of drawing section." );
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-10-31 20:49:48 +00:00
|
|
|
} while( strncmp( line, "ENDDRAW", 7 ) != 0 );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.push_back( newEntry );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
bool LIB_PART::LoadAliases( char* aLine, wxString& aErrorMsg )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
char* text = strtok( aLine, " \t\r\n" );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
while( text )
|
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
m_aliases.push_back( new LIB_ALIAS( FROM_UTF8( text ), this ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
text = strtok( NULL, " \t\r\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
bool LIB_PART::LoadField( LINE_READER& aLineReader, wxString& aErrorMsg )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_FIELD* field = new LIB_FIELD( this );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
if( !field->Load( aLineReader, aErrorMsg ) )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2013-04-28 14:28:13 +00:00
|
|
|
delete field;
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( field->GetId() < MANDATORY_FIELDS )
|
2009-08-19 19:34:03 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
LIB_FIELD* fixedField = GetField( field->GetId() );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
// this will fire only if somebody broke a constructor or editor.
|
2010-09-09 17:37:25 +00:00
|
|
|
// MANDATORY_FIELDS are always present in ram resident components, no
|
2010-06-17 16:30:10 +00:00
|
|
|
// exceptions, and they always have their names set, even fixed fields.
|
|
|
|
wxASSERT( fixedField );
|
|
|
|
|
|
|
|
*fixedField = *field;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( field->GetId() == VALUE )
|
2013-03-18 19:36:07 +00:00
|
|
|
m_name = field->GetText();
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2013-04-28 14:28:13 +00:00
|
|
|
delete field;
|
2009-08-19 19:34:03 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
else
|
2009-08-19 19:34:03 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.push_back( field );
|
2009-08-19 19:34:03 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
bool LIB_PART::LoadFootprints( LINE_READER& aLineReader, wxString& aErrorMsg )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-10-31 20:49:48 +00:00
|
|
|
char* line;
|
|
|
|
char* p;
|
|
|
|
|
2009-08-19 19:34:03 +00:00
|
|
|
while( true )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2013-05-24 23:58:29 +00:00
|
|
|
if( !( line = aLineReader.ReadLine() ) )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
aErrorMsg = wxT( "file ended prematurely while loading footprints" );
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
p = strtok( line, " \t\r\n" );
|
|
|
|
|
|
|
|
if( stricmp( p, "$ENDFPLIST" ) == 0 )
|
2009-08-19 19:34:03 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
m_FootprintList.Add( FROM_UTF8( p ) );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
EDA_RECT LIB_PART::GetBoundingBox( int aUnit, int aConvert ) const
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2012-05-16 16:59:47 +00:00
|
|
|
for( unsigned ii = 0; ii < drawings.size(); ii++ )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2012-05-16 16:59:47 +00:00
|
|
|
const LIB_ITEM& item = drawings[ii];
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
|
2009-12-15 21:11:05 +00:00
|
|
|
&& ( aUnit != item.m_Unit ) ) )
|
2009-09-29 18:38:21 +00:00
|
|
|
continue;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2010-09-09 17:37:25 +00:00
|
|
|
if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
|
2009-09-29 18:38:21 +00:00
|
|
|
continue;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if ( ( item.Type() == LIB_FIELD_T ) && !( ( LIB_FIELD& ) item ).IsVisible() )
|
2009-11-20 19:51:39 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
bBox.Merge( item.GetBoundingBox() );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bBox;
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
2008-12-31 15:01:29 +00:00
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
|
2011-02-27 19:54:01 +00:00
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT bBox( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
|
2011-02-27 19:54:01 +00:00
|
|
|
|
2012-05-16 16:59:47 +00:00
|
|
|
for( unsigned ii = 0; ii < drawings.size(); ii++ )
|
2011-02-27 19:54:01 +00:00
|
|
|
{
|
2012-05-16 16:59:47 +00:00
|
|
|
const LIB_ITEM& item = drawings[ii];
|
|
|
|
|
2011-02-27 19:54:01 +00:00
|
|
|
if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
|
|
|
|
&& ( aUnit != item.m_Unit ) ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ( item.Type() == LIB_FIELD_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bBox.Merge( item.GetBoundingBox() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return bBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::deleteAllFields()
|
2008-12-31 15:01:29 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEMS::iterator it;
|
2008-12-31 15:01:29 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
for( it = drawings.begin(); it!=drawings.end(); /* deleting */ )
|
2008-12-31 15:01:29 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( it->Type() != LIB_FIELD_T )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
++it;
|
2009-10-21 20:02:25 +00:00
|
|
|
continue;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// 'it' is not advanced, but should point to next in list after erase()
|
2011-03-09 14:30:39 +00:00
|
|
|
it = drawings.erase( it );
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::SetFields( const std::vector <LIB_FIELD>& aFields )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
|
|
|
deleteAllFields();
|
|
|
|
|
|
|
|
for( unsigned i=0; i<aFields.size(); ++i )
|
|
|
|
{
|
|
|
|
// drawings is a ptr_vector, new and copy an object on the heap.
|
|
|
|
LIB_FIELD* field = new LIB_FIELD( aFields[i] );
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.push_back( field );
|
2008-12-31 15:01:29 +00:00
|
|
|
}
|
|
|
|
|
2010-08-22 17:42:55 +00:00
|
|
|
// Reorder drawings: transparent polygons first, pins and text last.
|
2010-09-09 17:37:25 +00:00
|
|
|
// so texts have priority on screen.
|
2010-08-22 17:42:55 +00:00
|
|
|
drawings.sort();
|
2009-10-21 20:02:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::GetFields( LIB_FIELDS& aList )
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
LIB_FIELD* field;
|
|
|
|
|
|
|
|
// The only caller of this function is the library field editor, so it
|
|
|
|
// establishes policy here.
|
|
|
|
|
|
|
|
// Grab the MANDATORY_FIELDS first, in expected order given by
|
|
|
|
// enum NumFieldType
|
|
|
|
for( int id=0; id<MANDATORY_FIELDS; ++id )
|
|
|
|
{
|
|
|
|
field = GetField( id );
|
|
|
|
|
|
|
|
// the MANDATORY_FIELDS are exactly that in RAM.
|
|
|
|
wxASSERT( field );
|
|
|
|
|
|
|
|
aList.push_back( *field );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now grab all the rest of fields.
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2008-12-31 15:01:29 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( item.Type() != LIB_FIELD_T )
|
2009-10-21 20:02:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
field = ( LIB_FIELD* ) &item;
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( (unsigned) field->GetId() < MANDATORY_FIELDS )
|
2010-06-17 16:30:10 +00:00
|
|
|
continue; // was added above
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
aList.push_back( *field );
|
2008-12-31 15:01:29 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_FIELD* LIB_PART::GetField( int aId )
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( item.Type() != LIB_FIELD_T )
|
2009-10-21 20:02:25 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
LIB_FIELD* field = ( LIB_FIELD* ) &item;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( field->GetId() == aId )
|
2009-10-21 20:02:25 +00:00
|
|
|
return field;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( item.Type() != LIB_FIELD_T )
|
2010-06-17 16:30:10 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
LIB_FIELD* field = ( LIB_FIELD* ) &item;
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( field->GetName() == aFieldName )
|
2010-06-17 16:30:10 +00:00
|
|
|
return field;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_FIELD& LIB_PART::GetValueField()
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
|
|
|
LIB_FIELD* field = GetField( VALUE );
|
|
|
|
wxASSERT( field != NULL );
|
|
|
|
return *field;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_FIELD& LIB_PART::GetReferenceField()
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
|
|
|
LIB_FIELD* field = GetField( REFERENCE );
|
|
|
|
wxASSERT( field != NULL );
|
|
|
|
return *field;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
bool LIB_PART::SaveDateAndTime( OUTPUTFORMATTER& aFormatter )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
int year, mon, day, hour, min, sec;
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
if( m_dateModified == 0 )
|
2009-04-05 20:49:15 +00:00
|
|
|
return true;
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
sec = m_dateModified & 63;
|
|
|
|
min = ( m_dateModified >> 6 ) & 63;
|
|
|
|
hour = ( m_dateModified >> 12 ) & 31;
|
|
|
|
day = ( m_dateModified >> 17 ) & 31;
|
|
|
|
mon = ( m_dateModified >> 22 ) & 15;
|
|
|
|
year = ( m_dateModified >> 26 ) + 1990;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
aFormatter.Print( 0, "Ti %d/%d/%d %d:%d:%d\n", year, mon, day, hour, min, sec );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-11-01 15:06:26 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
bool LIB_PART::LoadDateAndTime( char* aLine )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
int year, mon, day, hour, min, sec;
|
|
|
|
|
|
|
|
year = mon = day = hour = min = sec = 0;
|
2011-05-13 13:15:28 +00:00
|
|
|
strtok( aLine, " \r\t\n" );
|
|
|
|
strtok( NULL, " \r\t\n" );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-10-31 20:49:48 +00:00
|
|
|
if( sscanf( aLine, "%d/%d/%d %d:%d:%d", &year, &mon, &day, &hour, &min, &sec ) != 6 )
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
|
|
|
|
2010-06-24 18:31:43 +00:00
|
|
|
m_dateModified = ( sec & 63 ) + ( ( min & 63 ) << 6 ) +
|
2011-10-31 20:49:48 +00:00
|
|
|
( ( hour & 31 ) << 12 ) + ( ( day & 31 ) << 17 ) +
|
|
|
|
( ( mon & 15 ) << 22 ) + ( ( year - 1990 ) << 26 );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::SetOffset( const wxPoint& aOffset )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
item.SetOffset( aOffset );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::RemoveDuplicateDrawItems()
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.unique();
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
bool LIB_PART::HasConversion() const
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2012-05-16 16:59:47 +00:00
|
|
|
for( unsigned ii = 0; ii < drawings.size(); ii++ )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2012-05-16 16:59:47 +00:00
|
|
|
const LIB_ITEM& item = drawings[ii];
|
2009-10-05 17:52:41 +00:00
|
|
|
if( item.m_Convert > 1 )
|
2009-09-14 13:24:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::ClearStatus()
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
2009-10-05 17:52:41 +00:00
|
|
|
item.m_Flags = 0;
|
2011-05-20 18:29:35 +00:00
|
|
|
}
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
int LIB_PART::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aEditPinByPin )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
int itemCount = 0;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
item.ClearFlags( SELECTED );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( ( item.m_Unit && item.m_Unit != aUnit )
|
|
|
|
|| ( item.m_Convert && item.m_Convert != aConvert ) )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( item.Type() != LIB_PIN_T )
|
2009-09-25 18:49:04 +00:00
|
|
|
continue;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
// Specific rules for pins.
|
2010-06-24 18:31:43 +00:00
|
|
|
if( aEditPinByPin || m_unitsLocked
|
2009-12-15 21:11:05 +00:00
|
|
|
|| ( item.m_Convert && item.m_Convert != aConvert ) )
|
2009-09-25 18:49:04 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( item.Inside( aRect ) )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
item.SetFlags( SELECTED );
|
2009-12-15 21:11:05 +00:00
|
|
|
itemCount++;
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
return itemCount;
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::MoveSelectedItems( const wxPoint& aOffset )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item.IsSelected() )
|
2009-09-25 18:49:04 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
item.SetOffset( aOffset );
|
2011-12-21 13:42:02 +00:00
|
|
|
item.m_Flags = 0;
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.sort();
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::ClearSelectedItems()
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2011-12-21 13:42:02 +00:00
|
|
|
{
|
|
|
|
item.m_Flags = 0;
|
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::DeleteSelectedItems()
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEMS::iterator item = drawings.begin();
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2010-03-08 19:21:44 +00:00
|
|
|
// We *do not* remove the 2 mandatory fields: reference and value
|
|
|
|
// so skip them (do not remove) if they are flagged selected.
|
2010-03-09 09:51:22 +00:00
|
|
|
// Skip also not visible items.
|
2010-09-09 17:37:25 +00:00
|
|
|
// But I think fields must not be deleted by a block delete command or other global command
|
2010-03-09 09:51:22 +00:00
|
|
|
// because they are not really graphic items
|
2010-03-08 19:21:44 +00:00
|
|
|
while( item != drawings.end() )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( item->Type() == LIB_FIELD_T )
|
2010-03-08 19:21:44 +00:00
|
|
|
{
|
2010-03-09 09:51:22 +00:00
|
|
|
#if 0 // Set to 1 to allows fields deletion on block delete or other global command
|
2010-03-08 19:21:44 +00:00
|
|
|
LIB_FIELD& field = ( LIB_FIELD& ) *item;
|
2011-12-21 13:42:02 +00:00
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
if( (field.GetId() == REFERENCE) || (field.m_FieldId == VALUE) ||
|
2010-03-09 09:51:22 +00:00
|
|
|
(field.m_Attributs & TEXT_NO_VISIBLE) )
|
|
|
|
#endif
|
2011-12-21 13:42:02 +00:00
|
|
|
item->ClearFlags( SELECTED );
|
2010-03-08 19:21:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item->IsSelected() )
|
2010-03-08 19:21:44 +00:00
|
|
|
item++;
|
2009-10-05 17:52:41 +00:00
|
|
|
else
|
2010-03-08 19:21:44 +00:00
|
|
|
item = drawings.erase( item );
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::CopySelectedItems( const wxPoint& aOffset )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2010-02-20 14:49:14 +00:00
|
|
|
/* *do not* use iterators here, because new items
|
|
|
|
* are added to drawings that is a boost::ptr_vector.
|
|
|
|
* When push_back elements in buffer,
|
|
|
|
* a memory reallocation can happen and will break pointers
|
|
|
|
*/
|
|
|
|
unsigned icnt = drawings.size();
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2010-02-20 14:49:14 +00:00
|
|
|
for( unsigned ii = 0; ii < icnt; ii++ )
|
2009-09-25 18:49:04 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM& item = drawings[ii];
|
2011-12-21 13:42:02 +00:00
|
|
|
|
2010-03-08 19:21:44 +00:00
|
|
|
// We *do not* copy fields because they are unique for the whole component
|
|
|
|
// so skip them (do not duplicate) if they are flagged selected.
|
2010-12-10 19:47:44 +00:00
|
|
|
if( item.Type() == LIB_FIELD_T )
|
2011-12-21 13:42:02 +00:00
|
|
|
item.ClearFlags( SELECTED );
|
2010-03-08 19:21:44 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item.IsSelected() )
|
2009-09-25 18:49:04 +00:00
|
|
|
continue;
|
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
item.ClearFlags( SELECTED );
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
|
2011-12-21 13:42:02 +00:00
|
|
|
newItem->SetFlags( SELECTED );
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.push_back( newItem );
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
MoveSelectedItems( aOffset );
|
|
|
|
drawings.sort();
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
|
2010-03-01 19:52:40 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::MirrorSelectedItemsH( const wxPoint& aCenter )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item.IsSelected() )
|
2009-09-29 18:38:21 +00:00
|
|
|
continue;
|
|
|
|
|
2010-03-01 19:52:40 +00:00
|
|
|
item.MirrorHorizontal( aCenter );
|
2011-12-21 13:42:02 +00:00
|
|
|
item.m_Flags = 0;
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.sort();
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::MirrorSelectedItemsV( const wxPoint& aCenter )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item.IsSelected() )
|
2011-05-20 18:29:35 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
item.MirrorVertical( aCenter );
|
2011-12-21 13:42:02 +00:00
|
|
|
item.m_Flags = 0;
|
2011-05-20 18:29:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
drawings.sort();
|
|
|
|
}
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::RotateSelectedItems( const wxPoint& aCenter )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
|
|
|
{
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item.IsSelected() )
|
2011-05-20 18:29:35 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
item.Rotate( aCenter );
|
2011-12-21 13:42:02 +00:00
|
|
|
item.m_Flags = 0;
|
2011-05-20 18:29:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
drawings.sort();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert,
|
2011-04-27 19:44:32 +00:00
|
|
|
KICAD_T aType, const wxPoint& aPoint )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
if( ( aUnit && item.m_Unit && ( aUnit != item.m_Unit) )
|
|
|
|
|| ( aConvert && item.m_Convert && ( aConvert != item.m_Convert ) )
|
|
|
|
|| ( ( item.Type() != aType ) && ( aType != TYPE_NOT_INIT ) ) )
|
2009-09-29 18:38:21 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( item.HitTest( aPoint ) )
|
2009-10-05 17:52:41 +00:00
|
|
|
return &item;
|
2009-09-29 18:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
|
2011-04-27 19:44:32 +00:00
|
|
|
const wxPoint& aPoint, const TRANSFORM& aTransform )
|
2009-10-06 13:52:43 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
/* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const
|
2009-10-19 19:00:47 +00:00
|
|
|
* wxPoint& pt ) to search items.
|
2011-05-05 17:45:35 +00:00
|
|
|
* because this function uses DefaultTransform as orient/mirror matrix
|
|
|
|
* we temporary copy aTransform in DefaultTransform
|
2009-10-19 19:00:47 +00:00
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* item;
|
2010-12-23 10:00:55 +00:00
|
|
|
TRANSFORM transform = DefaultTransform;
|
2010-12-23 10:53:12 +00:00
|
|
|
DefaultTransform = aTransform;
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
item = LocateDrawItem( aUnit, aConvert, aType, aPoint );
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2013-05-24 23:58:29 +00:00
|
|
|
// Restore matrix
|
2010-12-23 10:00:55 +00:00
|
|
|
DefaultTransform = transform;
|
2009-10-08 16:45:59 +00:00
|
|
|
|
2009-10-06 13:52:43 +00:00
|
|
|
return item;
|
|
|
|
}
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-10-19 19:00:47 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::SetUnitCount( int aCount )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
if( m_unitCount == aCount )
|
2009-10-05 17:52:41 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
if( aCount < m_unitCount )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEMS::iterator i;
|
2009-12-15 21:11:05 +00:00
|
|
|
i = drawings.begin();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
while( i != drawings.end() )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
if( i->m_Unit > aCount )
|
|
|
|
i = drawings.erase( i );
|
2009-10-05 17:52:41 +00:00
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
int prevCount = m_unitCount;
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-12-17 11:03:26 +00:00
|
|
|
// We cannot use an iterator here, because when adding items in vector
|
|
|
|
// the buffer can be reallocated, that change the previous value of
|
|
|
|
// .begin() and .end() iterators and invalidate others iterators
|
|
|
|
unsigned imax = drawings.size();
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2009-12-17 11:03:26 +00:00
|
|
|
for( unsigned ii = 0; ii < imax; ii++ )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2009-12-17 11:03:26 +00:00
|
|
|
if( drawings[ii].m_Unit != 1 )
|
2009-10-05 17:52:41 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
for( int j = prevCount + 1; j <= aCount; j++ )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* newItem = (LIB_ITEM*) drawings[ii].Clone();
|
2009-10-05 17:52:41 +00:00
|
|
|
newItem->m_Unit = j;
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.push_back( newItem );
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.sort();
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
|
2010-10-25 15:43:42 +00:00
|
|
|
m_unitCount = aCount;
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::SetConversion( bool aSetConvert )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aSetConvert == HasConversion() )
|
2009-10-05 17:52:41 +00:00
|
|
|
return;
|
2009-12-15 21:11:05 +00:00
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
// Duplicate items to create the converted shape
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aSetConvert )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
BOOST_FOREACH( LIB_ITEM& item, drawings )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2012-06-06 14:12:39 +00:00
|
|
|
// Only pins are duplicated.
|
2010-12-10 19:47:44 +00:00
|
|
|
if( item.Type() != LIB_PIN_T )
|
2009-10-05 17:52:41 +00:00
|
|
|
continue;
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
if( item.m_Convert == 1 )
|
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
|
2009-10-05 17:52:41 +00:00
|
|
|
newItem->m_Convert = 2;
|
2009-12-15 21:11:05 +00:00
|
|
|
drawings.push_back( newItem );
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-17 11:03:26 +00:00
|
|
|
// Delete converted shape items because the converted shape does
|
2009-10-19 19:00:47 +00:00
|
|
|
// not exist
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEMS::iterator i = drawings.begin();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
while( i != drawings.end() )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
|
|
|
if( i->m_Convert > 1 )
|
2009-12-15 21:11:05 +00:00
|
|
|
i = drawings.erase( i );
|
2009-10-05 17:52:41 +00:00
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-17 13:22:25 +00:00
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
wxArrayString LIB_PART::GetAliasNames( bool aIncludeRoot ) const
|
2010-02-17 13:22:25 +00:00
|
|
|
{
|
2010-10-04 18:54:14 +00:00
|
|
|
wxArrayString names;
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ALIASES::const_iterator it;
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
for( it=m_aliases.begin(); it<m_aliases.end(); ++it )
|
2010-02-17 13:22:25 +00:00
|
|
|
{
|
2010-10-04 18:54:14 +00:00
|
|
|
if( !aIncludeRoot && (*it)->IsRoot() )
|
2010-02-17 13:22:25 +00:00
|
|
|
continue;
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
names.Add( (*it)->GetName() );
|
2010-02-17 13:22:25 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
return names;
|
2010-02-17 13:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
bool LIB_PART::HasAlias( const wxString& aName ) const
|
2010-02-17 13:22:25 +00:00
|
|
|
{
|
2010-10-04 18:54:14 +00:00
|
|
|
wxCHECK2_MSG( !aName.IsEmpty(), return false,
|
|
|
|
wxT( "Cannot get alias with an empty name, bad programmer." ) );
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
for( size_t i = 0; i < m_aliases.size(); i++ )
|
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
if( Cmp_KEEPCASE( aName, m_aliases[i]->GetName() ) == 0 )
|
2010-10-04 18:54:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-02-17 13:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::SetAliases( const wxArrayString& aAliasList )
|
2010-02-17 13:22:25 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
wxCHECK_RET( !m_library,
|
|
|
|
wxT( "Part aliases cannot be changed when they are owned by a library." ) );
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
if( aAliasList == GetAliasNames() )
|
|
|
|
return;
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
// Add names not existing in the current component alias list.
|
|
|
|
for( size_t i = 0; i < aAliasList.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
if( HasAlias( aAliasList[ i ] ) )
|
|
|
|
continue;
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
m_aliases.push_back( new LIB_ALIAS( aAliasList[ i ], this ) );
|
|
|
|
}
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2012-06-06 14:12:39 +00:00
|
|
|
// Remove names in the current component that are not in the new alias list.
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ALIASES::iterator it;
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
for( it = m_aliases.begin(); it < m_aliases.end(); it++ )
|
|
|
|
{
|
|
|
|
int index = aAliasList.Index( (*it)->GetName(), false );
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
if( index != wxNOT_FOUND || (*it)->IsRoot() )
|
|
|
|
continue;
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
it = m_aliases.erase( it );
|
|
|
|
}
|
2010-02-17 13:22:25 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
#if 0 // this version looked suspect to me, it did not rename a deleted root
|
|
|
|
|
|
|
|
void LIB_PART::RemoveAlias( const wxString& aName )
|
2010-02-17 13:22:25 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
wxCHECK_RET( m_library == NULL,
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
wxT( "Part aliases cannot be changed when they are owned by a library." ) );
|
2010-10-04 18:54:14 +00:00
|
|
|
wxCHECK_RET( !aName.IsEmpty(), wxT( "Cannot get alias with an empty name." ) );
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ALIASES::iterator it;
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
for( it = m_aliases.begin(); it < m_aliases.end(); it++ )
|
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
if( Cmp_KEEPCASE( aName, (*it)->GetName() ) == 0 )
|
2010-10-04 18:54:14 +00:00
|
|
|
{
|
|
|
|
m_aliases.erase( it );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-02-17 13:22:25 +00:00
|
|
|
}
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
#else
|
|
|
|
void LIB_PART::RemoveAlias( const wxString& aName )
|
|
|
|
{
|
|
|
|
LIB_ALIAS* a = GetAlias( aName );
|
|
|
|
|
|
|
|
if( a )
|
|
|
|
RemoveAlias( a );
|
|
|
|
}
|
|
|
|
#endif
|
2010-10-04 18:54:14 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
LIB_ALIAS* LIB_PART::RemoveAlias( LIB_ALIAS* aAlias )
|
2010-02-17 13:22:25 +00:00
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
wxCHECK_MSG( aAlias, NULL, wxT( "Cannot remove alias by NULL pointer." ) );
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
LIB_ALIAS* nextAlias = NULL;
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ALIASES::iterator it = find( m_aliases.begin(), m_aliases.end(), aAlias );
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
if( it != m_aliases.end() )
|
|
|
|
{
|
|
|
|
bool rename = aAlias->IsRoot();
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
DBG( printf( "%s: part:'%s' alias:'%s'\n", __func__,
|
|
|
|
TO_UTF8( m_name ),
|
|
|
|
TO_UTF8( aAlias->GetName() )
|
|
|
|
);)
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
it = m_aliases.erase( it );
|
|
|
|
|
|
|
|
if( !m_aliases.empty() )
|
|
|
|
{
|
|
|
|
if( it == m_aliases.end() )
|
|
|
|
it = m_aliases.begin();
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
nextAlias = *it;
|
2010-10-04 18:54:14 +00:00
|
|
|
|
|
|
|
if( rename )
|
|
|
|
SetName( nextAlias->GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nextAlias;
|
2010-02-17 13:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::RemoveAllAliases()
|
2010-12-02 21:41:56 +00:00
|
|
|
{
|
|
|
|
// Remove all of the aliases except the root alias.
|
|
|
|
while( m_aliases.size() > 1 )
|
|
|
|
m_aliases.pop_back();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_ALIAS* LIB_PART::GetAlias( const wxString& aName )
|
2010-02-17 13:22:25 +00:00
|
|
|
{
|
2010-10-04 18:54:14 +00:00
|
|
|
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++ )
|
|
|
|
{
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
if( Cmp_KEEPCASE( aName, m_aliases[i]->GetName() ) == 0 )
|
2010-10-04 18:54:14 +00:00
|
|
|
return m_aliases[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2010-02-17 13:22:25 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
LIB_ALIAS* LIB_PART::GetAlias( size_t aIndex )
|
2010-02-17 13:22:25 +00:00
|
|
|
{
|
2010-10-04 18:54:14 +00:00
|
|
|
wxCHECK2_MSG( aIndex < m_aliases.size(), return NULL,
|
|
|
|
wxT( "Illegal alias list index, bad programmer." ) );
|
2010-09-09 17:37:25 +00:00
|
|
|
|
2010-10-04 18:54:14 +00:00
|
|
|
return m_aliases[aIndex];
|
2010-02-17 13:22:25 +00:00
|
|
|
}
|
2010-12-02 21:41:56 +00:00
|
|
|
|
|
|
|
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::AddAlias( const wxString& aName )
|
2010-12-02 21:41:56 +00:00
|
|
|
{
|
|
|
|
wxCHECK_RET( !HasAlias( aName ),
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
wxT( "Part <" ) + GetName() + wxT( "> already has an alias <" ) +
|
2010-12-02 21:41:56 +00:00
|
|
|
aName + wxT( ">. Bad programmer." ) );
|
|
|
|
|
|
|
|
m_aliases.push_back( new LIB_ALIAS( aName, this ) );
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** Set the separator char between the subpart id and the reference
|
|
|
|
* 0 (no separator) or '.' , '-' and '_'
|
|
|
|
* and the ascii char value to calculate the subpart symbol id from the part number:
|
|
|
|
* 'A' or '1' only are allowed. (to print U1.A or U1.1)
|
|
|
|
* if this is a digit, a number is used as id symbol
|
|
|
|
* Note also if the subpart symbol is a digit, the separator cannot be null.
|
|
|
|
* @param aSep = the separator symbol (0 (no separator) or '.' , '-' and '_')
|
|
|
|
* @param aFirstId = the Id of the first part ('A' or '1')
|
|
|
|
*/
|
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.
2014-08-13 20:28:54 +00:00
|
|
|
void LIB_PART::SetSubpartIdNotation( int aSep, int aFirstId )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
m_subpartFirstId = 'A';
|
|
|
|
m_subpartIdSeparator = 0;
|
|
|
|
|
|
|
|
if( aSep == '.' || aSep == '-' || aSep == '_' )
|
|
|
|
m_subpartIdSeparator = aSep;
|
|
|
|
|
|
|
|
if( aFirstId == '1' && aSep != 0 )
|
|
|
|
m_subpartFirstId = aFirstId;
|
|
|
|
}
|