Change the way power symbols are annotated before creating a netlist or running ERC.
Now only not annotated symbols (or duplicate references) are modified.
This commit is contained in:
parent
f453cec938
commit
f042fcddd0
|
@ -6,9 +6,9 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2011 jean-pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||
* Copyright (C) 1992-2011 jean-pierre Charras <jp.charras at wanadoo.fr>
|
||||
* Copyright (C) 1992-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -193,19 +193,6 @@ void SCH_REFERENCE_LIST::RemoveSubComponentsFromList()
|
|||
}
|
||||
|
||||
|
||||
void SCH_REFERENCE_LIST::ResetHiddenReferences()
|
||||
{
|
||||
for( unsigned ii = 0; ii < componentFlatList.size(); ii++ )
|
||||
{
|
||||
if( componentFlatList[ii].GetRefStr()[0] == '#' )
|
||||
{
|
||||
componentFlatList[ii].m_IsNew = true;
|
||||
componentFlatList[ii].m_NumRef = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_REFERENCE_LIST::GetRefsInUse( int aIndex, std::vector< int >& aIdList, int aMinRefId )
|
||||
{
|
||||
aIdList.clear();
|
||||
|
@ -292,9 +279,6 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
|
|||
int LastReferenceNumber = 0;
|
||||
int NumberOfUnits, Unit;
|
||||
|
||||
// Components with an invisible reference (power...) always are re-annotated.
|
||||
ResetHiddenReferences();
|
||||
|
||||
/* calculate index of the first component with the same reference prefix
|
||||
* than the current component. All components having the same reference
|
||||
* prefix will receive a reference number with consecutive values:
|
||||
|
@ -727,7 +711,15 @@ void SCH_REFERENCE::Annotate()
|
|||
if( m_NumRef < 0 )
|
||||
m_Ref += wxChar( '?' );
|
||||
else
|
||||
m_Ref = TO_UTF8( GetRef() << m_NumRef );
|
||||
{
|
||||
// To avoid a risk of duplicate, for power components
|
||||
// the ref number is 0nnn instead of nnn.
|
||||
// Just because sometimes only power components are annotated
|
||||
if( GetLibPart() && GetLibPart()->IsPower() )
|
||||
m_Ref = TO_UTF8( GetRef() << "0" << m_NumRef );
|
||||
else
|
||||
m_Ref = TO_UTF8( GetRef() << m_NumRef );
|
||||
}
|
||||
|
||||
m_RootCmp->SetRef( &m_SheetPath, FROM_UTF8( m_Ref.c_str() ) );
|
||||
m_RootCmp->SetUnit( m_Unit );
|
||||
|
|
|
@ -411,13 +411,6 @@ public:
|
|||
*/
|
||||
int FindUnit( size_t aIndex, int aUnit );
|
||||
|
||||
/**
|
||||
* Function ResetHiddenReferences
|
||||
* clears the annotation for all references that have an invisible reference designator.
|
||||
* Invisible reference designators always have # as the first letter.
|
||||
*/
|
||||
void ResetHiddenReferences();
|
||||
|
||||
/**
|
||||
* Function GetRefsInUse
|
||||
* adds all the reference designator numbers greater than \a aMinRefId to \a aIdList
|
||||
|
|
|
@ -181,42 +181,6 @@ void SCH_SHEET_PATH::UpdateAllScreenReferences()
|
|||
}
|
||||
|
||||
|
||||
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 )
|
||||
continue;
|
||||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
||||
LIB_PART* part = component->GetPartRef().lock().get();
|
||||
|
||||
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( "#" ) ) )
|
||||
refstr.insert( refstr.begin(), wxChar( '#' ) );
|
||||
|
||||
refstr << wxT( "0" ) << ref;
|
||||
component->SetRef( this, refstr );
|
||||
ref++;
|
||||
}
|
||||
|
||||
if( aReference )
|
||||
*aReference = ref;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
|
||||
bool aIncludePowerSymbols )
|
||||
|
@ -562,10 +526,79 @@ void SCH_SHEET_LIST::ClearModifyStatus()
|
|||
|
||||
void SCH_SHEET_LIST::AnnotatePowerSymbols( PART_LIBS* aLibs )
|
||||
{
|
||||
int ref = 1;
|
||||
// List of reference for power symbols
|
||||
SCH_REFERENCE_LIST references;
|
||||
|
||||
// Map of locked components (not used, but needed by Annotate()
|
||||
SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
|
||||
|
||||
// Build the list of power components:
|
||||
for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
|
||||
(*it).AnnotatePowerSymbols( aLibs, &ref );
|
||||
{
|
||||
SCH_SHEET_PATH& spath = *it;
|
||||
|
||||
for( EDA_ITEM* item = spath.LastDrawList(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() != SCH_COMPONENT_T )
|
||||
continue;
|
||||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
||||
LIB_PART* part = component->GetPartRef().lock().get();
|
||||
|
||||
if( !part || !part->IsPower() )
|
||||
continue;
|
||||
|
||||
if( part )
|
||||
{
|
||||
SCH_REFERENCE reference( component, part, spath );
|
||||
references.AddItem( reference );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Find duplicate, and silently clear annotation of duplicate
|
||||
std::map<wxString, int> ref_list; // stores the existing references
|
||||
|
||||
for( unsigned ii = 0; ii< references.GetCount(); ++ii )
|
||||
{
|
||||
wxString curr_ref = references[ii].GetRef();
|
||||
|
||||
if( ref_list.find( curr_ref ) == ref_list.end() )
|
||||
{
|
||||
ref_list[curr_ref] = ii;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Possible duplicate, if the ref ends by a number:
|
||||
if( curr_ref.Last() < '0' && curr_ref.Last() > '9' )
|
||||
continue; // not annotated
|
||||
|
||||
// Duplicate: clear annotation by removing the number ending the ref
|
||||
while( curr_ref.Last() >= '0' && curr_ref.Last() <= '9' )
|
||||
curr_ref.RemoveLast();
|
||||
|
||||
references[ii].SetRef( curr_ref );
|
||||
}
|
||||
|
||||
|
||||
// Break full components reference in name (prefix) and number:
|
||||
// example: IC1 become IC, and 1
|
||||
references.SplitReferences();
|
||||
|
||||
// Ensure all power symbols have the reference starting by '#'
|
||||
// (No sure this is really useful)
|
||||
for( unsigned ii = 0; ii< references.GetCount(); ++ii )
|
||||
{
|
||||
if( references[ii].GetRef()[0] != '#' )
|
||||
{
|
||||
wxString new_ref = "#" + references[ii].GetRef();
|
||||
references[ii].SetRef( new_ref );
|
||||
}
|
||||
}
|
||||
|
||||
// Recalculate and update reference numbers in schematic
|
||||
references.Annotate( false, 100, lockedComponents );
|
||||
references.UpdateAnnotation();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
||||
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -111,8 +111,6 @@ typedef std::map<wxString, SCH_REFERENCE_LIST> SCH_MULTI_UNIT_REFERENCE_MAP;
|
|||
*/
|
||||
class SCH_SHEET_PATH : public SCH_SHEETS
|
||||
{
|
||||
#define MAX_SHEET_DEPTH 32 /// Maximum number of levels for a sheet path.
|
||||
|
||||
int m_pageNumber; /// Page numbers are maintained by the sheet load order.
|
||||
|
||||
public:
|
||||
|
@ -203,17 +201,6 @@ public:
|
|||
*/
|
||||
void UpdateAllScreenReferences();
|
||||
|
||||
/**
|
||||
* Function AnnotatePowerSymbols
|
||||
* annotates the power symbols only starting at \a aReference in the sheet path.
|
||||
* @param aLibs the library list to use
|
||||
* @param aReference A pointer to the number for the reference designator of the
|
||||
* first power symbol to be annotated. If the pointer is NULL
|
||||
* the annotation starts at 1. The number is incremented for
|
||||
* each power symbol annotated.
|
||||
*/
|
||||
void AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference );
|
||||
|
||||
/**
|
||||
* Function GetComponents
|
||||
* adds a SCH_REFERENCE() object to \a aReferences for each component in the sheet.
|
||||
|
@ -244,7 +231,7 @@ public:
|
|||
* @param aReference The reference designator of the component.
|
||||
* @param aFootPrint The value to set the footprint field.
|
||||
* @param aSetVisible The value to set the field visibility flag.
|
||||
* @return True if \a aReference was found otherwise false.
|
||||
* @return true if \a aReference was found otherwise false.
|
||||
*/
|
||||
bool SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
|
||||
bool aSetVisible );
|
||||
|
@ -364,7 +351,7 @@ public:
|
|||
/**
|
||||
* Function IsModified
|
||||
* checks the entire hierarchy for any modifications.
|
||||
* @returns True if the hierarchy is modified otherwise false.
|
||||
* @return True if the hierarchy is modified otherwise false.
|
||||
*/
|
||||
bool IsModified();
|
||||
|
||||
|
@ -379,7 +366,11 @@ public:
|
|||
|
||||
/**
|
||||
* Function AnnotatePowerSymbols
|
||||
* clear and annotates the entire hierarchy of the sheet path list.
|
||||
* Silently annotates the not yet annotated power symbols of the entire hierarchy
|
||||
* of the sheet path list.
|
||||
* It is called before creating a netlist, to annotate power symbols, without prompting
|
||||
* the user about not annotated or duplicate for these symbols, if only these symbols
|
||||
* need annotation ( a very frequent case ).
|
||||
* @param aLib the library list to use
|
||||
*/
|
||||
void AnnotatePowerSymbols( PART_LIBS* aLib );
|
||||
|
|
Loading…
Reference in New Issue