2011-10-11 20:23:56 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-28 16:56:09 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-11 20:23:56 +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
|
|
|
|
*/
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
/**
|
|
|
|
* @file sch_component.cpp
|
|
|
|
* @brief Implementation of the class SCH_COMPONENT.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <richio.h>
|
2015-02-21 09:46:44 +00:00
|
|
|
#include <schframe.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <plot_common.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <class_library.h>
|
|
|
|
#include <lib_rectangle.h>
|
|
|
|
#include <lib_pin.h>
|
|
|
|
#include <lib_text.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_sheet.h>
|
|
|
|
#include <sch_sheet_path.h>
|
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
|
|
|
//#include <sch_collectors.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_netlist_object.h>
|
2015-06-08 00:07:42 +00:00
|
|
|
#include <lib_draw_item.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialogs/dialog_schematic_find.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
#include <wx/tokenzr.h>
|
2015-06-08 00:07:42 +00:00
|
|
|
#include <iostream>
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
#define NULL_STRING "_NONAME_"
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2011-07-15 13:17:41 +00:00
|
|
|
/**
|
|
|
|
* Function toUTFTildaText
|
|
|
|
* convert a wxString to UTF8 and replace any control characters with a ~,
|
|
|
|
* where a control character is one of the first ASCII values up to ' ' 32d.
|
|
|
|
*/
|
2016-07-11 19:48:46 +00:00
|
|
|
std::string toUTFTildaText( const wxString& txt )
|
2011-07-15 13:17:41 +00:00
|
|
|
{
|
|
|
|
std::string ret = TO_UTF8( txt );
|
|
|
|
|
|
|
|
for( std::string::iterator it = ret.begin(); it!=ret.end(); ++it )
|
|
|
|
{
|
|
|
|
if( (unsigned char) *it <= ' ' )
|
|
|
|
*it = '~';
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Used when a LIB_PART is not found in library
|
|
|
|
* to draw a dummy shape
|
|
|
|
* This component is a 400 mils square with the text ??
|
|
|
|
* DEF DUMMY U 0 40 Y Y 1 0 N
|
|
|
|
* F0 "U" 0 -350 60 H V
|
|
|
|
* F1 "DUMMY" 0 350 60 H V
|
|
|
|
* DRAW
|
|
|
|
* T 0 0 0 150 0 0 0 ??
|
|
|
|
* S -200 200 200 -200 0 1 0
|
|
|
|
* ENDDRAW
|
|
|
|
* ENDDEF
|
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
|
|
|
static LIB_PART* dummy()
|
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
|
|
|
static LIB_PART* part;
|
|
|
|
|
|
|
|
if( !part )
|
|
|
|
{
|
|
|
|
part = new LIB_PART( wxEmptyString );
|
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_RECTANGLE* square = new LIB_RECTANGLE( part );
|
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
|
|
|
square->Move( wxPoint( -200, 200 ) );
|
|
|
|
square->SetEndPosition( wxPoint( 200, -200 ) );
|
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_TEXT* text = new LIB_TEXT( part );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
text->SetTextSize( wxSize( 150, 150 ) );
|
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
|
|
|
text->SetText( wxString( wxT( "??" ) ) );
|
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
|
|
|
part->AddDrawItem( square );
|
|
|
|
part->AddDrawItem( text );
|
|
|
|
}
|
|
|
|
|
|
|
|
return part;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
|
2010-12-10 19:47:44 +00:00
|
|
|
SCH_ITEM( aParent, SCH_COMPONENT_T )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-10-16 17:18:23 +00:00
|
|
|
Init( aPos );
|
2016-02-15 20:15:51 +00:00
|
|
|
m_currentSheetPath = NULL;
|
2016-01-09 23:35:20 +00:00
|
|
|
m_fieldsAutoplaced = AUTOPLACED_NO;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:15:51 +00:00
|
|
|
SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit,
|
2010-12-14 21:39:31 +00:00
|
|
|
int convert, const wxPoint& pos, bool setNewItemFlag ) :
|
2010-12-10 19:47:44 +00:00
|
|
|
SCH_ITEM( NULL, SCH_COMPONENT_T )
|
2008-10-06 05:44:29 +00:00
|
|
|
{
|
2009-10-16 17:18:23 +00:00
|
|
|
Init( pos );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2016-02-15 20:15:51 +00:00
|
|
|
m_unit = unit;
|
|
|
|
m_convert = convert;
|
|
|
|
m_part_name = aPart.GetName();
|
|
|
|
m_part = aPart.SharedPtr();
|
|
|
|
m_currentSheetPath = NULL;
|
2016-01-09 23:35:20 +00:00
|
|
|
m_fieldsAutoplaced = AUTOPLACED_NO;
|
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-12-12 08:37:05 +00:00
|
|
|
SetTimeStamp( GetNewTimeStamp() );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
if( setNewItemFlag )
|
|
|
|
m_Flags = IS_NEW | IS_MOVED;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// Import user defined fields from the library component:
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_FIELDS libFields;
|
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
|
|
|
aPart.GetFields( libFields );
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
for( LIB_FIELDS::iterator it = libFields.begin(); it!=libFields.end(); ++it )
|
2008-10-06 05:44:29 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
// Can no longer insert an empty name, since names are now keys. The
|
|
|
|
// field index is not used beyond the first MANDATORY_FIELDS
|
2010-12-07 16:10:42 +00:00
|
|
|
if( it->GetName().IsEmpty() )
|
2009-10-16 17:18:23 +00:00
|
|
|
continue;
|
2008-10-18 13:42:21 +00:00
|
|
|
|
2015-04-26 16:32:16 +00:00
|
|
|
// See if field already exists (mandatory fields always exist).
|
|
|
|
// for mandatory fields, the name and field id are fixed, so we use the
|
|
|
|
// known and fixed id to get them (more reliable than names, which can be translated)
|
|
|
|
// for other fields (custom fields), locate the field by same name
|
|
|
|
// (field id has no known meaning for custom fields)
|
|
|
|
int idx = it->GetId();
|
|
|
|
SCH_FIELD* schField;
|
|
|
|
|
|
|
|
if( idx < MANDATORY_FIELDS )
|
|
|
|
schField = GetField( idx );
|
|
|
|
else
|
|
|
|
schField = FindField( it->GetName() );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
if( !schField )
|
2009-10-21 20:02:25 +00:00
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
SCH_FIELD fld( wxPoint( 0, 0 ), GetFieldCount(), this, it->GetName() );
|
2010-06-17 16:30:10 +00:00
|
|
|
schField = AddField( fld );
|
2009-10-16 17:18:23 +00:00
|
|
|
}
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
schField->SetTextPos( m_Pos + it->GetTextPos() );
|
2010-06-17 16:30:10 +00:00
|
|
|
schField->ImportValues( *it );
|
2013-03-18 19:36:07 +00:00
|
|
|
schField->SetText( it->GetText() );
|
2010-06-17 16:30:10 +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
|
|
|
wxString msg = aPart.GetReferenceField().GetText();
|
2009-10-21 20:02:25 +00:00
|
|
|
|
|
|
|
if( msg.IsEmpty() )
|
|
|
|
msg = wxT( "U" );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
m_prefix = msg;
|
2009-10-21 20:02:25 +00:00
|
|
|
|
|
|
|
// update the reference -- just the prefix for now.
|
2009-10-27 10:55:46 +00:00
|
|
|
msg += wxT( "?" );
|
2016-02-15 20:18:32 +00:00
|
|
|
SetRef( sheet, msg );
|
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
|
|
|
// Use the schematic component name instead of the library value field
|
|
|
|
// name.
|
|
|
|
GetField( VALUE )->SetText( GetPartName() );
|
2008-10-06 05:44:29 +00:00
|
|
|
}
|
|
|
|
|
2008-10-19 18:31:09 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) :
|
|
|
|
SCH_ITEM( aComponent )
|
2008-10-19 18:31:09 +00:00
|
|
|
{
|
2016-02-15 20:15:51 +00:00
|
|
|
m_currentSheetPath = NULL;
|
|
|
|
m_Parent = aComponent.m_Parent;
|
|
|
|
m_Pos = aComponent.m_Pos;
|
|
|
|
m_unit = aComponent.m_unit;
|
|
|
|
m_convert = aComponent.m_convert;
|
|
|
|
m_part_name = aComponent.m_part_name;
|
|
|
|
m_part = aComponent.m_part;
|
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-12-12 08:37:05 +00:00
|
|
|
SetTimeStamp( aComponent.m_TimeStamp );
|
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-12-21 15:13:09 +00:00
|
|
|
m_transform = aComponent.m_transform;
|
|
|
|
m_prefix = aComponent.m_prefix;
|
|
|
|
m_PathsAndReferences = aComponent.m_PathsAndReferences;
|
|
|
|
m_Fields = aComponent.m_Fields;
|
|
|
|
|
|
|
|
// Re-parent the fields, which before this had aComponent as parent
|
2010-09-05 17:01:48 +00:00
|
|
|
for( int i = 0; i<GetFieldCount(); ++i )
|
2008-10-19 18:31:09 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
GetField( i )->SetParent( this );
|
2008-10-19 18:31:09 +00:00
|
|
|
}
|
2015-06-08 00:07:42 +00:00
|
|
|
|
|
|
|
m_isDangling = aComponent.m_isDangling;
|
2015-12-13 16:56:47 +00:00
|
|
|
m_fieldsAutoplaced = aComponent.m_fieldsAutoplaced;
|
2008-10-19 18:31:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
void SCH_COMPONENT::Init( const wxPoint& pos )
|
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
m_Pos = pos;
|
2010-12-14 15:56:30 +00:00
|
|
|
m_unit = 0; // In multi unit chip - which unit to draw.
|
|
|
|
m_convert = 0; // De Morgan Handling
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// The rotation/mirror transformation matrix. pos normal
|
2010-12-14 21:39:31 +00:00
|
|
|
m_transform = TRANSFORM();
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// construct only the mandatory fields, which are the first 4 only.
|
|
|
|
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
2009-10-16 17:18:23 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
SCH_FIELD field( pos, i, this, TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) );
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2013-04-06 05:01:48 +00:00
|
|
|
if( i == REFERENCE )
|
2009-10-16 17:18:23 +00:00
|
|
|
field.SetLayer( LAYER_REFERENCEPART );
|
2013-04-06 05:01:48 +00:00
|
|
|
else if( i == VALUE )
|
2009-10-16 17:18:23 +00:00
|
|
|
field.SetLayer( LAYER_VALUEPART );
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// else keep LAYER_FIELDS from SCH_FIELD constructor
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// SCH_FIELD's implicitly created copy constructor is called in here
|
2009-10-16 17:18:23 +00:00
|
|
|
AddField( field );
|
|
|
|
}
|
|
|
|
|
2015-04-26 16:32:16 +00:00
|
|
|
m_prefix = wxString( wxT( "U" ) );
|
2010-12-14 15:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* SCH_COMPONENT::Clone() const
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
|
|
|
return new SCH_COMPONENT( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 SCH_COMPONENT::SetPartName( const wxString& aName, PART_LIBS* aLibs )
|
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
|
|
|
if( m_part_name != aName )
|
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
|
|
|
m_part_name = aName;
|
2010-12-14 15:56:30 +00:00
|
|
|
SetModified();
|
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( aLibs )
|
|
|
|
Resolve( aLibs );
|
|
|
|
else
|
|
|
|
m_part.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_COMPONENT::Resolve( PART_LIBS* aLibs )
|
|
|
|
{
|
|
|
|
// I've never been happy that the actual individual PART_LIB is left up to
|
|
|
|
// flimsy search path ordering. None-the-less find a part based on that design:
|
|
|
|
if( LIB_PART* part = aLibs->FindLibPart( m_part_name ) )
|
|
|
|
{
|
|
|
|
m_part = part->SharedPtr();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_COMPONENT::ResolveAll(
|
|
|
|
const SCH_COLLECTOR& aComponents, PART_LIBS* aLibs )
|
|
|
|
{
|
|
|
|
for( int i = 0; i < aComponents.GetCount(); ++i )
|
|
|
|
{
|
2015-03-10 18:31:21 +00:00
|
|
|
SCH_COMPONENT* cmp = dynamic_cast<SCH_COMPONENT*>( aComponents[i] );
|
|
|
|
wxASSERT( cmp );
|
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
|
|
|
|
2015-03-10 18:31:21 +00:00
|
|
|
if( cmp ) // cmp == NULL should not occur.
|
|
|
|
cmp->Resolve( aLibs );
|
2010-12-14 15:56:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_COMPONENT::SetUnit( int aUnit )
|
|
|
|
{
|
|
|
|
if( m_unit != aUnit )
|
|
|
|
{
|
|
|
|
m_unit = aUnit;
|
|
|
|
SetModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-05 17:48:01 +00:00
|
|
|
void SCH_COMPONENT::UpdateUnit( int aUnit )
|
|
|
|
{
|
|
|
|
m_unit = aUnit;
|
|
|
|
}
|
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
|
|
|
|
void SCH_COMPONENT::SetConvert( int aConvert )
|
|
|
|
{
|
|
|
|
if( m_convert != aConvert )
|
|
|
|
{
|
|
|
|
m_convert = aConvert;
|
|
|
|
SetModified();
|
|
|
|
}
|
2009-10-16 17:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-14 21:39:31 +00:00
|
|
|
void SCH_COMPONENT::SetTransform( const TRANSFORM& aTransform )
|
|
|
|
{
|
|
|
|
if( m_transform != aTransform )
|
|
|
|
{
|
|
|
|
m_transform = aTransform;
|
|
|
|
SetModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 SCH_COMPONENT::GetUnitCount() const
|
2011-06-17 13:24: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
|
|
|
if( PART_SPTR part = m_part.lock() )
|
|
|
|
{
|
|
|
|
return part->GetUnitCount();
|
|
|
|
}
|
2011-06-17 13:24: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
|
|
|
return 0;
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
|
|
|
|
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
|
|
|
|
bool aDrawPinText )
|
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
|
|
|
if( PART_SPTR part = m_part.lock() )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2015-06-15 14:41:08 +00:00
|
|
|
// Draw pin targets if part is being dragged
|
2015-09-06 13:07:46 +00:00
|
|
|
bool dragging = aPanel->GetScreen()->GetCurItem() == this && aPanel->IsMouseCaptured();
|
2015-06-15 14:41:08 +00:00
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
part->Draw( aPanel, aDC, m_Pos + aOffset, m_unit, m_convert, aDrawMode, aColor,
|
2015-06-15 14:41:08 +00:00
|
|
|
m_transform, aDrawPinText, false, false, dragging ? NULL : &m_isDangling );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
}
|
|
|
|
else // Use dummy() part if the actual cannot be found.
|
|
|
|
{
|
2015-02-28 16:56:09 +00:00
|
|
|
dummy()->Draw( aPanel, aDC, m_Pos + aOffset, 0, 0, aDrawMode, aColor,
|
|
|
|
m_transform, aDrawPinText, false );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_FIELD* field = GetField( REFERENCE );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( field->IsVisible() && !field->IsMoving() )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2015-02-28 16:56:09 +00:00
|
|
|
field->Draw( aPanel, aDC, aOffset, aDrawMode );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
2010-10-20 19:43:58 +00:00
|
|
|
for( int ii = VALUE; ii < GetFieldCount(); ii++ )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
|
|
|
field = GetField( ii );
|
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( field->IsMoving() )
|
2009-04-05 20:49:15 +00:00
|
|
|
continue;
|
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
field->Draw( aPanel, aDC, aOffset, aDrawMode );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2009-10-16 17:18:23 +00:00
|
|
|
|
|
|
|
#if 0
|
2015-02-28 16:56:09 +00:00
|
|
|
// Only for testing purposes, draw the component bounding box
|
2009-10-16 17:18:23 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
EDA_RECT boundingBox = GetBoundingBox();
|
2015-02-28 16:56:09 +00:00
|
|
|
GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
|
2009-12-30 18:06:12 +00:00
|
|
|
#if 1
|
|
|
|
if( GetField( REFERENCE )->IsVisible() )
|
|
|
|
{
|
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
|
|
|
boundingBox = GetField( REFERENCE )->GetBoundingBox();
|
2015-02-28 16:56:09 +00:00
|
|
|
GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
|
2009-12-30 18:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( GetField( VALUE )->IsVisible() )
|
|
|
|
{
|
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
|
|
|
boundingBox = GetField( VALUE )->GetBoundingBox();
|
2015-02-28 16:56:09 +00:00
|
|
|
GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
|
2009-12-30 18:06:12 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-10-16 17:18:23 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath,
|
|
|
|
const wxString& aRef,
|
|
|
|
int aMulti )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
wxString h_path, h_ref;
|
|
|
|
wxStringTokenizer tokenizer;
|
|
|
|
wxString separators( wxT( " " ) );
|
|
|
|
|
|
|
|
// Search for an existing path and remove it if found (should not occur)
|
2009-04-05 20:49:15 +00:00
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
|
|
|
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
|
|
|
h_path = tokenizer.GetNextToken();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
if( h_path.Cmp( aPath ) == 0 )
|
2008-04-15 19:38:19 +00:00
|
|
|
{
|
2008-04-16 08:40:31 +00:00
|
|
|
m_PathsAndReferences.RemoveAt( ii );
|
|
|
|
ii--;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
h_ref = aPath + wxT( " " ) + aRef;
|
|
|
|
h_ref << wxT( " " ) << aMulti;
|
2008-04-15 19:38:19 +00:00
|
|
|
m_PathsAndReferences.Add( h_ref );
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:22:45 +00:00
|
|
|
wxString SCH_COMPONENT::GetPath( const SCH_SHEET_PATH* sheet ) const
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2016-02-15 20:22:45 +00:00
|
|
|
wxCHECK_MSG( sheet != NULL, wxEmptyString,
|
2011-12-01 16:49:28 +00:00
|
|
|
wxT( "Cannot get component path with invalid sheet object." ) );
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
wxString str;
|
|
|
|
|
2015-02-28 13:12:09 +00:00
|
|
|
str.Printf( wxT( "%8.8lX" ), (long unsigned) m_TimeStamp );
|
2016-02-15 20:22:45 +00:00
|
|
|
return sheet->Path() + str;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
2016-02-15 20:17:51 +00:00
|
|
|
const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet )
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2016-02-15 20:22:45 +00:00
|
|
|
wxString path = GetPath( sheet );
|
2008-04-15 19:38:19 +00:00
|
|
|
wxString h_path, h_ref;
|
|
|
|
wxStringTokenizer tokenizer;
|
|
|
|
wxString separators( wxT( " " ) );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-02-21 12:21:01 +00:00
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
|
|
|
h_path = tokenizer.GetNextToken();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
if( h_path.Cmp( path ) == 0 )
|
2008-02-21 12:21:01 +00:00
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
h_ref = tokenizer.GetNextToken();
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* printf( "GetRef hpath: %s\n",
|
2011-02-28 18:36:19 +00:00
|
|
|
* TO_UTF8( m_PathsAndReferences[ii] ) ); */
|
2008-04-15 19:38:19 +00:00
|
|
|
return h_ref;
|
2008-02-21 12:21:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
// if it was not found in m_Paths array, then see if it is in
|
2008-02-21 12:21:01 +00:00
|
|
|
// m_Field[REFERENCE] -- if so, use this as a default for this path.
|
|
|
|
// this will happen if we load a version 1 schematic file.
|
|
|
|
// it will also mean that multiple instances of the same sheet by default
|
|
|
|
// all have the same component references, but perhaps this is best.
|
2013-03-18 19:36:07 +00:00
|
|
|
if( !GetField( REFERENCE )->GetText().IsEmpty() )
|
2008-02-21 12:21:01 +00:00
|
|
|
{
|
2016-02-15 20:18:32 +00:00
|
|
|
SetRef( sheet, GetField( REFERENCE )->GetText() );
|
2013-03-18 19:36:07 +00:00
|
|
|
return GetField( REFERENCE )->GetText();
|
2008-02-21 12:21:01 +00:00
|
|
|
}
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
return m_prefix;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
2016-02-15 20:17:51 +00:00
|
|
|
/* Function IsReferenceStringValid (static function)
|
|
|
|
* Tests for an acceptable reference string
|
|
|
|
* An acceptable reference string must support unannotation
|
|
|
|
* i.e starts by letter
|
|
|
|
* returns true if OK
|
|
|
|
*/
|
2011-12-14 17:25:42 +00:00
|
|
|
bool SCH_COMPONENT::IsReferenceStringValid( const wxString& aReferenceString )
|
2011-05-31 16:29:14 +00:00
|
|
|
{
|
|
|
|
wxString text = aReferenceString;
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
// Try to unannotate this reference
|
2011-12-07 18:47:59 +00:00
|
|
|
while( !text.IsEmpty() && ( text.Last() == '?' || isdigit( text.Last() ) ) )
|
2011-05-31 16:29:14 +00:00
|
|
|
text.RemoveLast();
|
|
|
|
|
|
|
|
if( text.IsEmpty() )
|
|
|
|
ok = false;
|
|
|
|
|
|
|
|
// Add here other constraints
|
|
|
|
// Currently:no other constraint
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:18:32 +00:00
|
|
|
void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
|
2008-02-12 21:12:46 +00:00
|
|
|
{
|
2016-02-15 20:22:45 +00:00
|
|
|
wxString path = GetPath( sheet );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
bool notInArray = true;
|
|
|
|
|
|
|
|
wxString h_path, h_ref;
|
|
|
|
wxStringTokenizer tokenizer;
|
|
|
|
wxString separators( wxT( " " ) );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
// check to see if it is already there before inserting it
|
2009-04-05 20:49:15 +00:00
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-02-21 12:21:01 +00:00
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
|
|
|
h_path = tokenizer.GetNextToken();
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
if( h_path.Cmp( path ) == 0 )
|
2008-02-21 12:21:01 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
// just update the reference text, not the timestamp.
|
2008-04-15 19:38:19 +00:00
|
|
|
h_ref = h_path + wxT( " " ) + ref;
|
|
|
|
h_ref += wxT( " " );
|
|
|
|
tokenizer.GetNextToken(); // Skip old reference
|
|
|
|
h_ref += tokenizer.GetNextToken(); // Add part selection
|
2016-06-24 10:55:54 +00:00
|
|
|
|
|
|
|
// Add the part selection
|
2008-04-15 19:38:19 +00:00
|
|
|
m_PathsAndReferences[ii] = h_ref;
|
2008-02-21 12:21:01 +00:00
|
|
|
notInArray = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( notInArray )
|
2010-12-14 15:56:30 +00:00
|
|
|
AddHierarchicalReference( path, ref, m_unit );
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_FIELD* rf = GetField( REFERENCE );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( rf->GetText().IsEmpty()
|
2017-01-23 20:30:11 +00:00
|
|
|
|| ( abs( rf->GetTextPos().x - m_Pos.x ) +
|
|
|
|
abs( rf->GetTextPos().y - m_Pos.y ) > 10000 ) )
|
2008-02-21 12:21:01 +00:00
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
// move it to a reasonable position
|
2017-01-23 20:30:11 +00:00
|
|
|
rf->SetTextPos( m_Pos + wxPoint( 50, 50 ) );
|
2008-02-21 12:21:01 +00:00
|
|
|
}
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
rf->SetText( ref ); // for drawing.
|
2009-10-30 19:26:25 +00:00
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
// Reinit the m_prefix member if needed
|
2009-10-27 19:30:32 +00:00
|
|
|
wxString prefix = ref;
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2011-05-31 16:29:14 +00:00
|
|
|
if( IsReferenceStringValid( prefix ) )
|
|
|
|
{
|
|
|
|
while( prefix.Last() == '?' || isdigit( prefix.Last() ) )
|
|
|
|
prefix.RemoveLast();
|
|
|
|
}
|
|
|
|
else
|
2011-12-07 18:47:59 +00:00
|
|
|
{
|
2011-12-12 20:59:43 +00:00
|
|
|
prefix = wxT( "U" ); // Set to default ref prefix
|
2011-12-07 18:47:59 +00:00
|
|
|
}
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
if( m_prefix != prefix )
|
|
|
|
m_prefix = prefix;
|
2008-02-12 21:12:46 +00:00
|
|
|
}
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2013-02-11 00:41:49 +00:00
|
|
|
void SCH_COMPONENT::SetTimeStamp( time_t aNewTimeStamp )
|
2009-04-25 10:12:30 +00:00
|
|
|
{
|
|
|
|
wxString string_timestamp, string_oldtimestamp;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2015-02-28 13:12:09 +00:00
|
|
|
string_timestamp.Printf( wxT( "%08lX" ), (long unsigned) aNewTimeStamp );
|
|
|
|
string_oldtimestamp.Printf( wxT( "%08lX" ), (long unsigned) m_TimeStamp );
|
2011-12-12 20:59:43 +00:00
|
|
|
EDA_ITEM::SetTimeStamp( aNewTimeStamp );
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2009-04-25 10:12:30 +00:00
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
m_PathsAndReferences[ii].Replace( string_oldtimestamp.GetData(),
|
2010-12-14 15:56:30 +00:00
|
|
|
string_timestamp.GetData() );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
2009-04-25 10:12:30 +00:00
|
|
|
}
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
|
2016-02-15 20:17:51 +00:00
|
|
|
int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet )
|
2008-04-16 08:40:31 +00:00
|
|
|
{
|
2016-02-15 20:22:45 +00:00
|
|
|
wxString path = GetPath( aSheet );
|
2008-04-16 08:40:31 +00:00
|
|
|
wxString h_path, h_multi;
|
|
|
|
wxStringTokenizer tokenizer;
|
|
|
|
wxString separators( wxT( " " ) );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-04-16 08:40:31 +00:00
|
|
|
{
|
|
|
|
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
|
|
|
h_path = tokenizer.GetNextToken();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
if( h_path.Cmp( path ) == 0 )
|
|
|
|
{
|
|
|
|
tokenizer.GetNextToken(); // Skip reference
|
|
|
|
h_multi = tokenizer.GetNextToken();
|
|
|
|
long imulti = 1;
|
|
|
|
h_multi.ToLong( &imulti );
|
|
|
|
return imulti;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
// if it was not found in m_Paths array, then use m_unit.
|
2008-04-16 08:40:31 +00:00
|
|
|
// this will happen if we load a version 1 schematic file.
|
2010-12-14 15:56:30 +00:00
|
|
|
return m_unit;
|
2008-04-16 08:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:16:54 +00:00
|
|
|
void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection )
|
2008-04-16 08:40:31 +00:00
|
|
|
{
|
2016-02-15 20:22:45 +00:00
|
|
|
wxString path = GetPath( aSheet );
|
2008-04-16 08:40:31 +00:00
|
|
|
|
|
|
|
bool notInArray = true;
|
|
|
|
|
|
|
|
wxString h_path, h_ref;
|
|
|
|
wxStringTokenizer tokenizer;
|
|
|
|
wxString separators( wxT( " " ) );
|
|
|
|
|
|
|
|
//check to see if it is already there before inserting it
|
2009-04-05 20:49:15 +00:00
|
|
|
for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-04-16 08:40:31 +00:00
|
|
|
{
|
|
|
|
tokenizer.SetString( m_PathsAndReferences[ii], separators );
|
|
|
|
h_path = tokenizer.GetNextToken();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
if( h_path.Cmp( path ) == 0 )
|
|
|
|
{
|
|
|
|
//just update the unit selection.
|
|
|
|
h_ref = h_path + wxT( " " );
|
|
|
|
h_ref += tokenizer.GetNextToken(); // Add reference
|
|
|
|
h_ref += wxT( " " );
|
|
|
|
h_ref << aUnitSelection; // Add part selection
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2008-04-16 08:40:31 +00:00
|
|
|
// Ann the part selection
|
|
|
|
m_PathsAndReferences[ii] = h_ref;
|
|
|
|
notInArray = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( notInArray )
|
2010-12-14 15:56:30 +00:00
|
|
|
AddHierarchicalReference( path, m_prefix, aUnitSelection );
|
2008-04-16 08:40:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
const SCH_FIELD* field;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
if( (unsigned) aFieldNdx < m_Fields.size() )
|
|
|
|
field = &m_Fields[aFieldNdx];
|
|
|
|
else
|
|
|
|
field = NULL;
|
2008-02-21 12:21:01 +00:00
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
wxASSERT( field );
|
2008-02-21 12:21:01 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// use cast to remove const-ness
|
2009-12-02 21:44:03 +00:00
|
|
|
return (SCH_FIELD*) field;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
void SCH_COMPONENT::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly )
|
|
|
|
{
|
2016-06-29 20:07:55 +00:00
|
|
|
for( SCH_FIELD& each_field : m_Fields )
|
2015-12-13 16:56:47 +00:00
|
|
|
{
|
|
|
|
if( !aVisibleOnly || ( each_field.IsVisible() && !each_field.IsVoid() ) )
|
|
|
|
aVector.push_back( &each_field );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
SCH_FIELD* SCH_COMPONENT::AddField( const SCH_FIELD& aField )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
int newNdx = m_Fields.size();
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2008-10-06 05:44:29 +00:00
|
|
|
m_Fields.push_back( aField );
|
2010-06-17 16:30:10 +00:00
|
|
|
return &m_Fields[newNdx];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName )
|
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
for( unsigned i = 0; i<m_Fields.size(); ++i )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
2011-12-07 18:47:59 +00:00
|
|
|
if( aFieldName == m_Fields[i].GetName( false ) )
|
2010-06-17 16:30:10 +00:00
|
|
|
return &m_Fields[i];
|
|
|
|
}
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
return NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-30 19:26:25 +00:00
|
|
|
LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number )
|
|
|
|
{
|
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( PART_SPTR part = m_part.lock() )
|
|
|
|
{
|
|
|
|
return part->GetPin( number, m_unit, m_convert );
|
|
|
|
}
|
|
|
|
return NULL;
|
2009-10-30 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2015-12-13 16:56:47 +00:00
|
|
|
void SCH_COMPONENT::GetPins( std::vector<LIB_PIN*>& aPinsList )
|
|
|
|
{
|
|
|
|
if( PART_SPTR part = m_part.lock() )
|
|
|
|
{
|
|
|
|
part->GetPins( aPinsList, m_unit, m_convert );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
wxFAIL_MSG( "Could not obtain PART_SPTR lock" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-08 17:41:52 +00:00
|
|
|
void SCH_COMPONENT::SwapData( SCH_ITEM* aItem )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-04-08 17:41:52 +00:00
|
|
|
wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_COMPONENT_T),
|
|
|
|
wxT( "Cannot swap data with invalid component." ) );
|
|
|
|
|
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) aItem;
|
|
|
|
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( m_part_name, component->m_part_name );
|
|
|
|
std::swap( m_part, component->m_part );
|
|
|
|
std::swap( m_Pos, component->m_Pos );
|
|
|
|
std::swap( m_unit, component->m_unit );
|
|
|
|
std::swap( m_convert, component->m_convert );
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2010-12-14 21:39:31 +00:00
|
|
|
TRANSFORM tmp = m_transform;
|
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-08 17:41:52 +00:00
|
|
|
m_transform = component->m_transform;
|
|
|
|
component->m_transform = tmp;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2011-04-08 17:41:52 +00:00
|
|
|
m_Fields.swap( component->m_Fields ); // std::vector's swap()
|
2008-10-18 13:42:21 +00:00
|
|
|
|
2008-10-19 10:13:04 +00:00
|
|
|
// Reparent items after copying data
|
2008-10-19 18:31:09 +00:00
|
|
|
// (after swap(), m_Parent member does not point to the right parent):
|
2011-04-08 17:41:52 +00:00
|
|
|
for( int ii = 0; ii < component->GetFieldCount(); ++ii )
|
2008-10-18 13:42:21 +00:00
|
|
|
{
|
2011-04-08 17:41:52 +00:00
|
|
|
component->GetField( ii )->SetParent( component );
|
2008-10-18 13:42:21 +00:00
|
|
|
}
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2008-10-18 13:42:21 +00:00
|
|
|
for( int ii = 0; ii < GetFieldCount(); ++ii )
|
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
GetField( ii )->SetParent( this );
|
2008-10-18 13:42:21 +00:00
|
|
|
}
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( m_PathsAndReferences, component->m_PathsAndReferences );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:22:45 +00:00
|
|
|
void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
bool keepMulti = false;
|
2009-09-18 14:56:05 +00:00
|
|
|
wxArrayString reference_fields;
|
2008-04-15 19:38: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
|
|
|
static const wxChar separators[] = wxT( " " );
|
|
|
|
|
|
|
|
PART_SPTR part = m_part.lock();
|
2008-04-15 19:38:19 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
if( part && part->UnitsLocked() )
|
2011-02-28 18:36:19 +00:00
|
|
|
keepMulti = true;
|
2008-02-21 12:21:01 +00:00
|
|
|
|
2011-05-31 16:29:14 +00:00
|
|
|
// Build a reference with no annotation,
|
|
|
|
// i.e. a reference ended by only one '?'
|
|
|
|
wxString defRef = m_prefix;
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2011-05-31 16:29:14 +00:00
|
|
|
if( IsReferenceStringValid( defRef ) )
|
|
|
|
{
|
|
|
|
while( defRef.Last() == '?' )
|
|
|
|
defRef.RemoveLast();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // This is a malformed reference: reinit this reference
|
2016-02-15 20:22:45 +00:00
|
|
|
m_prefix = defRef = wxT("U"); // Set to default ref prefix
|
2011-05-31 16:29:14 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
defRef.Append( wxT( "?" ) );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
|
|
|
wxString multi = wxT( "1" );
|
2008-09-20 17:20:40 +00:00
|
|
|
|
2011-02-28 19:06:27 +00:00
|
|
|
// For components with units locked,
|
|
|
|
// we cannot remove all annotations: part selection must be kept
|
2016-02-15 20:22:45 +00:00
|
|
|
// For all components: if aSheetPath is not NULL,
|
2011-02-28 19:06:27 +00:00
|
|
|
// remove annotation only for the given path
|
2016-02-15 20:22:45 +00:00
|
|
|
if( keepMulti || aSheetPath )
|
2008-02-21 12:21:01 +00:00
|
|
|
{
|
2008-05-15 11:20:19 +00:00
|
|
|
wxString NewHref;
|
|
|
|
wxString path;
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2016-02-15 20:22:45 +00:00
|
|
|
if( aSheetPath )
|
|
|
|
path = GetPath( aSheetPath );
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2009-10-30 19:26:25 +00:00
|
|
|
// Break hierarchical reference in path, ref and multi selection:
|
2010-12-14 15:56:30 +00:00
|
|
|
reference_fields = wxStringTokenize( m_PathsAndReferences[ii], separators );
|
|
|
|
|
2016-02-15 20:22:45 +00:00
|
|
|
if( aSheetPath == NULL || reference_fields[0].Cmp( path ) == 0 )
|
2008-05-15 11:20:19 +00:00
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
if( keepMulti ) // Get and keep part selection
|
2008-05-15 11:20:19 +00:00
|
|
|
multi = reference_fields[2];
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2008-05-15 11:20:19 +00:00
|
|
|
NewHref = reference_fields[0];
|
|
|
|
NewHref << wxT( " " ) << defRef << wxT( " " ) << multi;
|
|
|
|
m_PathsAndReferences[ii] = NewHref;
|
|
|
|
}
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
2008-02-21 12:21:01 +00:00
|
|
|
}
|
2008-05-15 11:20:19 +00:00
|
|
|
else
|
|
|
|
{
|
2011-02-28 19:06:27 +00:00
|
|
|
// Clear reference strings, but does not free memory because a new annotation
|
2009-04-05 20:49:15 +00:00
|
|
|
// will reuse it
|
|
|
|
m_PathsAndReferences.Empty();
|
2010-12-14 15:56:30 +00:00
|
|
|
m_unit = 1;
|
2008-05-15 11:20:19 +00:00
|
|
|
}
|
|
|
|
|
2008-04-21 06:34:56 +00:00
|
|
|
// These 2 changes do not work in complex hierarchy.
|
|
|
|
// When a clear annotation is made, the calling function must call a
|
|
|
|
// UpdateAllScreenReferences for the active sheet.
|
2008-05-15 11:20:19 +00:00
|
|
|
// But this call cannot made here.
|
2013-03-18 19:36:07 +00:00
|
|
|
m_Fields[REFERENCE].SetText( defRef ); //for drawing.
|
2010-12-31 19:47:39 +00:00
|
|
|
|
|
|
|
SetModified();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
void SCH_COMPONENT::SetOrientation( int aOrientation )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-10-20 20:24:26 +00:00
|
|
|
TRANSFORM temp = TRANSFORM();
|
2011-07-15 13:17:41 +00:00
|
|
|
bool transform = false;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
switch( aOrientation )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
|
|
|
case CMP_ORIENT_0:
|
2010-12-23 10:00:55 +00:00
|
|
|
case CMP_NORMAL: // default transform matrix
|
2010-12-14 21:39:31 +00:00
|
|
|
m_transform.x1 = 1;
|
|
|
|
m_transform.y2 = -1;
|
|
|
|
m_transform.x2 = m_transform.y1 = 0;
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2014-02-22 12:39:59 +00:00
|
|
|
case CMP_ROTATE_COUNTERCLOCKWISE: // Rotate + (incremental rotation)
|
2010-10-20 20:24:26 +00:00
|
|
|
temp.x1 = temp.y2 = 0;
|
|
|
|
temp.y1 = 1;
|
|
|
|
temp.x2 = -1;
|
2011-07-15 13:17:41 +00:00
|
|
|
transform = true;
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2014-02-22 12:39:59 +00:00
|
|
|
case CMP_ROTATE_CLOCKWISE: // Rotate - (incremental rotation)
|
2010-10-20 20:24:26 +00:00
|
|
|
temp.x1 = temp.y2 = 0;
|
|
|
|
temp.y1 = -1;
|
|
|
|
temp.x2 = 1;
|
2011-07-15 13:17:41 +00:00
|
|
|
transform = true;
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-23 10:00:55 +00:00
|
|
|
case CMP_MIRROR_Y: // Mirror Y (incremental rotation)
|
2010-10-20 20:24:26 +00:00
|
|
|
temp.x1 = -1;
|
|
|
|
temp.y2 = 1;
|
|
|
|
temp.y1 = temp.x2 = 0;
|
2011-07-15 13:17:41 +00:00
|
|
|
transform = true;
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-23 10:00:55 +00:00
|
|
|
case CMP_MIRROR_X: // Mirror X (incremental rotation)
|
2010-10-20 20:24:26 +00:00
|
|
|
temp.x1 = 1;
|
|
|
|
temp.y2 = -1;
|
|
|
|
temp.y1 = temp.x2 = 0;
|
2011-10-07 14:41:30 +00:00
|
|
|
transform = true;
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMP_ORIENT_90:
|
2010-01-13 21:15:54 +00:00
|
|
|
SetOrientation( CMP_ORIENT_0 );
|
|
|
|
SetOrientation( CMP_ROTATE_COUNTERCLOCKWISE );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMP_ORIENT_180:
|
2010-01-13 21:15:54 +00:00
|
|
|
SetOrientation( CMP_ORIENT_0 );
|
|
|
|
SetOrientation( CMP_ROTATE_COUNTERCLOCKWISE );
|
|
|
|
SetOrientation( CMP_ROTATE_COUNTERCLOCKWISE );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CMP_ORIENT_270:
|
2010-01-13 21:15:54 +00:00
|
|
|
SetOrientation( CMP_ORIENT_0 );
|
|
|
|
SetOrientation( CMP_ROTATE_CLOCKWISE );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
case ( CMP_ORIENT_0 + CMP_MIRROR_X ):
|
|
|
|
SetOrientation( CMP_ORIENT_0 );
|
|
|
|
SetOrientation( CMP_MIRROR_X );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
case ( CMP_ORIENT_0 + CMP_MIRROR_Y ):
|
|
|
|
SetOrientation( CMP_ORIENT_0 );
|
|
|
|
SetOrientation( CMP_MIRROR_Y );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
case ( CMP_ORIENT_90 + CMP_MIRROR_X ):
|
|
|
|
SetOrientation( CMP_ORIENT_90 );
|
|
|
|
SetOrientation( CMP_MIRROR_X );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
case ( CMP_ORIENT_90 + CMP_MIRROR_Y ):
|
|
|
|
SetOrientation( CMP_ORIENT_90 );
|
|
|
|
SetOrientation( CMP_MIRROR_Y );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
case ( CMP_ORIENT_180 + CMP_MIRROR_X ):
|
|
|
|
SetOrientation( CMP_ORIENT_180 );
|
|
|
|
SetOrientation( CMP_MIRROR_X );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
case ( CMP_ORIENT_180 + CMP_MIRROR_Y ):
|
|
|
|
SetOrientation( CMP_ORIENT_180 );
|
|
|
|
SetOrientation( CMP_MIRROR_Y );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
case ( CMP_ORIENT_270 + CMP_MIRROR_X ):
|
|
|
|
SetOrientation( CMP_ORIENT_270 );
|
|
|
|
SetOrientation( CMP_MIRROR_X );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
case ( CMP_ORIENT_270 + CMP_MIRROR_Y ):
|
|
|
|
SetOrientation( CMP_ORIENT_270 );
|
|
|
|
SetOrientation( CMP_MIRROR_Y );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-01-22 17:20:22 +00:00
|
|
|
transform = false;
|
2009-07-27 14:32:40 +00:00
|
|
|
wxMessageBox( wxT( "SetRotateMiroir() error: ill value" ) );
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-07-15 13:17:41 +00:00
|
|
|
if( transform )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
|
|
|
/* The new matrix transform is the old matrix transform modified by the
|
2010-12-23 10:00:55 +00:00
|
|
|
* requested transformation, which is the temp transform (rot,
|
2009-04-05 20:49:15 +00:00
|
|
|
* mirror ..) in order to have (in term of matrix transform):
|
2010-12-14 21:39:31 +00:00
|
|
|
* transform coord = new_m_transform * coord
|
|
|
|
* where transform coord is the coord modified by new_m_transform from
|
2009-04-05 20:49:15 +00:00
|
|
|
* the initial value coord.
|
2010-12-23 10:00:55 +00:00
|
|
|
* new_m_transform is computed (from old_m_transform and temp) to
|
2009-04-05 20:49:15 +00:00
|
|
|
* have:
|
2010-12-23 10:00:55 +00:00
|
|
|
* transform coord = old_m_transform * temp
|
2008-04-12 18:39:20 +00:00
|
|
|
*/
|
2010-10-20 20:24:26 +00:00
|
|
|
TRANSFORM newTransform;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2010-12-14 21:39:31 +00:00
|
|
|
newTransform.x1 = m_transform.x1 * temp.x1 + m_transform.x2 * temp.y1;
|
|
|
|
newTransform.y1 = m_transform.y1 * temp.x1 + m_transform.y2 * temp.y1;
|
|
|
|
newTransform.x2 = m_transform.x1 * temp.x2 + m_transform.x2 * temp.y2;
|
|
|
|
newTransform.y2 = m_transform.y1 * temp.x2 + m_transform.y2 * temp.y2;
|
|
|
|
m_transform = newTransform;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
int SCH_COMPONENT::GetOrientation()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
int type_rotate = CMP_ORIENT_0;
|
2010-10-20 20:24:26 +00:00
|
|
|
TRANSFORM transform;
|
2010-09-05 17:01:48 +00:00
|
|
|
int ii;
|
2009-04-17 08:51:02 +00:00
|
|
|
|
2009-04-09 11:34:41 +00:00
|
|
|
#define ROTATE_VALUES_COUNT 12
|
2009-12-02 21:44:03 +00:00
|
|
|
|
|
|
|
// list of all possibilities, but only the first 8 are actually used
|
|
|
|
int rotate_value[ROTATE_VALUES_COUNT] =
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
CMP_ORIENT_0, CMP_ORIENT_90, CMP_ORIENT_180,
|
|
|
|
CMP_ORIENT_270,
|
|
|
|
CMP_MIRROR_X + CMP_ORIENT_0, CMP_MIRROR_X + CMP_ORIENT_90,
|
2010-01-13 21:15:54 +00:00
|
|
|
CMP_MIRROR_X + CMP_ORIENT_180, CMP_MIRROR_X + CMP_ORIENT_270,
|
2010-09-05 17:01:48 +00:00
|
|
|
CMP_MIRROR_Y + CMP_ORIENT_0, CMP_MIRROR_Y + CMP_ORIENT_90,
|
2010-01-13 21:15:54 +00:00
|
|
|
CMP_MIRROR_Y + CMP_ORIENT_180, CMP_MIRROR_Y + CMP_ORIENT_270
|
2009-04-09 11:34:41 +00:00
|
|
|
};
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-04-09 11:34:41 +00:00
|
|
|
// Try to find the current transform option:
|
2010-12-14 21:39:31 +00:00
|
|
|
transform = m_transform;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-04-09 11:34:41 +00:00
|
|
|
for( ii = 0; ii < ROTATE_VALUES_COUNT; ii++ )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2009-04-09 11:34:41 +00:00
|
|
|
type_rotate = rotate_value[ii];
|
2010-01-13 21:15:54 +00:00
|
|
|
SetOrientation( type_rotate );
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2010-12-14 21:39:31 +00:00
|
|
|
if( transform == m_transform )
|
2009-04-09 11:34:41 +00:00
|
|
|
return type_rotate;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
2009-04-09 11:34:41 +00:00
|
|
|
// Error: orientation not found in list (should not happen)
|
2010-09-05 17:01:48 +00:00
|
|
|
wxMessageBox( wxT( "Component orientation matrix internal error" ) );
|
2010-12-14 21:39:31 +00:00
|
|
|
m_transform = transform;
|
2010-10-20 20:24:26 +00:00
|
|
|
|
2009-04-09 11:34:41 +00:00
|
|
|
return CMP_NORMAL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2010-12-14 21:39:31 +00:00
|
|
|
wxPoint SCH_COMPONENT::GetScreenCoord( const wxPoint& aPoint )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2010-12-14 21:39:31 +00:00
|
|
|
return m_transform.TransformCoordinate( aPoint );
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
#if defined(DEBUG)
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
void SCH_COMPONENT::Show( int nestLevel, std::ostream& os ) const
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-09-20 21:06:49 +00:00
|
|
|
// for now, make it look like XML:
|
2009-12-02 21:44:03 +00:00
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
|
2011-03-25 19:16:05 +00:00
|
|
|
<< " ref=\"" << TO_UTF8( GetField( 0 )->GetName() )
|
2009-12-02 21:44:03 +00:00
|
|
|
<< '"' << " chipName=\""
|
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
|
|
|
<< TO_UTF8( GetPartName() ) << '"' << m_Pos
|
2009-12-02 21:44:03 +00:00
|
|
|
<< " layer=\"" << m_Layer
|
2010-08-03 05:11:05 +00:00
|
|
|
<< '"' << ">\n";
|
2008-02-21 12:21:01 +00:00
|
|
|
|
|
|
|
// skip the reference, it's been output already.
|
2009-04-05 20:49:15 +00:00
|
|
|
for( int i = 1; i < GetFieldCount(); ++i )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
wxString value = GetField( i )->GetText();
|
2008-02-21 12:21:01 +00:00
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
if( !value.IsEmpty() )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
NestedSpace( nestLevel + 1, os ) << "<field" << " name=\""
|
2011-03-25 19:16:05 +00:00
|
|
|
<< TO_UTF8( GetField( i )->GetName() )
|
2010-09-05 17:01:48 +00:00
|
|
|
<< '"' << " value=\""
|
2011-02-28 18:36:19 +00:00
|
|
|
<< TO_UTF8( value ) << "\"/>\n";
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2008-02-21 12:21:01 +00:00
|
|
|
}
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
NestedSpace( nestLevel, os ) << "</" << TO_UTF8( GetClass().Lower() ) << ">\n";
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
#endif
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
bool SCH_COMPONENT::Save( FILE* f ) const
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2011-07-15 13:17:41 +00:00
|
|
|
std::string name1;
|
|
|
|
std::string name2;
|
2008-04-15 19:38:19 +00:00
|
|
|
wxArrayString reference_fields;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
static wxString delimiters( wxT( " " ) );
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2013-05-24 21:30:27 +00:00
|
|
|
// this is redundant with the AR entries below, but it makes the
|
|
|
|
// files backwards-compatible.
|
2008-04-15 19:38:19 +00:00
|
|
|
if( m_PathsAndReferences.GetCount() > 0 )
|
|
|
|
{
|
2011-12-07 18:47:59 +00:00
|
|
|
reference_fields = wxStringTokenize( m_PathsAndReferences[0], delimiters );
|
2011-07-15 13:17:41 +00:00
|
|
|
|
|
|
|
name1 = toUTFTildaText( reference_fields[1] );
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
2008-04-12 18:39:20 +00:00
|
|
|
else
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
if( GetField( REFERENCE )->GetText().IsEmpty() )
|
2011-07-15 13:17:41 +00:00
|
|
|
name1 = toUTFTildaText( m_prefix );
|
2008-04-12 18:39:20 +00:00
|
|
|
else
|
2013-03-18 19:36:07 +00:00
|
|
|
name1 = toUTFTildaText( GetField( REFERENCE )->GetText() );
|
2008-04-12 18:39:20 +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
|
|
|
wxString part_name = GetPartName();
|
|
|
|
|
|
|
|
if( part_name.size() )
|
2008-04-12 18:39:20 +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
|
|
|
name2 = toUTFTildaText( part_name );
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
else
|
2011-12-07 18:47:59 +00:00
|
|
|
{
|
2011-07-15 13:17:41 +00:00
|
|
|
name2 = NULL_STRING;
|
2011-12-07 18:47:59 +00:00
|
|
|
}
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
if( fprintf( f, "$Comp\n" ) == EOF )
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2011-07-15 13:17:41 +00:00
|
|
|
if( fprintf( f, "L %s %s\n", name2.c_str(), name1.c_str() ) == EOF )
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
2008-04-12 18:39:20 +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
|
|
|
// Generate unit number, convert and time stamp
|
2016-03-14 18:20:19 +00:00
|
|
|
if( fprintf( f, "U %d %d %8.8lX\n", m_unit, m_convert, (unsigned long)m_TimeStamp ) == EOF )
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
2008-04-12 18:39:20 +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
|
|
|
// Save the position
|
2008-04-12 18:39:20 +00:00
|
|
|
if( fprintf( f, "P %d %d\n", m_Pos.x, m_Pos.y ) == EOF )
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
|
|
|
/* If this is a complex hierarchy; save hierarchical references.
|
2008-04-16 08:40:31 +00:00
|
|
|
* but for simple hierarchies it is not necessary.
|
|
|
|
* the reference inf is already saved
|
2011-09-30 18:15:37 +00:00
|
|
|
* this is useful for old Eeschema version compatibility
|
2008-04-15 19:38:19 +00:00
|
|
|
*/
|
|
|
|
if( m_PathsAndReferences.GetCount() > 1 )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
/*format:
|
|
|
|
* AR Path="/140/2" Ref="C99" Part="1"
|
|
|
|
* where 140 is the uid of the containing sheet
|
|
|
|
* and 2 is the timestamp of this component.
|
|
|
|
* (timestamps are actually 8 hex chars)
|
|
|
|
* Ref is the conventional component reference for this 'path'
|
|
|
|
* Part is the conventional component part selection for this 'path'
|
|
|
|
*/
|
2010-12-14 15:56:30 +00:00
|
|
|
reference_fields = wxStringTokenize( m_PathsAndReferences[ii], delimiters );
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
if( fprintf( f, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n",
|
2011-02-28 18:36:19 +00:00
|
|
|
TO_UTF8( reference_fields[0] ),
|
|
|
|
TO_UTF8( reference_fields[1] ),
|
|
|
|
TO_UTF8( reference_fields[2] ) ) == EOF )
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// update the ugly field index, which I would like to see go away someday soon.
|
2010-09-05 17:01:48 +00:00
|
|
|
for( unsigned i = 0; i<m_Fields.size(); ++i )
|
2008-04-12 18:39:20 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
SCH_FIELD* fld = GetField( i );
|
2011-12-07 18:47:59 +00:00
|
|
|
fld->SetId( i ); // we don't need field Ids, please be gone.
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// Fixed fields:
|
2013-05-24 21:30:27 +00:00
|
|
|
// Save mandatory fields even if they are blank,
|
|
|
|
// because the visibility, size and orientation are set from libary editor.
|
2010-09-05 17:01:48 +00:00
|
|
|
for( unsigned i = 0; i<MANDATORY_FIELDS; ++i )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
|
|
|
SCH_FIELD* fld = GetField( i );
|
2013-02-11 18:50:55 +00:00
|
|
|
if( !fld->Save( f ) )
|
|
|
|
return false;
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// User defined fields:
|
|
|
|
// The *policy* about which user defined fields are part of a symbol is now
|
|
|
|
// only in the dialog editors. No policy should be enforced here, simply
|
|
|
|
// save all the user defined fields, they are present because a dialog editor
|
|
|
|
// thought they should be. If you disagree, go fix the dialog editors.
|
2010-09-05 17:01:48 +00:00
|
|
|
for( unsigned i = MANDATORY_FIELDS; i<m_Fields.size(); ++i )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
|
|
|
SCH_FIELD* fld = GetField( i );
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
if( !fld->Save( f ) )
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
2008-04-12 18:39:20 +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
|
|
|
// Unit number, position, box ( old standard )
|
2010-12-14 15:56:30 +00:00
|
|
|
if( fprintf( f, "\t%-4d %-4d %-4d\n", m_unit, m_Pos.x, m_Pos.y ) == EOF )
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
|
|
|
if( fprintf( f, "\t%-4d %-4d %-4d %-4d\n",
|
2010-12-14 21:39:31 +00:00
|
|
|
m_transform.x1, m_transform.y1, m_transform.x2, m_transform.y2 ) == EOF )
|
2009-04-05 20:49:15 +00:00
|
|
|
return false;
|
2008-04-12 18:39:20 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( fprintf( f, "$EndComp\n" ) == EOF )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2008-04-15 19:38:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|
|
|
{
|
2015-08-13 10:48:14 +00:00
|
|
|
// Remark: avoid using sscanf to read texts entered by user
|
|
|
|
// which are UTF8 encoded, because sscanf does not work well on Windows
|
|
|
|
// with some UTF8 values.
|
2016-03-14 18:20:19 +00:00
|
|
|
char name1[256], char1[256], char2[256], char3[256];
|
|
|
|
int newfmt = 0;
|
|
|
|
char* ptcar;
|
|
|
|
wxString fieldName;
|
|
|
|
char* line = aLine.Line();
|
|
|
|
unsigned long timeStamp;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
m_convert = 1;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2011-02-27 06:22:34 +00:00
|
|
|
if( line[0] == '$' )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
|
|
|
newfmt = 1;
|
|
|
|
|
2013-05-24 21:30:27 +00:00
|
|
|
if( !(line = aLine.ReadLine()) )
|
2011-10-07 14:41:30 +00:00
|
|
|
return true;
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
2015-08-13 10:48:14 +00:00
|
|
|
// Parse the first line of description:
|
|
|
|
// like "L partname ref" (for instance "L 74LS00 U4"
|
|
|
|
// They are UTF8 texts, so do not use sscanf
|
|
|
|
|
|
|
|
line += 1;
|
|
|
|
|
|
|
|
if( *line == ' ' )
|
|
|
|
line++;
|
|
|
|
|
|
|
|
// line points the first parameter
|
|
|
|
wxString buffer( FROM_UTF8( line ) );
|
|
|
|
wxStringTokenizer tokenizer( buffer, wxT( " \r\n" ) );
|
|
|
|
|
|
|
|
if( tokenizer.CountTokens() < 2 )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema component description error at line %d, aborted" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
2011-02-28 18:36:19 +00:00
|
|
|
aErrorMsg << wxT( "\n" ) << FROM_UTF8( line );
|
2010-11-10 15:30:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-08-13 10:48:14 +00:00
|
|
|
wxString partname = tokenizer.NextToken();
|
|
|
|
partname.Replace( wxT("~"), wxT(" ") ); // all spaces were replaced by ~ in files.
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2015-08-13 10:48:14 +00:00
|
|
|
if( partname != NULL_STRING )
|
|
|
|
{
|
|
|
|
SetPartName( partname );
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
if( !newfmt )
|
2015-08-13 10:48:14 +00:00
|
|
|
GetField( VALUE )->SetText( partname );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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_part_name.Empty();
|
2013-03-18 19:36:07 +00:00
|
|
|
GetField( VALUE )->Empty();
|
2017-01-23 20:30:11 +00:00
|
|
|
GetField( VALUE )->SetTextAngle( TEXT_ANGLE_HORIZ );
|
2013-03-18 19:36:07 +00:00
|
|
|
GetField( VALUE )->SetVisible( false );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
2015-08-13 10:48:14 +00:00
|
|
|
wxString reference = tokenizer.NextToken();
|
|
|
|
reference.Replace( wxT("~"), wxT(" ") ); // all spaces were replaced by ~ in files.
|
|
|
|
reference.Trim( true );
|
|
|
|
reference.Trim( false );
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2015-08-13 10:48:14 +00:00
|
|
|
if( reference != NULL_STRING )
|
|
|
|
{
|
|
|
|
wxString prefix = reference;
|
|
|
|
// Build reference prefix from the actual reference by removing trailing digits
|
|
|
|
// (Perhaps outdated code, only for very old schematic files)
|
|
|
|
while( prefix.Length() )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
2015-08-13 10:48:14 +00:00
|
|
|
if( ( prefix.Last() < '0' || prefix.Last() > '9') && prefix.Last() != '?' )
|
|
|
|
break;
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2015-08-13 10:48:14 +00:00
|
|
|
prefix.RemoveLast();
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
2015-08-13 10:48:14 +00:00
|
|
|
// Avoid a prefix containing trailing/leading spaces
|
|
|
|
prefix.Trim( true );
|
|
|
|
prefix.Trim( false );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2015-08-13 10:48:14 +00:00
|
|
|
if( prefix.IsEmpty() )
|
2010-12-14 15:56:30 +00:00
|
|
|
m_prefix = wxT( "U" );
|
2010-11-10 15:30:12 +00:00
|
|
|
else
|
2015-08-13 10:48:14 +00:00
|
|
|
m_prefix = prefix;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
if( !newfmt )
|
2015-08-13 10:48:14 +00:00
|
|
|
GetField( REFERENCE )->SetText( reference );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
GetField( REFERENCE )->SetVisible( false );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse component description
|
|
|
|
* These lines begin with:
|
|
|
|
* "P" = Position
|
|
|
|
* U = Num Unit and Conversion
|
|
|
|
* "Fn" = Fields (0 .. n = = number of field)
|
|
|
|
* "Ar" = Alternate reference in the case of multiple sheets referring to
|
|
|
|
* one schematic file.
|
|
|
|
*/
|
|
|
|
for( ; ; )
|
|
|
|
{
|
2013-05-24 21:30:27 +00:00
|
|
|
if( !(line = aLine.ReadLine()) )
|
2010-11-10 15:30:12 +00:00
|
|
|
return false;
|
|
|
|
|
2011-02-27 06:22:34 +00:00
|
|
|
if( line[0] == 'U' )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
2016-03-14 18:20:19 +00:00
|
|
|
sscanf( line + 1, "%d %d %lX", &m_unit, &m_convert, &timeStamp );
|
|
|
|
m_TimeStamp = (time_t)timeStamp;
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
2011-02-27 06:22:34 +00:00
|
|
|
else if( line[0] == 'P' )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
2011-02-27 06:22:34 +00:00
|
|
|
sscanf( line + 1, "%d %d", &m_Pos.x, &m_Pos.y );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
// Set fields position to a default position (that is the
|
|
|
|
// component position. For existing fields, the real position
|
|
|
|
// will be set later
|
2013-03-18 19:36:07 +00:00
|
|
|
for( int i = 0; i<GetFieldCount(); i++ )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
if( GetField( i )->GetText().IsEmpty() )
|
2017-01-23 20:30:11 +00:00
|
|
|
GetField( i )->SetTextPos( m_Pos );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-27 06:22:34 +00:00
|
|
|
else if( line[0] == 'A' && line[1] == 'R' )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
|
|
|
/* format:
|
|
|
|
* AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1"
|
|
|
|
* where 9086AF6E is the unique timestamp of the containing sheet
|
|
|
|
* and 67452AA0 is the timestamp of this component.
|
|
|
|
* C99 is the reference given this path.
|
|
|
|
*/
|
|
|
|
int ii;
|
2011-02-27 06:22:34 +00:00
|
|
|
ptcar = line + 2;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
//copy the path.
|
2011-07-15 13:17:41 +00:00
|
|
|
ii = ReadDelimitedText( name1, ptcar, 255 );
|
2010-11-10 15:30:12 +00:00
|
|
|
ptcar += ii + 1;
|
2011-07-15 13:17:41 +00:00
|
|
|
wxString path = FROM_UTF8( name1 );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
// copy the reference
|
2011-07-15 13:17:41 +00:00
|
|
|
ii = ReadDelimitedText( name1, ptcar, 255 );
|
2010-11-10 15:30:12 +00:00
|
|
|
ptcar += ii + 1;
|
2011-07-15 13:17:41 +00:00
|
|
|
wxString ref = FROM_UTF8( name1 );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
// copy the multi, if exists
|
2011-07-15 13:17:41 +00:00
|
|
|
ii = ReadDelimitedText( name1, ptcar, 255 );
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2011-07-15 13:17:41 +00:00
|
|
|
if( name1[0] == 0 ) // Nothing read, put a default value
|
|
|
|
sprintf( name1, "%d", m_unit );
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2011-07-15 13:17:41 +00:00
|
|
|
int multi = atoi( name1 );
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2013-11-26 09:15:20 +00:00
|
|
|
if( multi < 0 || multi > 26 )
|
2010-11-10 15:30:12 +00:00
|
|
|
multi = 1;
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
AddHierarchicalReference( path, ref, multi );
|
2013-03-18 19:36:07 +00:00
|
|
|
GetField( REFERENCE )->SetText( ref );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
2011-02-27 06:22:34 +00:00
|
|
|
else if( line[0] == 'F' )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
|
|
|
int fieldNdx;
|
|
|
|
|
2011-03-25 20:07:27 +00:00
|
|
|
wxString fieldText;
|
2012-01-03 17:14:17 +00:00
|
|
|
EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER;
|
|
|
|
EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER;
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
ptcar = (char*) aLine;
|
|
|
|
|
|
|
|
while( *ptcar && (*ptcar != '"') )
|
|
|
|
ptcar++;
|
|
|
|
|
|
|
|
if( *ptcar != '"' )
|
|
|
|
{
|
2011-09-30 18:15:37 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Eeschema file library field F at line %d, aborted" ),
|
2010-11-10 15:30:12 +00:00
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-03-25 20:07:27 +00:00
|
|
|
ptcar += ReadDelimitedText( &fieldText, ptcar );
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2011-03-25 20:07:27 +00:00
|
|
|
if( *ptcar == 0 )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
2011-03-25 20:07:27 +00:00
|
|
|
aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ),
|
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
2011-02-27 06:22:34 +00:00
|
|
|
fieldNdx = atoi( line + 2 );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2011-03-25 20:07:27 +00:00
|
|
|
ReadDelimitedText( &fieldName, ptcar );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2011-03-25 20:07:27 +00:00
|
|
|
if( fieldName.IsEmpty() )
|
2010-11-10 15:30:12 +00:00
|
|
|
fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx );
|
|
|
|
|
|
|
|
if( fieldNdx >= GetFieldCount() )
|
|
|
|
{
|
|
|
|
// The first MANDATOR_FIELDS _must_ be constructed within
|
|
|
|
// the SCH_COMPONENT constructor. This assert is simply here
|
|
|
|
// to guard against a change in that constructor.
|
|
|
|
wxASSERT( GetFieldCount() >= MANDATORY_FIELDS );
|
|
|
|
|
|
|
|
// Ignore the _supplied_ fieldNdx. It is not important anymore
|
|
|
|
// if within the user defined fields region (i.e. >= MANDATORY_FIELDS).
|
|
|
|
// We freely renumber the index to fit the next available field slot.
|
|
|
|
|
|
|
|
fieldNdx = GetFieldCount(); // new has this index after insertion
|
|
|
|
|
|
|
|
SCH_FIELD field( wxPoint( 0, 0 ),
|
|
|
|
-1, // field id is not relavant for user defined fields
|
|
|
|
this, fieldName );
|
|
|
|
|
|
|
|
AddField( field );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-07 18:47:59 +00:00
|
|
|
GetField( fieldNdx )->SetName( fieldName );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
GetField( fieldNdx )->SetText( fieldText );
|
2011-07-15 13:17:41 +00:00
|
|
|
memset( char3, 0, sizeof(char3) );
|
2016-04-16 09:57:42 +00:00
|
|
|
int ii, x, y, w, attr;
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2015-06-25 08:53:45 +00:00
|
|
|
if( ( ii = sscanf( ptcar, "%255s %d %d %d %X %255s %255s", char1, &x, &y, &w, &attr,
|
2011-07-15 13:17:41 +00:00
|
|
|
char2, char3 ) ) < 4 )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
|
|
|
aErrorMsg.Printf( wxT( "Component Field error line %d, aborted" ),
|
|
|
|
aLine.LineNumber() );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
GetField( fieldNdx )->SetTextPos( wxPoint( x, y ) );
|
|
|
|
GetField( fieldNdx )->SetVisible( !attr );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( (w == 0 ) || (ii == 4) )
|
2014-05-16 13:57:53 +00:00
|
|
|
w = GetDefaultTextSize();
|
2013-03-18 19:36:07 +00:00
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
GetField( fieldNdx )->SetTextSize( wxSize( w, w ) );
|
|
|
|
GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_HORIZ );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2011-07-15 13:17:41 +00:00
|
|
|
if( char1[0] == 'V' )
|
2017-01-23 20:30:11 +00:00
|
|
|
GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_VERT );
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
if( ii >= 7 )
|
|
|
|
{
|
2011-07-15 13:17:41 +00:00
|
|
|
if( *char2 == 'L' )
|
2010-11-10 15:30:12 +00:00
|
|
|
hjustify = GR_TEXT_HJUSTIFY_LEFT;
|
2011-07-15 13:17:41 +00:00
|
|
|
else if( *char2 == 'R' )
|
2010-11-10 15:30:12 +00:00
|
|
|
hjustify = GR_TEXT_HJUSTIFY_RIGHT;
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2011-07-15 13:17:41 +00:00
|
|
|
if( char3[0] == 'B' )
|
2010-11-10 15:30:12 +00:00
|
|
|
vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
|
2011-07-15 13:17:41 +00:00
|
|
|
else if( char3[0] == 'T' )
|
2010-11-10 15:30:12 +00:00
|
|
|
vjustify = GR_TEXT_VJUSTIFY_TOP;
|
2011-12-07 18:47:59 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
GetField( fieldNdx )->SetItalic( char3[1] == 'I' );
|
|
|
|
GetField( fieldNdx )->SetBold( char3[2] == 'B' );
|
|
|
|
GetField( fieldNdx )->SetHorizJustify( hjustify );
|
|
|
|
GetField( fieldNdx )->SetVertJustify( vjustify );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( fieldNdx == REFERENCE )
|
2013-03-18 19:36:07 +00:00
|
|
|
if( GetField( fieldNdx )->GetText()[0] == '#' )
|
|
|
|
GetField( fieldNdx )->SetVisible( false );
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
else
|
2011-12-07 18:47:59 +00:00
|
|
|
{
|
2010-11-10 15:30:12 +00:00
|
|
|
break;
|
2011-12-07 18:47:59 +00:00
|
|
|
}
|
2010-11-10 15:30:12 +00:00
|
|
|
}
|
|
|
|
|
2011-02-27 06:22:34 +00:00
|
|
|
if( sscanf( line, "%d %d %d", &m_unit, &m_Pos.x, &m_Pos.y ) != 3 )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
|
|
|
aErrorMsg.Printf( wxT( "Component unit & pos error at line %d, aborted" ),
|
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-24 21:30:27 +00:00
|
|
|
if( !(line = aLine.ReadLine()) ||
|
|
|
|
sscanf( line, "%d %d %d %d",
|
2010-12-14 21:39:31 +00:00
|
|
|
&m_transform.x1,
|
|
|
|
&m_transform.y1,
|
|
|
|
&m_transform.x2,
|
|
|
|
&m_transform.y2 ) != 4 )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
|
|
|
aErrorMsg.Printf( wxT( "Component orient error at line %d, aborted" ),
|
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( newfmt )
|
|
|
|
{
|
2013-05-24 21:30:27 +00:00
|
|
|
if( !(line = aLine.ReadLine()) )
|
2010-11-10 15:30:12 +00:00
|
|
|
return false;
|
|
|
|
|
2016-08-11 12:41:06 +00:00
|
|
|
if( strncasecmp( "$End", line, 4 ) != 0 )
|
2010-11-10 15:30:12 +00:00
|
|
|
{
|
|
|
|
aErrorMsg.Printf( wxT( "Component End expected at line %d, aborted" ),
|
|
|
|
aLine.LineNumber() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-18 08:04:26 +00:00
|
|
|
// ensure flags (mainly used in edit) are cleared.
|
|
|
|
// some changes have set the modified flag
|
|
|
|
m_Flags = 0;
|
|
|
|
|
2010-11-10 15:30:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT SCH_COMPONENT::GetBodyBoundingBox() const
|
2008-04-15 19:38: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
|
|
|
EDA_RECT bBox;
|
2010-12-10 19:47:44 +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( PART_SPTR part = m_part.lock() )
|
2011-02-27 19:54:01 +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
|
|
|
bBox = part->GetBodyBoundingBox( m_unit, m_convert );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert );
|
2011-02-27 19:54:01 +00:00
|
|
|
}
|
2010-12-10 19:47:44 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
int x0 = bBox.GetX();
|
|
|
|
int xm = bBox.GetRight();
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
// We must reverse Y values, because matrix orientation
|
|
|
|
// suppose Y axis normal for the library items coordinates,
|
2010-12-14 21:39:31 +00:00
|
|
|
// m_transform reverse Y values, but bBox is already reversed!
|
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 y0 = -bBox.GetY();
|
|
|
|
int ym = -bBox.GetBottom();
|
2010-12-10 19:47:44 +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
|
|
|
// Compute the real Boundary box (rotated, mirrored ...)
|
2010-12-14 21:39:31 +00:00
|
|
|
int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
|
|
|
|
int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
|
|
|
|
int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
|
|
|
|
int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
// H and W must be > 0:
|
|
|
|
if( x2 < x1 )
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( x2, x1 );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( y2 < y1 )
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( y2, y1 );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
bBox.SetX( x1 );
|
|
|
|
bBox.SetY( y1 );
|
|
|
|
bBox.SetWidth( x2 - x1 );
|
|
|
|
bBox.SetHeight( y2 - y1 );
|
2008-04-15 19:38:19 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
bBox.Offset( m_Pos );
|
2010-12-13 15:59:00 +00:00
|
|
|
return bBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT SCH_COMPONENT::GetBoundingBox() const
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2012-03-12 10:04:40 +00:00
|
|
|
EDA_RECT bbox = GetBodyBoundingBox();
|
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
|
|
|
|
2012-03-12 10:04:40 +00:00
|
|
|
for( size_t i = 0; i < m_Fields.size(); i++ )
|
|
|
|
{
|
|
|
|
bbox.Merge( m_Fields[i].GetBoundingBox() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return bbox;
|
2008-04-12 18:39:20 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
void SCH_COMPONENT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
|
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
|
|
|
// part and alias can differ if alias is not the root
|
|
|
|
if( PART_SPTR part = m_part.lock() )
|
|
|
|
{
|
|
|
|
LIB_ALIAS* alias = part->GetAlias( GetPartName() );
|
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
|
|
|
if( !alias )
|
|
|
|
return;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2016-02-15 20:15:51 +00:00
|
|
|
if( m_currentSheetPath )
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Reference" ),
|
2016-02-15 20:17:51 +00:00
|
|
|
GetRef( m_currentSheetPath ),
|
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
|
|
|
DARKCYAN ) );
|
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
|
|
|
wxString msg = part->IsPower() ? _( "Power symbol" ) : _( "Value" );
|
2010-12-13 15:59:00 +00:00
|
|
|
|
2014-09-13 18:15:45 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( msg, GetField( VALUE )->GetShownText(), DARKCYAN ) );
|
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
|
|
|
// Display component reference in library and library
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Component" ), GetPartName(), BROWN ) );
|
2010-12-13 15:59:00 +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( alias->GetName() != part->GetName() )
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), part->GetName(), BROWN ) );
|
2010-12-13 15:59:00 +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
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Library" ), alias->GetLibraryName(), BROWN ) );
|
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
|
|
|
// Display the current associated footprint, if exists.
|
|
|
|
if( !GetField( FOOTPRINT )->IsVoid() )
|
2014-09-13 18:15:45 +00:00
|
|
|
msg = GetField( FOOTPRINT )->GetShownText();
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
else
|
|
|
|
msg = _( "<Unknown>" );
|
2013-11-09 16:30:49 +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
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg, DARKRED ) );
|
2013-02-11 18:50:55 +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
|
|
|
// Display description of the component, and keywords found in lib
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Description" ), alias->GetDescription(), DARKCYAN ) );
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Key Words" ), alias->GetKeyWords(), DARKCYAN ) );
|
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
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2009-07-27 14:32:40 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_COMPONENT::MirrorY( int aYaxis_position )
|
2009-07-27 14:32:40 +00:00
|
|
|
{
|
|
|
|
int dx = m_Pos.x;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
SetOrientation( CMP_MIRROR_Y );
|
2015-06-26 13:41:56 +00:00
|
|
|
MIRROR( m_Pos.x, aYaxis_position );
|
2009-07-27 14:32:40 +00:00
|
|
|
dx -= m_Pos.x; // dx,0 is the move vector for this transform
|
|
|
|
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
// Move the fields to the new position because the component itself has moved.
|
2017-01-23 20:30:11 +00:00
|
|
|
wxPoint pos = GetField( ii )->GetTextPos();
|
2013-03-18 19:36:07 +00:00
|
|
|
pos.x -= dx;
|
2017-01-23 20:30:11 +00:00
|
|
|
GetField( ii )->SetTextPos( pos );
|
2009-07-27 14:32:40 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_COMPONENT::MirrorX( int aXaxis_position )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
int dy = m_Pos.y;
|
|
|
|
|
|
|
|
SetOrientation( CMP_MIRROR_X );
|
2015-06-26 13:41:56 +00:00
|
|
|
MIRROR( m_Pos.y, aXaxis_position );
|
2010-09-05 17:01:48 +00:00
|
|
|
dy -= m_Pos.y; // dy,0 is the move vector for this transform
|
|
|
|
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
// Move the fields to the new position because the component itself has moved.
|
2017-01-23 20:30:11 +00:00
|
|
|
wxPoint pos = GetField( ii )->GetTextPos();
|
2013-03-18 19:36:07 +00:00
|
|
|
pos.y -= dy;
|
2017-01-23 20:30:11 +00:00
|
|
|
GetField( ii )->SetTextPos( pos );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_COMPONENT::Rotate( wxPoint aPosition )
|
2010-09-05 17:01:48 +00:00
|
|
|
{
|
|
|
|
wxPoint prev = m_Pos;
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
RotatePoint( &m_Pos, aPosition, 900 );
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2014-02-22 12:39:59 +00:00
|
|
|
SetOrientation( CMP_ROTATE_COUNTERCLOCKWISE );
|
2010-09-05 17:01:48 +00:00
|
|
|
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
// Move the fields to the new position because the component itself has moved.
|
2017-01-23 20:30:11 +00:00
|
|
|
wxPoint pos = GetField( ii )->GetTextPos();
|
2013-03-18 19:36:07 +00:00
|
|
|
pos.x -= prev.x - m_Pos.x;
|
|
|
|
pos.y -= prev.y - m_Pos.y;
|
2017-01-23 20:30:11 +00:00
|
|
|
GetField( ii )->SetTextPos( pos );
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData,
|
|
|
|
wxPoint* aFindLocation )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2011-12-13 15:37:33 +00:00
|
|
|
wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() );
|
2010-10-20 19:43:58 +00:00
|
|
|
|
2011-12-01 16:49:28 +00:00
|
|
|
// Components are searchable via the child field and pin item text.
|
2010-03-16 18:22:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_COMPONENT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
|
|
|
{
|
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( PART_SPTR part = m_part.lock() )
|
2010-11-03 14:13: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
|
|
|
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
|
|
|
{
|
|
|
|
wxASSERT( pin->Type() == LIB_PIN_T );
|
2010-11-03 14:13: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
|
|
|
if( pin->GetUnit() && m_unit && ( m_unit != pin->GetUnit() ) )
|
|
|
|
continue;
|
2010-11-03 14:13: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
|
|
|
if( pin->GetConvert() && m_convert && ( m_convert != pin->GetConvert() ) )
|
|
|
|
continue;
|
2010-11-03 14:13: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
|
|
|
DANGLING_END_ITEM item( PIN_END, pin, GetPinPhysicalPosition( pin ) );
|
|
|
|
aItemList.push_back( item );
|
|
|
|
}
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-20 19:49:32 +00:00
|
|
|
bool SCH_COMPONENT::IsPinDanglingStateChanged( std::vector<DANGLING_END_ITEM> &aItemList,
|
|
|
|
LIB_PINS& aLibPins, unsigned aPin )
|
2015-06-08 00:07:42 +00:00
|
|
|
{
|
|
|
|
bool previousState;
|
2015-07-20 19:49:32 +00:00
|
|
|
|
2015-06-08 00:07:42 +00:00
|
|
|
if( aPin < m_isDangling.size() )
|
|
|
|
{
|
|
|
|
previousState = m_isDangling[aPin];
|
|
|
|
m_isDangling[aPin] = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
previousState = true;
|
|
|
|
m_isDangling.push_back( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPoint pin_position = GetPinPhysicalPosition( aLibPins[aPin] );
|
|
|
|
|
2016-06-29 20:07:55 +00:00
|
|
|
for( DANGLING_END_ITEM& each_item : aItemList )
|
2015-06-08 00:07:42 +00:00
|
|
|
{
|
2015-07-20 19:49:32 +00:00
|
|
|
// Some people like to stack pins on top of each other in a symbol to indicate
|
|
|
|
// internal connection. While technically connected, it is not particularly useful
|
|
|
|
// to display them that way, so skip any pins that are in the same symbol as this
|
|
|
|
// one.
|
|
|
|
//
|
|
|
|
// Do not make this exception for hidden pins, because those actually make internal
|
|
|
|
// connections to a power net.
|
|
|
|
const LIB_PIN* item_pin = dynamic_cast<const LIB_PIN*>( each_item.GetItem() );
|
|
|
|
|
|
|
|
if( item_pin
|
2015-07-21 14:07:52 +00:00
|
|
|
&& ( !item_pin->IsPowerConnection() || !IsInNetlist() )
|
2015-07-20 19:49:32 +00:00
|
|
|
&& std::find( aLibPins.begin(), aLibPins.end(), item_pin) != aLibPins.end() )
|
2015-06-08 00:07:42 +00:00
|
|
|
continue;
|
2015-07-20 19:49:32 +00:00
|
|
|
|
2015-06-08 00:07:42 +00:00
|
|
|
switch( each_item.GetType() )
|
|
|
|
{
|
|
|
|
case PIN_END:
|
|
|
|
case LABEL_END:
|
|
|
|
case SHEET_LABEL_END:
|
|
|
|
case WIRE_START_END:
|
|
|
|
case WIRE_END_END:
|
|
|
|
case NO_CONNECT_END:
|
2015-06-10 18:32:25 +00:00
|
|
|
case JUNCTION_END:
|
2015-06-08 00:07:42 +00:00
|
|
|
if( pin_position == each_item.GetPosition() )
|
|
|
|
m_isDangling[aPin] = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( !m_isDangling[aPin] )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return previousState != m_isDangling[aPin];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_COMPONENT::IsDanglingStateChanged( std::vector<DANGLING_END_ITEM>& aItemList )
|
|
|
|
{
|
|
|
|
bool changed = false;
|
|
|
|
LIB_PINS libPins;
|
|
|
|
if( PART_SPTR part = m_part.lock() )
|
|
|
|
part->GetPins( libPins, m_unit, m_convert );
|
|
|
|
for( size_t i = 0; i < libPins.size(); ++i )
|
|
|
|
{
|
|
|
|
if( IsPinDanglingStateChanged( aItemList, libPins, i ) )
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_COMPONENT::IsDangling() const
|
|
|
|
{
|
2016-06-29 20:07:55 +00:00
|
|
|
for( bool each : m_isDangling )
|
2015-06-08 00:07:42 +00:00
|
|
|
{
|
|
|
|
if( each )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
wxPoint SCH_COMPONENT::GetPinPhysicalPosition( LIB_PIN* Pin )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
wxCHECK_MSG( Pin != NULL && Pin->Type() == LIB_PIN_T, wxPoint( 0, 0 ),
|
2010-11-03 14:13:15 +00:00
|
|
|
wxT( "Cannot get physical position of pin." ) );
|
|
|
|
|
2010-12-14 21:39:31 +00:00
|
|
|
return m_transform.TransformCoordinate( Pin->GetPosition() ) + m_Pos;
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_COMPONENT::IsSelectStateChanged( const wxRect& aRect )
|
|
|
|
{
|
|
|
|
bool previousState = IsSelected();
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT boundingBox = GetBoundingBox();
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
if( aRect.Intersects( boundingBox ) )
|
2013-03-30 19:55:26 +00:00
|
|
|
SetFlags( SELECTED );
|
2010-11-03 14:13:15 +00:00
|
|
|
else
|
2013-03-30 19:55:26 +00:00
|
|
|
ClearFlags( SELECTED );
|
2010-11-03 14:13:15 +00:00
|
|
|
|
|
|
|
return previousState != IsSelected();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-13 16:27:30 +00:00
|
|
|
void SCH_COMPONENT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const
|
2010-11-03 14:13: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
|
|
|
if( PART_SPTR part = m_part.lock() )
|
2010-11-03 14:13: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
|
|
|
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
|
|
|
{
|
|
|
|
wxCHECK_RET( pin->Type() == LIB_PIN_T,
|
|
|
|
wxT( "GetNextPin() did not return a pin object. Bad programmer!" ) );
|
2010-11-03 14:13: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
|
|
|
// Skip items not used for this part.
|
|
|
|
if( m_unit && pin->GetUnit() && ( pin->GetUnit() != m_unit ) )
|
|
|
|
continue;
|
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
|
|
|
if( m_convert && pin->GetConvert() && ( pin->GetConvert() != m_convert ) )
|
|
|
|
continue;
|
2010-11-03 14:13: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
|
|
|
// Calculate the pin position relative to the component position and orientation.
|
|
|
|
aPoints.push_back( m_transform.TransformCoordinate( pin->GetPosition() ) + m_Pos );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCHECK_RET( 0,
|
|
|
|
wxT( "Cannot add connection points to list. Cannot find component <" ) +
|
|
|
|
GetPartName() + wxT( "> in any of the loaded libraries." ) );
|
2010-11-03 14:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_ITEM* SCH_COMPONENT::GetDrawItem( const wxPoint& aPosition, KICAD_T aType )
|
2010-12-10 19:47:44 +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( PART_SPTR part = m_part.lock() )
|
|
|
|
{
|
|
|
|
// Calculate the position relative to the component.
|
|
|
|
wxPoint libPosition = aPosition - m_Pos;
|
2010-12-10 19:47:44 +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 part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
|
|
|
|
}
|
2010-12-13 15:59:00 +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 NULL;
|
2010-12-13 15:59:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
wxString SCH_COMPONENT::GetSelectMenuText() const
|
|
|
|
{
|
2011-03-26 10:08:50 +00:00
|
|
|
wxString tmp;
|
|
|
|
tmp.Printf( _( "Component %s, %s" ),
|
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
|
|
|
GetChars( GetPartName() ),
|
2014-09-13 18:15:45 +00:00
|
|
|
GetChars( GetField( REFERENCE )->GetShownText() ) );
|
2011-03-26 10:08:50 +00:00
|
|
|
return tmp;
|
2011-03-25 19:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_RESULT SCH_COMPONENT::Visit( INSPECTOR aInspector, void* aTestData,
|
2011-03-25 19:16:05 +00:00
|
|
|
const KICAD_T aFilterTypes[] )
|
2010-12-13 15:59:00 +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
|
|
|
KICAD_T stype;
|
2010-12-13 15:59:00 +00:00
|
|
|
|
2012-12-08 17:24:49 +00:00
|
|
|
for( const KICAD_T* p = aFilterTypes; (stype = *p) != EOT; ++p )
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
// If caller wants to inspect component type or and component children types.
|
|
|
|
if( stype == Type() )
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2016-07-12 19:05:54 +00:00
|
|
|
if( SEARCH_QUIT == aInspector( this, aTestData ) )
|
2011-03-25 19:16:05 +00:00
|
|
|
return SEARCH_QUIT;
|
|
|
|
}
|
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
|
|
|
|
2012-12-08 17:24:49 +00:00
|
|
|
switch( stype )
|
2011-03-25 19:16: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
|
|
|
case SCH_FIELD_T:
|
|
|
|
// Test the bounding boxes of fields if they are visible and not empty.
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ii++ )
|
|
|
|
{
|
2016-07-12 19:05:54 +00:00
|
|
|
if( SEARCH_QUIT == aInspector( GetField( ii ), (void*) this ) )
|
2011-03-25 19:16:05 +00:00
|
|
|
return SEARCH_QUIT;
|
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
|
|
|
}
|
|
|
|
break;
|
2010-12-13 15:59:00 +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
|
|
|
case SCH_FIELD_LOCATE_REFERENCE_T:
|
2016-07-12 19:05:54 +00:00
|
|
|
if( SEARCH_QUIT == aInspector( GetField( REFERENCE ), (void*) this ) )
|
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 SEARCH_QUIT;
|
|
|
|
break;
|
2012-12-08 17:24:49 +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
|
|
|
case SCH_FIELD_LOCATE_VALUE_T:
|
2016-07-12 19:05:54 +00:00
|
|
|
if( SEARCH_QUIT == aInspector( GetField( VALUE ), (void*) this ) )
|
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 SEARCH_QUIT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_FIELD_LOCATE_FOOTPRINT_T:
|
2016-07-12 19:05:54 +00:00
|
|
|
if( SEARCH_QUIT == aInspector( GetField( FOOTPRINT ), (void*) this ) )
|
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 SEARCH_QUIT;
|
|
|
|
break;
|
2010-12-13 15:59:00 +00:00
|
|
|
|
2011-03-25 19:16: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
|
|
|
case LIB_PIN_T:
|
|
|
|
if( PART_SPTR part = m_part.lock() )
|
|
|
|
{
|
|
|
|
LIB_PINS pins;
|
2012-12-08 17:24:49 +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->GetPins( pins, m_unit, m_convert );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pins.size(); i++ )
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2016-07-12 19:05:54 +00:00
|
|
|
if( SEARCH_QUIT == aInspector( pins[ i ], (void*) this ) )
|
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 SEARCH_QUIT;
|
2011-03-25 19:16: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
|
|
|
}
|
|
|
|
break;
|
2012-12-08 17:24:49 +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
|
|
|
default:
|
|
|
|
break;
|
2010-12-13 15:59:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
return SEARCH_CONTINUE;
|
|
|
|
}
|
2010-12-13 15:59:00 +00:00
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2013-09-25 19:09:57 +00:00
|
|
|
void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
|
|
|
|
SCH_SHEET_PATH* aSheetPath )
|
2011-10-11 20:23: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
|
|
|
if( PART_SPTR part = m_part.lock() )
|
2011-10-11 20:23: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
|
|
|
for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
|
|
|
|
{
|
|
|
|
wxASSERT( pin->Type() == LIB_PIN_T );
|
2011-10-11 20:23:56 +00:00
|
|
|
|
2016-02-15 20:17:51 +00:00
|
|
|
if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath ) ) )
|
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
|
|
|
continue;
|
2011-10-11 20:23: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
|
|
|
if( pin->GetConvert() && ( pin->GetConvert() != GetConvert() ) )
|
|
|
|
continue;
|
2011-10-11 20:23: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
|
|
|
wxPoint pos = GetTransform().TransformCoordinate( pin->GetPosition() ) + m_Pos;
|
2011-10-11 20:23: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
|
|
|
NETLIST_OBJECT* item = new NETLIST_OBJECT();
|
2013-09-29 18:24:38 +00:00
|
|
|
item->m_SheetPathInclude = *aSheetPath;
|
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
|
|
|
item->m_Comp = (SCH_ITEM*) pin;
|
2013-09-29 18:24:38 +00:00
|
|
|
item->m_SheetPath = *aSheetPath;
|
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
|
|
|
item->m_Type = NET_PIN;
|
|
|
|
item->m_Link = (SCH_ITEM*) this;
|
2016-02-19 16:51:23 +00:00
|
|
|
item->m_ElectricalPinType = pin->GetType();
|
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
|
|
|
item->m_PinNum = pin->GetNumber();
|
2011-10-11 20:23:56 +00:00
|
|
|
item->m_Label = pin->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
|
|
|
item->m_Start = item->m_End = pos;
|
2011-10-11 20:23:56 +00:00
|
|
|
|
|
|
|
aNetListItems.push_back( item );
|
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
|
|
|
|
2015-07-20 19:49:32 +00:00
|
|
|
if( pin->IsPowerConnection() )
|
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
|
|
|
{
|
|
|
|
// There is an associated PIN_LABEL.
|
|
|
|
item = new NETLIST_OBJECT();
|
|
|
|
item->m_SheetPathInclude = *aSheetPath;
|
|
|
|
item->m_Comp = NULL;
|
|
|
|
item->m_SheetPath = *aSheetPath;
|
|
|
|
item->m_Type = NET_PINLABEL;
|
|
|
|
item->m_Label = pin->GetName();
|
|
|
|
item->m_Start = pos;
|
|
|
|
item->m_End = item->m_Start;
|
|
|
|
|
|
|
|
aNetListItems.push_back( item );
|
|
|
|
}
|
2011-10-11 20:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-25 19:16:05 +00:00
|
|
|
bool SCH_COMPONENT::operator <( const SCH_ITEM& aItem ) const
|
|
|
|
{
|
|
|
|
if( Type() != aItem.Type() )
|
|
|
|
return Type() < aItem.Type();
|
|
|
|
|
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) &aItem;
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT rect = GetBodyBoundingBox();
|
2011-03-25 19:16:05 +00:00
|
|
|
|
|
|
|
if( rect.GetArea() != component->GetBodyBoundingBox().GetArea() )
|
|
|
|
return rect.GetArea() < component->GetBodyBoundingBox().GetArea();
|
|
|
|
|
|
|
|
if( m_Pos.x != component->m_Pos.x )
|
|
|
|
return m_Pos.x < component->m_Pos.x;
|
|
|
|
|
|
|
|
if( m_Pos.y != component->m_Pos.y )
|
|
|
|
return m_Pos.y < component->m_Pos.y;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-22 21:37:34 +00:00
|
|
|
bool SCH_COMPONENT::operator==( const SCH_COMPONENT& aComponent ) const
|
|
|
|
{
|
|
|
|
if( GetFieldCount() != aComponent.GetFieldCount() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for( int i = VALUE; i < GetFieldCount(); i++ )
|
|
|
|
{
|
|
|
|
if( GetField( i )->GetText().Cmp( aComponent.GetField( i )->GetText() ) != 0 )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_COMPONENT::operator!=( const SCH_COMPONENT& aComponent ) const
|
|
|
|
{
|
|
|
|
return !( *this == aComponent );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-09 20:26:55 +00:00
|
|
|
SCH_ITEM& SCH_COMPONENT::operator=( const SCH_ITEM& aItem )
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( Type() == aItem.Type(), *this,
|
|
|
|
wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
|
|
|
|
GetClass() );
|
|
|
|
|
|
|
|
if( &aItem != this )
|
|
|
|
{
|
|
|
|
SCH_ITEM::operator=( aItem );
|
|
|
|
|
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
|
|
|
SCH_COMPONENT* c = (SCH_COMPONENT*) &aItem;
|
2012-01-09 20:26:55 +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
|
|
|
m_part_name = c->m_part_name;
|
|
|
|
m_part = c->m_part;
|
|
|
|
m_Pos = c->m_Pos;
|
|
|
|
m_unit = c->m_unit;
|
|
|
|
m_convert = c->m_convert;
|
|
|
|
m_transform = c->m_transform;
|
|
|
|
|
|
|
|
m_PathsAndReferences = c->m_PathsAndReferences;
|
|
|
|
|
|
|
|
m_Fields = c->m_Fields; // std::vector's assignment operator.
|
2012-01-09 20:26:55 +00:00
|
|
|
|
|
|
|
// Reparent fields after assignment to new component.
|
|
|
|
for( int ii = 0; ii < GetFieldCount(); ++ii )
|
|
|
|
{
|
|
|
|
GetField( ii )->SetParent( this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool SCH_COMPONENT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
2011-03-25 19:16:05 +00:00
|
|
|
{
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT bBox = GetBodyBoundingBox();
|
2011-03-25 19:16:05 +00:00
|
|
|
bBox.Inflate( aAccuracy );
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
if( bBox.Contains( aPosition ) )
|
2011-03-25 19:16:05 +00:00
|
|
|
return true;
|
2010-12-13 15:59:00 +00:00
|
|
|
|
|
|
|
return false;
|
2010-12-10 19:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool SCH_COMPONENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
2010-12-10 19:47:44 +00:00
|
|
|
{
|
2012-03-15 14:31:16 +00:00
|
|
|
if( m_Flags & STRUCT_DELETED || m_Flags & SKIP_STRUCT )
|
|
|
|
return false;
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT rect = aRect;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
|
|
|
rect.Inflate( aAccuracy );
|
|
|
|
|
|
|
|
if( aContained )
|
2012-03-12 10:04:40 +00:00
|
|
|
return rect.Contains( GetBodyBoundingBox() );
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2012-03-12 10:04:40 +00:00
|
|
|
return rect.Intersects( GetBodyBoundingBox() );
|
2010-12-10 19:47:44 +00:00
|
|
|
}
|
2010-12-13 15:59:00 +00:00
|
|
|
|
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
bool SCH_COMPONENT::doIsConnected( const wxPoint& aPosition ) const
|
2010-12-13 15:59:00 +00:00
|
|
|
{
|
2013-12-13 16:27:30 +00:00
|
|
|
std::vector< wxPoint > pts;
|
2010-12-13 15:59:00 +00:00
|
|
|
|
|
|
|
GetConnectionPoints( pts );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < pts.size(); i++ )
|
|
|
|
{
|
|
|
|
if( pts[i] == aPosition )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-06-17 13:24: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
|
|
|
|
2013-09-27 17:58:58 +00:00
|
|
|
bool SCH_COMPONENT::IsInNetlist() const
|
|
|
|
{
|
|
|
|
SCH_FIELD* rf = GetField( REFERENCE );
|
2013-09-28 22:53:55 +00:00
|
|
|
return ! rf->GetText().StartsWith( wxT( "#" ) );
|
2013-09-27 17:58:58 +00:00
|
|
|
}
|
2011-06-17 13:24:22 +00:00
|
|
|
|
2013-09-28 22:53:55 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
void SCH_COMPONENT::Plot( PLOTTER* aPlotter )
|
2011-06-17 13:24: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
|
|
|
TRANSFORM temp;
|
2011-06-17 13:24: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
|
|
|
if( PART_SPTR part = m_part.lock() )
|
|
|
|
{
|
|
|
|
temp = GetTransform();
|
2011-06-17 13:24: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
|
|
|
part->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp );
|
2011-06-17 13:24: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
|
|
|
for( size_t i = 0; i < m_Fields.size(); i++ )
|
|
|
|
{
|
|
|
|
m_Fields[i].Plot( aPlotter );
|
|
|
|
}
|
2011-06-17 13:24:22 +00:00
|
|
|
}
|
|
|
|
}
|