2011-10-31 20:49:48 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-01-27 18:40:52 +00:00
|
|
|
* Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-09-21 12:58:08 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2017-01-27 15:56:36 +00:00
|
|
|
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-31 20:49:48 +00:00
|
|
|
*
|
|
|
|
* 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>
|
2018-01-28 18:12:26 +00:00
|
|
|
#include <plotter.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
2018-01-30 08:56:43 +00:00
|
|
|
#include <sch_screen.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#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-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
|
|
|
|
2017-09-21 12:58:08 +00:00
|
|
|
const wxChar traceSchLibMem[] = wxT( "KICAD_TRACE_SCH_LIB_MEM" ); // public
|
2015-02-06 15:34:11 +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
|
|
|
{
|
2018-01-09 08:50:31 +00:00
|
|
|
wxLogTrace( traceSchLibMem, wxT( "%s: destroying alias:'%s'" ),
|
|
|
|
GetChars( wxString::FromAscii( __WXFUNCTION__ ) ), GetChars( GetName() ) );
|
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
|
|
|
|
2018-01-09 08:50:31 +00:00
|
|
|
wxCHECK_RET( shared, wxT( "~LIB_ALIAS() without a LIB_PART" ) );
|
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
|
|
|
{
|
2016-06-11 03:15:02 +00:00
|
|
|
return name == shared->GetName();
|
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
|
|
|
|
|
|
|
bool LIB_ALIAS::operator==( const wxChar* aName ) const
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2016-06-11 03:15:02 +00:00
|
|
|
return name == aName;
|
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
|
|
|
{
|
2016-06-11 03:15:02 +00:00
|
|
|
return aItem1.GetName() < aItem2.GetName();
|
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
|
|
|
{
|
2016-06-11 03:15:02 +00:00
|
|
|
return aItem1->GetName().Cmp( 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
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-01 16:49: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( const wxString& aName, PART_LIB* aLibrary ) :
|
|
|
|
EDA_ITEM( LIB_PART_T ),
|
2017-09-17 08:26:06 +00:00
|
|
|
m_me( this, null_deleter() )
|
2008-12-31 09:27:19 +00:00
|
|
|
{
|
2017-12-14 16:24:29 +00:00
|
|
|
m_dateLastEdition = 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
|
|
|
|
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.
|
2017-11-12 20:49:38 +00:00
|
|
|
m_drawings[LIB_FIELD_T].push_back( new LIB_FIELD( this, VALUE ) );
|
2017-09-17 08:26:06 +00:00
|
|
|
m_drawings[LIB_FIELD_T].push_back( new LIB_FIELD( this, REFERENCE ) );
|
|
|
|
m_drawings[LIB_FIELD_T].push_back( new LIB_FIELD( this, FOOTPRINT ) );
|
|
|
|
m_drawings[LIB_FIELD_T].push_back( new LIB_FIELD( this, DATASHEET ) );
|
2017-11-12 20:49:38 +00:00
|
|
|
|
2017-11-12 19:54:04 +00:00
|
|
|
SetLib( aLibrary );
|
2017-11-12 20:49:38 +00:00
|
|
|
SetName( aName );
|
2008-12-31 09:27:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-18 00:15:07 +00:00
|
|
|
LIB_PART::LIB_PART( LIB_PART& aPart, PART_LIB* 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
|
|
|
EDA_ITEM( aPart ),
|
2017-09-17 08:26:06 +00:00
|
|
|
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_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;
|
2017-12-14 16:24:29 +00:00
|
|
|
m_dateLastEdition = aPart.m_dateLastEdition;
|
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_options = aPart.m_options;
|
2017-11-10 02:24:43 +00:00
|
|
|
m_libId = aPart.m_libId;
|
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
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& oldItem : aPart.m_drawings )
|
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 );
|
2017-09-17 08:26:06 +00:00
|
|
|
m_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
|
|
|
{
|
2015-02-06 15:34:11 +00:00
|
|
|
wxLogTrace( traceSchLibMem,
|
2018-01-18 10:23:59 +00:00
|
|
|
wxT( "%s: destroying symbol with alias list count of %llu" ),
|
2017-12-31 00:55:11 +00:00
|
|
|
GetChars( wxString::FromAscii( __WXFUNCTION__ ) ),
|
2015-02-27 19:12:01 +00:00
|
|
|
(long long unsigned) m_aliases.size() );
|
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 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
|
2015-04-07 11:52:29 +00:00
|
|
|
{
|
|
|
|
// use letters as notation. To allow more than 26 units, the sub ref
|
|
|
|
// use one letter if letter = A .. Z or a ... z, and 2 letters otherwise
|
|
|
|
// first letter is expected to be 'A' or 'a' (i.e. 26 letters are available)
|
|
|
|
int u;
|
2015-04-07 13:19:30 +00:00
|
|
|
aUnit -= 1; // Unit number starts to 1. now to 0.
|
2015-04-07 11:52:29 +00:00
|
|
|
|
2015-04-07 13:19:30 +00:00
|
|
|
while( aUnit >= 26 ) // more than one letter are needed
|
2015-04-07 11:52:29 +00:00
|
|
|
{
|
|
|
|
u = aUnit / 26;
|
|
|
|
subRef << wxChar( m_subpartFirstId + u -1 );
|
|
|
|
aUnit %= 26;
|
|
|
|
}
|
|
|
|
|
2015-04-07 13:19:30 +00:00
|
|
|
u = m_subpartFirstId + aUnit;
|
2015-04-07 11:52:29 +00:00
|
|
|
subRef << wxChar( u );
|
|
|
|
}
|
2013-05-19 19:35:49 +00:00
|
|
|
|
2010-04-24 11:27:38 +00:00
|
|
|
return subRef;
|
|
|
|
}
|
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
|
2017-12-29 14:57:12 +00:00
|
|
|
const wxString& LIB_PART::GetName() const
|
|
|
|
{
|
|
|
|
static wxString dummy;
|
|
|
|
|
|
|
|
wxCHECK_MSG( m_aliases.size(), dummy, "no aliases defined for symbol" );
|
|
|
|
|
|
|
|
return m_aliases[0]->GetName();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2017-11-12 19:54:04 +00:00
|
|
|
m_libId.SetLibItemName( aName, false );
|
2016-08-18 23:23:10 +00:00
|
|
|
|
|
|
|
// The LIB_ALIAS that is the LIB_PART name has to be created so create it.
|
|
|
|
if( m_aliases.size() == 0 )
|
|
|
|
m_aliases.push_back( new LIB_ALIAS( aName, this ) );
|
|
|
|
else
|
|
|
|
m_aliases[0]->SetName( aName );
|
2017-11-12 19:54:04 +00:00
|
|
|
|
|
|
|
LIB_FIELD& valueField = GetValueField();
|
|
|
|
|
|
|
|
// LIB_FIELD::SetText() calls LIB_PART::SetName(),
|
|
|
|
// the following if-clause is to break an infinite loop
|
|
|
|
if( valueField.GetText() != aName )
|
|
|
|
valueField.SetText( aName );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-19 18:40:26 +00:00
|
|
|
void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
|
|
|
|
int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts )
|
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
|
|
|
|
2017-02-19 18:40:26 +00:00
|
|
|
GRSetDrawMode( aDc, aOpts.draw_mode );
|
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 )
|
|
|
|
*/
|
2017-02-20 16:57:41 +00:00
|
|
|
if( ! ( screen && screen->m_IsPrinting && GetGRForceBlackPenState() )
|
2017-02-20 17:48:27 +00:00
|
|
|
&& ( aOpts.color == COLOR4D::UNSPECIFIED ) )
|
2010-03-28 14:46:49 +00:00
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& drawItem : m_drawings )
|
2010-03-28 14:46:49 +00:00
|
|
|
{
|
|
|
|
if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR )
|
|
|
|
continue;
|
|
|
|
|
2017-02-19 18:40:26 +00:00
|
|
|
if( aOpts.only_selected && !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;
|
|
|
|
|
2017-08-14 14:53:25 +00:00
|
|
|
if( drawItem.Type() == LIB_FIELD_T ) // TODO dead code?
|
2010-03-28 14:46:49 +00:00
|
|
|
{
|
2017-02-19 18:40:26 +00:00
|
|
|
drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
|
|
|
|
aOpts.draw_mode, (void*) NULL, aOpts.transform );
|
2010-03-28 14:46:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now, draw only the background for items with
|
|
|
|
// m_Fill == FILLED_WITH_BG_BODYCOLOR:
|
2017-02-19 18:40:26 +00:00
|
|
|
drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
|
|
|
|
aOpts.draw_mode, (void*) false, aOpts.transform );
|
2010-03-28 14:46:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-08 00:07:42 +00:00
|
|
|
// Track the index into the dangling pins list
|
|
|
|
size_t pin_index = 0;
|
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& drawItem : m_drawings )
|
2009-09-04 18:57:37 +00:00
|
|
|
{
|
2017-02-19 18:40:26 +00:00
|
|
|
if( aOpts.only_selected && !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;
|
|
|
|
|
2017-02-19 18:40:26 +00:00
|
|
|
if( drawItem.Type() == LIB_FIELD_T )
|
|
|
|
{
|
|
|
|
LIB_FIELD& field = dynamic_cast<LIB_FIELD&>( drawItem );
|
|
|
|
|
|
|
|
if( field.IsVisible() && !aOpts.draw_visible_fields )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( !field.IsVisible() && !aOpts.draw_hidden_fields )
|
|
|
|
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
|
|
|
{
|
2015-07-21 14:07:52 +00:00
|
|
|
LIB_PIN& pin = dynamic_cast<LIB_PIN&>( drawItem );
|
|
|
|
|
2015-06-08 00:07:42 +00:00
|
|
|
uintptr_t flags = 0;
|
2017-02-19 18:40:26 +00:00
|
|
|
if( aOpts.show_pin_text )
|
2015-06-08 00:07:42 +00:00
|
|
|
flags |= PIN_DRAW_TEXTS;
|
|
|
|
|
2017-02-19 18:40:26 +00:00
|
|
|
if( aOpts.show_elec_type )
|
2016-11-04 11:13:22 +00:00
|
|
|
flags |= PIN_DRAW_ELECTRICAL_TYPE_NAME;
|
|
|
|
|
2017-02-19 18:40:26 +00:00
|
|
|
if( aOpts.PinIsDangling( pin_index ) )
|
2015-06-08 00:07:42 +00:00
|
|
|
flags |= PIN_DRAW_DANGLING;
|
|
|
|
|
2015-07-21 14:07:52 +00:00
|
|
|
if( pin.IsPowerConnection() && IsPower() )
|
|
|
|
flags |= PIN_DANGLING_HIDDEN;
|
|
|
|
|
2017-02-19 18:40:26 +00:00
|
|
|
drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
|
|
|
|
aOpts.draw_mode, (void*) flags, aOpts.transform );
|
2015-06-08 00:07:42 +00:00
|
|
|
|
|
|
|
++pin_index;
|
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
|
|
|
{
|
2017-02-19 18:40:26 +00:00
|
|
|
drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
|
|
|
|
aOpts.draw_mode, (void*) NULL, aOpts.transform );
|
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;
|
2017-02-19 18:40:26 +00:00
|
|
|
drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
|
|
|
|
aOpts.draw_mode, (void*) forceNoFill,
|
|
|
|
aOpts.transform );
|
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,
|
2017-02-19 18:40:26 +00:00
|
|
|
aOffset.y + len, 0, aOpts.color );
|
2014-02-19 16:44:48 +00:00
|
|
|
GRLine( clipbox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len,
|
2017-02-19 18:40:26 +00:00
|
|
|
aOffset.y, 0, aOpts.color );
|
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
|
2016-09-30 05:31:48 +00:00
|
|
|
EDA_RECT bBox = GetUnitBoundingBox( aMulti, aConvert );
|
2015-06-18 14:56:08 +00:00
|
|
|
bBox.RevertYAxis();
|
2017-02-19 18:40:26 +00:00
|
|
|
bBox = aOpts.transform.TransformCoordinate( bBox );
|
2015-06-18 14:56:08 +00:00
|
|
|
bBox.Move( aOffset );
|
|
|
|
GRRect( aPanel ? aPanel->GetClipBox() : NULL, aDc, bBox, 0, LIGHTMAGENTA );
|
2009-09-04 18:57:37 +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
|
|
|
void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
|
2017-12-01 16:49:19 +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();
|
|
|
|
|
2014-11-12 10:32:02 +00:00
|
|
|
// draw background for filled items using background option
|
|
|
|
// Solid lines will be drawn after the background
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2014-11-12 10:32:02 +00:00
|
|
|
// Lib Fields are not plotted here, because this plot function
|
2013-05-18 09:38:23 +00:00
|
|
|
// 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;
|
|
|
|
|
2014-11-12 10:32:02 +00:00
|
|
|
if( item.m_Fill == FILLED_WITH_BG_BODYCOLOR )
|
|
|
|
item.Plot( aPlotter, aOffset, fill, aTransform );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not filled items and filled shapes are now plotted
|
|
|
|
// (plot only items which are not already plotted)
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings )
|
2014-11-12 10:32:02 +00:00
|
|
|
{
|
|
|
|
if( item.Type() == LIB_FIELD_T )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( item.m_Fill != FILLED_WITH_BG_BODYCOLOR )
|
|
|
|
item.Plot( aPlotter, aOffset, fill, aTransform );
|
2013-05-18 09:38:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-01 16:49: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::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
|
2017-12-01 16:49:19 +00:00
|
|
|
const wxPoint& aOffset, const TRANSFORM& aTransform )
|
2013-05-18 09:38:23 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aPlotter != NULL );
|
|
|
|
|
|
|
|
aPlotter->SetColor( GetLayerColor( LAYER_FIELDS ) );
|
|
|
|
bool fill = aPlotter->GetColorMode();
|
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings )
|
2013-05-18 09:38:23 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2015-01-27 18:40:52 +00:00
|
|
|
// The reference is a special case: we should change the basic text
|
2013-05-18 09:38:23 +00:00
|
|
|
// 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
|
|
|
|
2015-02-06 15:34:11 +00:00
|
|
|
// none of the MANDATORY_FIELDS may be removed in RAM, but they may be
|
2010-06-17 16:30:10 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
LIB_ITEMS& items = m_drawings[ aItem->Type() ];
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2017-08-14 14:53:25 +00:00
|
|
|
for( LIB_ITEMS::iterator i = items.begin(); i != items.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 )
|
2017-02-20 17:48:27 +00:00
|
|
|
aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED,
|
2015-01-27 18:40:52 +00:00
|
|
|
g_XorMode, NULL, DefaultTransform );
|
2011-02-24 22:29:43 +00:00
|
|
|
|
2017-08-14 14:53:25 +00:00
|
|
|
items.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
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
m_drawings.push_back( aItem );
|
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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
if( m_drawings.empty( aType ) )
|
2009-10-05 17:52:41 +00:00
|
|
|
return NULL;
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
if( aItem == NULL )
|
|
|
|
return &( *( m_drawings.begin( aType ) ) );
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2017-09-17 09:09:56 +00:00
|
|
|
// Search for the last item, assume aItem is of type aType
|
2017-09-17 08:26:06 +00:00
|
|
|
wxASSERT( ( aType == TYPE_NOT_INIT ) || ( aType == aItem->Type() ) );
|
|
|
|
LIB_ITEMS_CONTAINER::ITERATOR it = m_drawings.begin( aType );
|
2017-09-17 09:09:56 +00:00
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
while( ( it != m_drawings.end( aType ) ) && ( aItem != &( *it ) ) )
|
|
|
|
++it;
|
2009-09-29 18:38:21 +00:00
|
|
|
|
2009-10-08 16:45:59 +00:00
|
|
|
// Search the next item
|
2017-09-17 08:26:06 +00:00
|
|
|
if( it != m_drawings.end( aType ) )
|
2009-10-08 16:45:59 +00:00
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
++it;
|
2017-09-17 09:09:56 +00:00
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
if( it != m_drawings.end( aType ) )
|
|
|
|
return &( *it );
|
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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
if( m_drawings.empty( LIB_PIN_T ) )
|
2017-08-14 14:53:25 +00:00
|
|
|
return;
|
|
|
|
|
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
|
|
|
*/
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings[ LIB_PIN_T ] )
|
2009-10-14 19:43:31 +00:00
|
|
|
{
|
2009-10-26 12:01:46 +00:00
|
|
|
// 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
|
|
|
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
|
|
|
|
2017-08-10 15:00:28 +00:00
|
|
|
if( aNumber == pinList[i]->GetNumber() )
|
2009-10-30 19:26:25 +00:00
|
|
|
return pinList[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-25 22:26:51 +00:00
|
|
|
bool LIB_PART::PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTestNames,
|
|
|
|
bool aTestType, bool aTestOrientation, bool aTestLength )
|
|
|
|
{
|
|
|
|
LIB_PINS thisPinList;
|
|
|
|
GetPins( thisPinList, /* aUnit */ 0, /* aConvert */ 0 );
|
|
|
|
|
2016-06-29 20:07:55 +00:00
|
|
|
for( LIB_PIN* eachThisPin : thisPinList )
|
2015-04-25 22:26:51 +00:00
|
|
|
{
|
|
|
|
wxASSERT( eachThisPin );
|
|
|
|
LIB_PINS otherPinList;
|
|
|
|
aOtherPart.GetPins( otherPinList, /* aUnit */ 0, /* aConvert */ 0 );
|
|
|
|
bool foundMatch = false;
|
|
|
|
|
2016-06-29 20:07:55 +00:00
|
|
|
for( LIB_PIN* eachOtherPin : otherPinList )
|
2015-04-25 22:26:51 +00:00
|
|
|
{
|
|
|
|
wxASSERT( eachOtherPin );
|
|
|
|
// Same position?
|
|
|
|
if( eachThisPin->GetPosition() != eachOtherPin->GetPosition() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Same number?
|
2017-08-10 15:00:28 +00:00
|
|
|
if( aTestNums && ( eachThisPin->GetNumber() != eachOtherPin->GetNumber() ))
|
2015-04-25 22:26:51 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Same name?
|
|
|
|
if( aTestNames && ( eachThisPin->GetName() != eachOtherPin->GetName() ))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Same electrical type?
|
|
|
|
if( aTestType && ( eachThisPin->GetType() != eachOtherPin->GetType() ))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Same orientation?
|
|
|
|
if( aTestOrientation && ( eachThisPin->GetOrientation() != eachOtherPin->GetOrientation() ))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Same length?
|
|
|
|
if( aTestLength && ( eachThisPin->GetLength() != eachOtherPin->GetLength() ))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
foundMatch = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !foundMatch )
|
|
|
|
{
|
|
|
|
// This means there was not an identical (according to the arguments)
|
|
|
|
// pin at the same position in the other component.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The loop never gave up, so no conflicts were found.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-30 05:31:48 +00:00
|
|
|
const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2015-06-18 14:56:08 +00:00
|
|
|
EDA_RECT bBox;
|
|
|
|
bool initialized = false;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
for( const LIB_ITEM& item : m_drawings )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
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;
|
|
|
|
|
2015-06-18 14:56:08 +00:00
|
|
|
if( initialized )
|
|
|
|
bBox.Merge( item.GetBoundingBox() );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bBox = item.GetBoundingBox();
|
|
|
|
initialized = true;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
2015-01-18 17:28:14 +00:00
|
|
|
const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
|
2011-02-27 19:54:01 +00:00
|
|
|
{
|
2015-06-18 14:56:08 +00:00
|
|
|
EDA_RECT bBox;
|
|
|
|
bool initialized = false;
|
2011-02-27 19:54:01 +00:00
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
for( const LIB_ITEM& item : m_drawings )
|
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;
|
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
if( item.Type() == LIB_FIELD_T )
|
2011-02-27 19:54:01 +00:00
|
|
|
continue;
|
|
|
|
|
2015-06-18 14:56:08 +00:00
|
|
|
if( initialized )
|
|
|
|
bBox.Merge( item.GetBoundingBox() );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bBox = item.GetBoundingBox();
|
|
|
|
initialized = true;
|
|
|
|
}
|
2011-02-27 19:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
m_drawings[ LIB_FIELD_T ].clear();
|
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
|
|
|
|
2014-10-26 11:42:25 +00:00
|
|
|
field->SetParent( this );
|
2017-09-17 08:26:06 +00:00
|
|
|
m_drawings.push_back( field );
|
2008-12-31 15:01:29 +00:00
|
|
|
}
|
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.
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
2008-12-31 15:01:29 +00:00
|
|
|
{
|
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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-09 13:08:33 +00:00
|
|
|
LIB_FIELD& LIB_PART::GetFootprintField()
|
|
|
|
{
|
|
|
|
LIB_FIELD* field = GetField( FOOTPRINT );
|
|
|
|
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;
|
|
|
|
|
2017-12-14 16:24:29 +00:00
|
|
|
if( m_dateLastEdition == 0 )
|
2009-04-05 20:49:15 +00:00
|
|
|
return true;
|
|
|
|
|
2017-12-14 16:24:29 +00:00
|
|
|
sec = m_dateLastEdition & 63;
|
|
|
|
min = ( m_dateLastEdition >> 6 ) & 63;
|
|
|
|
hour = ( m_dateLastEdition >> 12 ) & 31;
|
|
|
|
day = ( m_dateLastEdition >> 17 ) & 31;
|
|
|
|
mon = ( m_dateLastEdition >> 22 ) & 15;
|
|
|
|
year = ( m_dateLastEdition >> 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;
|
|
|
|
|
2017-12-14 16:24:29 +00:00
|
|
|
m_dateLastEdition = ( 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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings )
|
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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
m_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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( const LIB_ITEM& item : m_drawings )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_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
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-23 11:15:19 +00:00
|
|
|
int LIB_PART::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aSyncPinEdit )
|
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
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_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
|
|
|
|
2018-01-23 11:15:19 +00:00
|
|
|
// Specific rules for pins:
|
|
|
|
// - do not select pins in other units when synchronized pin edit mode is disabled
|
|
|
|
// - do not select pins in other units when units are not interchangeable
|
|
|
|
// - in other cases verify if the pin belongs to the requested unit
|
|
|
|
if( !aSyncPinEdit || 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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
LIB_ITEMS_CONTAINER::ITERATOR item = m_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
|
2017-09-17 08:26:06 +00:00
|
|
|
while( item != m_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
|
|
|
{
|
2017-12-01 16:49:19 +00:00
|
|
|
item->ClearFlags( SELECTED );
|
2010-03-08 19:21:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( !item->IsSelected() )
|
2017-08-14 14:53:25 +00:00
|
|
|
++item;
|
2009-10-05 17:52:41 +00:00
|
|
|
else
|
2017-09-17 08:26:06 +00:00
|
|
|
item = m_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
|
|
|
{
|
2017-08-31 16:21:09 +00:00
|
|
|
std::vector< LIB_ITEM* > tmp;
|
2011-10-31 20:49:48 +00:00
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings )
|
2009-09-25 18:49:04 +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 );
|
2017-09-17 08:26:06 +00:00
|
|
|
|
|
|
|
// When push_back elements in buffer, a memory reallocation can happen
|
|
|
|
// and will break pointers.
|
|
|
|
// So, push_back later.
|
2017-08-31 16:21:09 +00:00
|
|
|
tmp.push_back( newItem );
|
2009-09-25 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
2017-09-17 09:09:56 +00:00
|
|
|
for( auto item : tmp )
|
2017-09-17 08:26:06 +00:00
|
|
|
m_drawings.push_back( item );
|
2017-08-31 16:21:09 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
MoveSelectedItems( aOffset );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2009-09-29 18:38:21 +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::MirrorSelectedItemsH( const wxPoint& aCenter )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-14 14:53: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::MirrorSelectedItemsV( const wxPoint& aCenter )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-14 14:53: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::RotateSelectedItems( const wxPoint& aCenter )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings )
|
2011-05-20 18:29:35 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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,
|
2015-01-27 18:40:52 +00:00
|
|
|
KICAD_T aType, const wxPoint& aPoint )
|
2009-09-29 18:38:21 +00:00
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_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,
|
2015-01-27 18:40:52 +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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
LIB_ITEMS_CONTAINER::ITERATOR i = m_drawings.begin();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
while( i != m_drawings.end() )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
if( i->m_Unit > aCount )
|
2017-09-17 08:26:06 +00:00
|
|
|
i = m_drawings.erase( i );
|
2009-10-05 17:52:41 +00:00
|
|
|
else
|
2017-08-14 14:53:25 +00:00
|
|
|
++i;
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
int prevCount = m_unitCount;
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2017-09-17 09:09:56 +00:00
|
|
|
// Temporary storage for new items, as adding new items directly to
|
|
|
|
// m_drawings may cause the buffer reallocation which invalidates the
|
|
|
|
// iterators
|
2017-09-17 08:26:06 +00:00
|
|
|
std::vector< LIB_ITEM* > tmp;
|
2017-09-17 09:09:56 +00:00
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_drawings )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
if( item.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
|
|
|
{
|
2017-09-17 08:26:06 +00:00
|
|
|
LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
|
2009-10-05 17:52:41 +00:00
|
|
|
newItem->m_Unit = j;
|
2017-09-17 08:26:06 +00:00
|
|
|
tmp.push_back( newItem );
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-17 09:09:56 +00:00
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
for( auto item : tmp )
|
|
|
|
m_drawings.push_back( item );
|
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
|
|
|
{
|
2016-02-19 21:29:56 +00:00
|
|
|
std::vector< LIB_ITEM* > tmp; // Temporarily store the duplicated pins here.
|
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
for( LIB_ITEM& item : m_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;
|
2016-02-19 21:29:56 +00:00
|
|
|
tmp.push_back( newItem );
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-19 21:29:56 +00:00
|
|
|
|
|
|
|
// Transfer the new pins to the LIB_PART.
|
|
|
|
for( unsigned i = 0; i < tmp.size(); i++ )
|
2017-09-17 08:26:06 +00:00
|
|
|
m_drawings.push_back( tmp[i] );
|
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
|
2017-09-17 08:26:06 +00:00
|
|
|
LIB_ITEMS_CONTAINER::ITERATOR i = m_drawings.begin();
|
2009-10-05 17:52:41 +00:00
|
|
|
|
2017-09-17 08:26:06 +00:00
|
|
|
while( i != m_drawings.end() )
|
2009-10-05 17:52:41 +00:00
|
|
|
{
|
|
|
|
if( i->m_Convert > 1 )
|
2017-09-17 08:26:06 +00:00
|
|
|
i = m_drawings.erase( i );
|
2009-10-05 17:52:41 +00:00
|
|
|
else
|
2017-08-14 14:53:25 +00:00
|
|
|
++i;
|
2009-10-05 17:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
2015-12-22 11:58:26 +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++ )
|
|
|
|
{
|
2016-06-11 03:15:02 +00:00
|
|
|
if( aName == m_aliases[i]->GetName() )
|
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,
|
2018-01-18 10:23:59 +00:00
|
|
|
wxT( "Symbol aliases cannot be changed when they are owned by a library." ) );
|
2017-11-12 20:49:38 +00:00
|
|
|
wxCHECK_RET( !aAliasList.IsEmpty(), wxT( "Alias list cannot be empty" ) );
|
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.
|
2016-01-26 01:52:13 +00:00
|
|
|
LIB_ALIASES::iterator it = m_aliases.begin();
|
2010-02-17 13:22:25 +00:00
|
|
|
|
2016-01-26 01:52:13 +00:00
|
|
|
while( it != m_aliases.end() )
|
2010-10-04 18:54:14 +00:00
|
|
|
{
|
|
|
|
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() )
|
2016-01-26 01:52:13 +00:00
|
|
|
++it;
|
|
|
|
else
|
|
|
|
it = m_aliases.erase( it );
|
2010-10-04 18:54:14 +00:00
|
|
|
}
|
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
|
|
|
void LIB_PART::RemoveAlias( const wxString& aName )
|
|
|
|
{
|
|
|
|
LIB_ALIAS* a = GetAlias( aName );
|
|
|
|
|
|
|
|
if( a )
|
|
|
|
RemoveAlias( a );
|
|
|
|
}
|
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();
|
|
|
|
|
2015-02-06 15:34:11 +00:00
|
|
|
wxLogTrace( traceSchLibMem,
|
2018-01-18 10:23:59 +00:00
|
|
|
wxT( "%s: symbol:'%s', alias:'%s', alias count %llu, reference count %ld." ),
|
2015-02-06 15:34:11 +00:00
|
|
|
GetChars( wxString::FromAscii( __WXFUNCTION__ ) ),
|
2017-11-12 20:49:38 +00:00
|
|
|
GetChars( GetName() ),
|
2015-02-06 15:34:11 +00:00
|
|
|
GetChars( aAlias->GetName() ),
|
2015-02-27 19:12:01 +00:00
|
|
|
(long long unsigned) m_aliases.size(),
|
2015-02-06 15:34:11 +00:00
|
|
|
m_me.use_count() );
|
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
|
|
|
|
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++ )
|
|
|
|
{
|
2016-06-11 03:15:02 +00:00
|
|
|
if( aName == m_aliases[i]->GetName() )
|
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 ),
|
2018-01-18 10:23:59 +00:00
|
|
|
wxT( "Symbol <" ) + 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
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|