2011-10-15 13:25:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-04-12 06:18:46 +00:00
|
|
|
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2011-2017 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-15 13:25:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file sch_sheet_path.cpp
|
|
|
|
* @brief SCH_SHEET_PATH class implementation.
|
|
|
|
*/
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <dlist.h>
|
|
|
|
#include <class_sch_screen.h>
|
|
|
|
#include <sch_item_struct.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2015-02-21 08:11:58 +00:00
|
|
|
#include <sch_reference_list.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_library.h>
|
|
|
|
#include <sch_sheet_path.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <template_fieldnames.h>
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialogs/dialog_schematic_find.h>
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2015-06-07 20:31:55 +00:00
|
|
|
#include <wx/filename.h>
|
2015-03-23 11:45:31 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_PATH::SCH_SHEET_PATH()
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
m_pageNumber = 0;
|
2009-01-07 20:09:03 +00:00
|
|
|
}
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
if( size() > aSheetPathToTest.size() )
|
2009-01-04 18:52:57 +00:00
|
|
|
return 1;
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2016-02-27 19:35:45 +00:00
|
|
|
if( size() < aSheetPathToTest.size() )
|
2009-01-04 18:52:57 +00:00
|
|
|
return -1;
|
|
|
|
|
2011-01-23 21:22:42 +00:00
|
|
|
//otherwise, same number of sheets.
|
2016-02-27 19:35:45 +00:00
|
|
|
for( unsigned i = 0; i < size(); i++ )
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
if( at( i )->GetTimeStamp() > aSheetPathToTest.at( i )->GetTimeStamp() )
|
2009-01-04 18:52:57 +00:00
|
|
|
return 1;
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2016-02-27 19:35:45 +00:00
|
|
|
if( at( i )->GetTimeStamp() < aSheetPathToTest.at( i )->GetTimeStamp() )
|
2009-01-04 18:52:57 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
SCH_SHEET* SCH_SHEET_PATH::Last() const
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
if( !empty() )
|
|
|
|
return at( size() - 1 );
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
SCH_SCREEN* SCH_SHEET_PATH::LastScreen() const
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2010-04-01 13:15:48 +00:00
|
|
|
SCH_SHEET* lastSheet = Last();
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2010-04-01 13:15:48 +00:00
|
|
|
if( lastSheet )
|
2011-01-20 16:34:57 +00:00
|
|
|
return lastSheet->GetScreen();
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
SCH_ITEM* SCH_SHEET_PATH::LastDrawList() const
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2011-01-23 21:22:42 +00:00
|
|
|
SCH_SHEET* lastSheet = Last();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-01-23 21:22:42 +00:00
|
|
|
if( lastSheet && lastSheet->GetScreen() )
|
|
|
|
return lastSheet->GetScreen()->GetDrawItems();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-01-04 18:52:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
SCH_ITEM* SCH_SHEET_PATH::FirstDrawList() const
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
SCH_ITEM* item = NULL;
|
|
|
|
|
2016-02-27 19:35:45 +00:00
|
|
|
if( !empty() && at( 0 )->GetScreen() )
|
|
|
|
item = at( 0 )->GetScreen()->GetDrawItems();
|
2011-01-23 21:22:42 +00:00
|
|
|
|
|
|
|
/* @fixme - These lists really should be one of the boost pointer containers. This
|
|
|
|
* is a brain dead hack to allow reverse iteration of EDA_ITEM linked
|
|
|
|
* list.
|
|
|
|
*/
|
|
|
|
SCH_ITEM* lastItem = NULL;
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
while( item )
|
2011-01-23 21:22:42 +00:00
|
|
|
{
|
|
|
|
lastItem = item;
|
|
|
|
item = item->Next();
|
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2011-01-23 21:22:42 +00:00
|
|
|
return lastItem;
|
2010-03-16 18:22:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-17 01:06:08 +00:00
|
|
|
wxString SCH_SHEET_PATH::Path() const
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2009-01-04 18:52:57 +00:00
|
|
|
wxString s, t;
|
|
|
|
|
2009-01-06 20:09:32 +00:00
|
|
|
s = wxT( "/" ); // This is the root path
|
2009-01-04 18:52:57 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
// start at 1 to avoid the root sheet,
|
|
|
|
// which does not need to be added to the path
|
|
|
|
// it's timestamp changes anyway.
|
2016-02-27 19:35:45 +00:00
|
|
|
for( unsigned i = 1; i < size(); i++ )
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
t.Printf( _( "%8.8lX/" ), (long unsigned) at( i )->GetTimeStamp() );
|
2009-01-04 18:52:57 +00:00
|
|
|
s = s + t;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-03 02:13:33 +00:00
|
|
|
wxString SCH_SHEET_PATH::PathHumanReadable() const
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2015-11-03 19:44:05 +00:00
|
|
|
wxString s;
|
2009-01-04 18:52:57 +00:00
|
|
|
|
|
|
|
s = wxT( "/" );
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
// start at 1 to avoid the root sheet, as above.
|
2016-02-27 19:35:45 +00:00
|
|
|
for( unsigned i = 1; i < size(); i++ )
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
s = s + at( i )->GetName() + wxT( "/" );
|
2009-01-04 18:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:17:51 +00:00
|
|
|
void SCH_SHEET_PATH::UpdateAllScreenReferences()
|
|
|
|
{
|
|
|
|
EDA_ITEM* t = LastDrawList();
|
|
|
|
|
|
|
|
while( t )
|
|
|
|
{
|
|
|
|
if( t->Type() == SCH_COMPONENT_T )
|
|
|
|
{
|
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) t;
|
|
|
|
component->GetField( REFERENCE )->SetText( component->GetRef( this ) );
|
|
|
|
component->UpdateUnit( component->GetUnitSelection( this ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
t = t->Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:18:32 +00:00
|
|
|
void SCH_SHEET_PATH::AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference )
|
|
|
|
{
|
|
|
|
int ref = 1;
|
|
|
|
|
|
|
|
if( aReference )
|
|
|
|
ref = *aReference;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item = LastDrawList(); item; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
2016-02-27 19:35:45 +00:00
|
|
|
continue;
|
2016-02-15 20:18:32 +00:00
|
|
|
|
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
2017-04-12 06:18:46 +00:00
|
|
|
LIB_PART* part = component->GetPartRef().lock().get();
|
2016-02-15 20:18:32 +00:00
|
|
|
|
|
|
|
if( !part || !part->IsPower() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
wxString refstr = component->GetPrefix();
|
|
|
|
|
|
|
|
//str will be "C?" or so after the ClearAnnotation call.
|
|
|
|
while( refstr.Last() == '?' )
|
|
|
|
refstr.RemoveLast();
|
|
|
|
|
|
|
|
if( !refstr.StartsWith( wxT( "#" ) ) )
|
2016-06-24 10:55:54 +00:00
|
|
|
refstr.insert( refstr.begin(), wxChar( '#' ) );
|
2016-02-15 20:18:32 +00:00
|
|
|
|
|
|
|
refstr << wxT( "0" ) << ref;
|
|
|
|
component->SetRef( this, refstr );
|
|
|
|
ref++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aReference )
|
|
|
|
*aReference = ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-27 19:35:45 +00:00
|
|
|
void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
|
|
|
|
bool aIncludePowerSymbols )
|
2016-02-15 20:16:54 +00:00
|
|
|
{
|
|
|
|
for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( item->Type() == SCH_COMPONENT_T )
|
|
|
|
{
|
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
|
|
|
|
|
|
|
// Skip pseudo components, which have a reference starting with #. This mainly
|
|
|
|
// affects power symbols.
|
2016-02-15 20:17:51 +00:00
|
|
|
if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
|
2016-02-15 20:16:54 +00:00
|
|
|
continue;
|
|
|
|
|
2017-04-12 06:18:46 +00:00
|
|
|
LIB_PART* part = component->GetPartRef().lock().get();
|
2016-02-27 19:35:45 +00:00
|
|
|
|
2016-02-15 20:16:54 +00:00
|
|
|
if( part )
|
|
|
|
{
|
2016-06-24 10:55:54 +00:00
|
|
|
SCH_REFERENCE reference( component, part, *this );
|
|
|
|
|
2016-02-27 19:35:45 +00:00
|
|
|
reference.SetSheetNumber( m_pageNumber );
|
2016-02-15 20:16:54 +00:00
|
|
|
aReferences.AddItem( reference );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-15 20:14:48 +00:00
|
|
|
|
2016-02-27 19:35:45 +00:00
|
|
|
void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs,
|
2016-06-24 10:55:54 +00:00
|
|
|
SCH_MULTI_UNIT_REFERENCE_MAP& aRefList,
|
2016-02-27 19:35:45 +00:00
|
|
|
bool aIncludePowerSymbols )
|
|
|
|
{
|
2016-02-15 20:14:48 +00:00
|
|
|
|
|
|
|
for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
|
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
if( item->Type() != SCH_COMPONENT_T )
|
|
|
|
continue;
|
|
|
|
|
2016-02-15 20:14:48 +00:00
|
|
|
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
|
|
|
|
|
|
|
// Skip pseudo components, which have a reference starting with #. This mainly
|
|
|
|
// affects power symbols.
|
2016-02-15 20:17:51 +00:00
|
|
|
if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
|
2016-02-15 20:14:48 +00:00
|
|
|
continue;
|
|
|
|
|
2017-04-12 06:18:46 +00:00
|
|
|
LIB_PART* part = component->GetPartRef().lock().get();
|
2016-02-27 19:35:45 +00:00
|
|
|
|
2016-02-15 20:14:48 +00:00
|
|
|
if( part && part->GetUnitCount() > 1 )
|
|
|
|
{
|
2016-02-15 20:16:54 +00:00
|
|
|
SCH_REFERENCE reference = SCH_REFERENCE( component, part, *this );
|
2016-02-27 19:35:45 +00:00
|
|
|
reference.SetSheetNumber( m_pageNumber );
|
2016-02-15 20:14:48 +00:00
|
|
|
wxString reference_str = reference.GetRef();
|
|
|
|
|
|
|
|
// Never lock unassigned references
|
2016-02-27 19:35:45 +00:00
|
|
|
if( reference_str[reference_str.Len() - 1] == '?' )
|
|
|
|
continue;
|
2016-02-15 20:14:48 +00:00
|
|
|
|
|
|
|
aRefList[reference_str].AddItem( reference );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:14:07 +00:00
|
|
|
SCH_ITEM* SCH_SHEET_PATH::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const
|
|
|
|
{
|
|
|
|
bool hasWrapped = false;
|
|
|
|
bool firstItemFound = false;
|
|
|
|
SCH_ITEM* drawItem = LastDrawList();
|
|
|
|
|
|
|
|
while( drawItem )
|
|
|
|
{
|
|
|
|
if( drawItem->Type() == aType )
|
|
|
|
{
|
|
|
|
if( !aLastItem || firstItemFound )
|
|
|
|
{
|
|
|
|
return drawItem;
|
|
|
|
}
|
|
|
|
else if( !firstItemFound && drawItem == aLastItem )
|
|
|
|
{
|
|
|
|
firstItemFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
drawItem = drawItem->Next();
|
|
|
|
|
|
|
|
if( !drawItem && aLastItem && aWrap && !hasWrapped )
|
|
|
|
{
|
|
|
|
hasWrapped = true;
|
|
|
|
drawItem = LastDrawList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
SCH_ITEM* SCH_SHEET_PATH::FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
bool hasWrapped = false;
|
|
|
|
bool firstItemFound = false;
|
|
|
|
SCH_ITEM* drawItem = FirstDrawList();
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
while( drawItem )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
if( drawItem->Type() == aType )
|
|
|
|
{
|
|
|
|
if( aLastItem == NULL || firstItemFound )
|
|
|
|
{
|
|
|
|
return drawItem;
|
|
|
|
}
|
|
|
|
else if( !firstItemFound && drawItem == aLastItem )
|
|
|
|
{
|
|
|
|
firstItemFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
drawItem = drawItem->Back();
|
|
|
|
|
|
|
|
if( drawItem == NULL && aLastItem && aWrap && !hasWrapped )
|
|
|
|
{
|
|
|
|
hasWrapped = true;
|
|
|
|
drawItem = FirstDrawList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:14:07 +00:00
|
|
|
bool SCH_SHEET_PATH::SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
|
|
|
|
bool aSetVisible )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = LastScreen();
|
|
|
|
|
|
|
|
if( screen == NULL )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-03 02:13:33 +00:00
|
|
|
bool SCH_SHEET_PATH::operator==( const SCH_SHEET_PATH& d1 ) const
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
if( size() != d1.size() )
|
2009-01-04 18:52:57 +00:00
|
|
|
return false;
|
2010-08-03 02:13:33 +00:00
|
|
|
|
2016-02-27 19:35:45 +00:00
|
|
|
for( unsigned i = 0; i < size(); i++ )
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
if( at( i ) != d1[i] )
|
2009-01-04 18:52:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:12:42 +00:00
|
|
|
bool SCH_SHEET_PATH::TestForRecursion( const wxString& aSrcFileName,
|
|
|
|
const wxString& aDestFileName ) const
|
|
|
|
{
|
|
|
|
wxFileName rootFn = g_RootSheet->GetFileName();
|
|
|
|
wxFileName srcFn = aSrcFileName;
|
|
|
|
wxFileName destFn = aDestFileName;
|
|
|
|
|
|
|
|
if( srcFn.IsRelative() )
|
|
|
|
srcFn.MakeAbsolute( rootFn.GetPath() );
|
|
|
|
|
|
|
|
if( destFn.IsRelative() )
|
|
|
|
destFn.MakeAbsolute( rootFn.GetPath() );
|
|
|
|
|
|
|
|
|
|
|
|
// The source and destination sheet file names cannot be the same.
|
|
|
|
if( srcFn == destFn )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
/// @todo Store sheet file names with full path, either relative to project path
|
|
|
|
/// or absolute path. The current design always assumes subsheet files are
|
|
|
|
/// located in the project folder which may or may not be desirable.
|
|
|
|
unsigned i = 0;
|
|
|
|
|
2016-02-27 19:35:45 +00:00
|
|
|
while( i < size() )
|
2016-02-15 20:12:42 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
wxFileName cmpFn = at( i )->GetFileName();
|
2016-02-15 20:12:42 +00:00
|
|
|
|
|
|
|
if( cmpFn.IsRelative() )
|
|
|
|
cmpFn.MakeAbsolute( rootFn.GetPath() );
|
|
|
|
|
|
|
|
// Test if the file name of the destination sheet is in anywhere in this sheet path.
|
|
|
|
if( cmpFn == destFn )
|
|
|
|
break;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The destination sheet file name was not found in the sheet path or the destination
|
|
|
|
// sheet file name is the root sheet so no recursion is possible.
|
2016-02-27 19:35:45 +00:00
|
|
|
if( i >= size() || i == 0 )
|
2016-02-15 20:12:42 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Walk back up to the root sheet to see if the source file name is already a parent in
|
|
|
|
// the sheet path. If so, recursion will occur.
|
|
|
|
do
|
|
|
|
{
|
|
|
|
i -= 1;
|
|
|
|
|
2016-02-27 19:35:45 +00:00
|
|
|
wxFileName cmpFn = at( i )->GetFileName();
|
2016-02-15 20:12:42 +00:00
|
|
|
|
|
|
|
if( cmpFn.IsRelative() )
|
|
|
|
cmpFn.MakeAbsolute( rootFn.GetPath() );
|
|
|
|
|
|
|
|
if( cmpFn == srcFn )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} while( i != 0 );
|
|
|
|
|
|
|
|
// The source sheet file name is not a parent of the destination sheet file name.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:11:50 +00:00
|
|
|
int SCH_SHEET_PATH::FindSheet( const wxString& aFileName ) const
|
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
for( unsigned i = 0; i < size(); i++ )
|
2016-02-15 20:11:50 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
if( at( i )->GetFileName().CmpNoCase( aFileName ) == 0 )
|
2016-02-15 20:11:50 +00:00
|
|
|
return (int)i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SHEET_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_SHEET* SCH_SHEET_PATH::FindSheetByName( const wxString& aSheetName )
|
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
for( unsigned i = 0; i < size(); i++ )
|
2016-02-15 20:11:50 +00:00
|
|
|
{
|
2016-02-27 19:35:45 +00:00
|
|
|
if( at( i )->GetName().CmpNoCase( aSheetName ) == 0 )
|
|
|
|
return at( i );
|
2016-02-15 20:11:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
/********************************************************************/
|
2009-12-02 21:44:03 +00:00
|
|
|
/* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */
|
2011-03-29 19:33:07 +00:00
|
|
|
/********************************************************************/
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet )
|
|
|
|
{
|
2013-10-27 18:21:53 +00:00
|
|
|
m_isRootSheet = false;
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
if( aSheet != NULL )
|
|
|
|
BuildSheetList( aSheet );
|
2009-01-04 18:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-08 14:37:45 +00:00
|
|
|
SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheetByPath( const wxString aPath, bool aHumanReadable )
|
2011-11-17 01:06:08 +00:00
|
|
|
{
|
|
|
|
wxString sheetPath;
|
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
for( unsigned i = 0; i < size(); i++ )
|
2011-11-17 01:06:08 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
sheetPath = ( aHumanReadable ) ? at( i ).PathHumanReadable() : at( i ).Path();
|
2011-11-17 01:06:08 +00:00
|
|
|
|
|
|
|
if( sheetPath == aPath )
|
2016-03-06 21:22:01 +00:00
|
|
|
return &at( i );
|
2011-11-17 01:06:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
|
|
|
|
{
|
2014-08-23 15:22:50 +00:00
|
|
|
wxCHECK_RET( aSheet != NULL, wxT( "Cannot build sheet list from undefined sheet." ) );
|
|
|
|
|
2013-10-27 18:21:53 +00:00
|
|
|
if( aSheet == g_RootSheet )
|
|
|
|
m_isRootSheet = true;
|
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
m_currentSheetPath.push_back( aSheet );
|
2016-02-27 19:35:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo: Schematic page number is currently a left over relic and is generated as
|
|
|
|
* SCH_SHEET_PATH object is pushed to the list. This only has meaning when
|
|
|
|
* entire hierarchy is created from the root sheet down.
|
|
|
|
*/
|
2016-03-06 21:22:01 +00:00
|
|
|
m_currentSheetPath.SetPageNumber( size() + 1 );
|
|
|
|
push_back( m_currentSheetPath );
|
2009-12-02 21:44:03 +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( aSheet->GetScreen() )
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
EDA_ITEM* item = m_currentSheetPath.LastDrawList();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
while( item )
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
if( item->Type() == SCH_SHEET_T )
|
2009-01-04 18:52:57 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
2009-01-06 20:09:32 +00:00
|
|
|
BuildSheetList( sheet );
|
2009-01-04 18:52:57 +00:00
|
|
|
}
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
item = item->Next();
|
2009-01-04 18:52:57 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
m_currentSheetPath.pop_back();
|
2009-01-04 18:52:57 +00:00
|
|
|
}
|
2010-03-16 18:22:59 +00:00
|
|
|
|
|
|
|
|
2016-02-15 20:21:18 +00:00
|
|
|
bool SCH_SHEET_LIST::IsModified()
|
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
|
2016-02-15 20:21:18 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
if( (*it).LastScreen() && (*it).LastScreen()->IsModify() )
|
2016-02-15 20:21:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:19:22 +00:00
|
|
|
bool SCH_SHEET_LIST::IsAutoSaveRequired()
|
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
|
2016-02-15 20:19:22 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
if( (*it).LastScreen() && (*it).LastScreen()->IsSave() )
|
2016-02-15 20:19:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:21:18 +00:00
|
|
|
void SCH_SHEET_LIST::ClearModifyStatus()
|
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
|
2016-02-15 20:21:18 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
if( (*it).LastScreen() )
|
|
|
|
(*it).LastScreen()->ClrModify();
|
2016-02-15 20:21:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:18:32 +00:00
|
|
|
void SCH_SHEET_LIST::AnnotatePowerSymbols( PART_LIBS* aLibs )
|
|
|
|
{
|
|
|
|
int ref = 1;
|
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
|
|
|
|
(*it).AnnotatePowerSymbols( aLibs, &ref );
|
2016-02-15 20:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:16:54 +00:00
|
|
|
void SCH_SHEET_LIST::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
|
2016-03-06 21:22:01 +00:00
|
|
|
bool aIncludePowerSymbols )
|
2016-02-15 20:16:54 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
|
|
|
|
(*it).GetComponents( aLibs, aReferences, aIncludePowerSymbols );
|
2016-02-15 20:16:54 +00:00
|
|
|
}
|
|
|
|
|
2016-02-15 20:14:48 +00:00
|
|
|
void SCH_SHEET_LIST::GetMultiUnitComponents( PART_LIBS* aLibs,
|
2016-03-06 21:22:01 +00:00
|
|
|
SCH_MULTI_UNIT_REFERENCE_MAP &aRefList,
|
|
|
|
bool aIncludePowerSymbols )
|
2016-02-15 20:14:48 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
|
2016-02-15 20:14:48 +00:00
|
|
|
{
|
|
|
|
SCH_MULTI_UNIT_REFERENCE_MAP tempMap;
|
2016-03-06 21:22:01 +00:00
|
|
|
(*it).GetMultiUnitComponents( aLibs, tempMap );
|
|
|
|
|
2016-06-29 20:07:55 +00:00
|
|
|
for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
|
2016-02-15 20:14:48 +00:00
|
|
|
{
|
|
|
|
// Merge this list into the main one
|
|
|
|
unsigned n_refs = pair.second.GetCount();
|
2016-03-06 21:22:01 +00:00
|
|
|
|
2016-02-15 20:14:48 +00:00
|
|
|
for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
|
|
|
|
{
|
|
|
|
aRefList[pair.first].AddItem( pair.second[thisRef] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
SCH_ITEM* SCH_SHEET_LIST::FindNextItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFoundIn,
|
|
|
|
SCH_ITEM* aLastItem, bool aWrap )
|
|
|
|
{
|
|
|
|
bool hasWrapped = false;
|
|
|
|
bool firstItemFound = false;
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
|
|
|
SCH_ITEM* drawItem = NULL;
|
2016-03-06 21:22:01 +00:00
|
|
|
SCH_SHEET_PATHS_ITER it = begin();
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
while( it != end() )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
drawItem = (*it).LastDrawList();
|
2010-03-16 18:22:59 +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
|
|
|
while( drawItem )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
if( drawItem->Type() == aType )
|
|
|
|
{
|
|
|
|
if( aLastItem == NULL || firstItemFound )
|
|
|
|
{
|
|
|
|
if( aSheetFoundIn )
|
2016-03-06 21:22:01 +00:00
|
|
|
*aSheetFoundIn = &(*it);
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
return drawItem;
|
|
|
|
}
|
|
|
|
else if( !firstItemFound && drawItem == aLastItem )
|
|
|
|
{
|
|
|
|
firstItemFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
drawItem = drawItem->Next();
|
|
|
|
}
|
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
++it;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
if( it == end() && aLastItem && aWrap && !hasWrapped )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
hasWrapped = true;
|
2016-03-06 21:22:01 +00:00
|
|
|
it = begin();
|
2010-03-16 18:22:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_ITEM* SCH_SHEET_LIST::FindPreviousItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFoundIn,
|
|
|
|
SCH_ITEM* aLastItem, bool aWrap )
|
|
|
|
{
|
|
|
|
bool hasWrapped = false;
|
|
|
|
bool firstItemFound = false;
|
|
|
|
SCH_ITEM* drawItem = NULL;
|
2016-03-06 21:22:01 +00:00
|
|
|
SCH_SHEET_PATHS_RITER it = rbegin();
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
while( it != rend() )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
drawItem = (*it).FirstDrawList();
|
2010-03-16 18:22:59 +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
|
|
|
while( drawItem )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
if( drawItem->Type() == aType )
|
|
|
|
{
|
|
|
|
if( aLastItem == NULL || firstItemFound )
|
|
|
|
{
|
|
|
|
if( aSheetFoundIn )
|
2016-03-06 21:22:01 +00:00
|
|
|
*aSheetFoundIn = &(*it);
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
return drawItem;
|
|
|
|
}
|
|
|
|
else if( !firstItemFound && drawItem == aLastItem )
|
|
|
|
{
|
|
|
|
firstItemFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
drawItem = drawItem->Back();
|
|
|
|
}
|
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
++it;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
if( it == rend() && aLastItem && aWrap && !hasWrapped )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
hasWrapped = true;
|
2016-03-06 21:22:01 +00:00
|
|
|
it = rbegin();
|
2010-03-16 18:22:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2016-02-15 20:11:50 +00:00
|
|
|
|
|
|
|
|
2016-02-15 20:14:07 +00:00
|
|
|
bool SCH_SHEET_LIST::SetComponentFootprint( const wxString& aReference,
|
|
|
|
const wxString& aFootPrint, bool aSetVisible )
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
|
|
|
|
found = (*it).SetComponentFootprint( aReference, aFootPrint, aSetVisible );
|
2016-02-15 20:14:07 +00:00
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SHEET_LIST::IsComplexHierarchy() const
|
|
|
|
{
|
|
|
|
wxString fileName;
|
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
for( unsigned i = 0; i < size(); i++ )
|
2016-02-15 20:14:07 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
fileName = at( i ).Last()->GetFileName();
|
2016-02-15 20:14:07 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
for( unsigned j = 0; j < size(); j++ )
|
2016-02-15 20:14:07 +00:00
|
|
|
{
|
|
|
|
if( i == j )
|
|
|
|
continue;
|
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
if( fileName == at( j ).Last()->GetFileName() )
|
2016-02-15 20:14:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:12:42 +00:00
|
|
|
bool SCH_SHEET_LIST::TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
|
|
|
|
const wxString& aDestFileName ) const
|
|
|
|
{
|
|
|
|
wxFileName rootFn = g_RootSheet->GetFileName();
|
|
|
|
wxFileName destFn = aDestFileName;
|
|
|
|
|
|
|
|
if( destFn.IsRelative() )
|
|
|
|
destFn.MakeAbsolute( rootFn.GetPath() );
|
|
|
|
|
|
|
|
// Test each SCH_SHEET_PATH in this SCH_SHEET_LIST for potential recursion.
|
2016-03-06 21:22:01 +00:00
|
|
|
for( unsigned i = 0; i < size(); i++ )
|
2016-02-15 20:12:42 +00:00
|
|
|
{
|
|
|
|
// Test each SCH_SHEET_PATH in the source sheet.
|
2016-03-06 21:22:01 +00:00
|
|
|
for( unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
|
2016-02-15 20:12:42 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
const SCH_SHEET_PATH* sheetPath = &aSrcSheetHierarchy[j];
|
2016-02-15 20:12:42 +00:00
|
|
|
|
2016-02-27 19:35:45 +00:00
|
|
|
for( unsigned k = 0; k < sheetPath->size(); k++ )
|
2016-02-15 20:12:42 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
if( at( i ).TestForRecursion( sheetPath->GetSheet( k )->GetFileName(),
|
|
|
|
aDestFileName ) )
|
2016-02-15 20:12:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The source sheet file can safely be added to the destination sheet file.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-15 20:11:50 +00:00
|
|
|
SCH_SHEET* SCH_SHEET_LIST::FindSheetByName( const wxString& aSheetName )
|
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
for( unsigned i = 0; i < size(); i++ )
|
2016-02-15 20:11:50 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
SCH_SHEET* sheet = at( i ).FindSheetByName( aSheetName );
|
2016-02-15 20:11:50 +00:00
|
|
|
|
|
|
|
if( sheet )
|
|
|
|
return sheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|