Eeschema: move annotate power symbols from SCH_SHEET_PATH to SCH_SHEET.
1 * Uncouple SCH_COMPONENT::SetRef() from SCH_SHEET_PATH and use SCH_SHEET instead.
This commit is contained in:
parent
662d35633a
commit
133b8f6b96
|
@ -694,7 +694,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
|
|||
}
|
||||
|
||||
|
||||
SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent,
|
||||
SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent,
|
||||
SCH_SHEET_PATH& aSheetPath )
|
||||
{
|
||||
wxASSERT( aComponent != NULL && aLibComponent != NULL );
|
||||
|
@ -710,7 +710,7 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComp
|
|||
m_SheetNum = 0;
|
||||
|
||||
if( aComponent->GetRef( &aSheetPath ).IsEmpty() )
|
||||
aComponent->SetRef( &aSheetPath, wxT( "DefRef?" ) );
|
||||
aComponent->SetRef( aSheetPath.Last(), wxT( "DefRef?" ) );
|
||||
|
||||
SetRef( aComponent->GetRef( &aSheetPath ) );
|
||||
|
||||
|
@ -730,7 +730,7 @@ void SCH_REFERENCE::Annotate()
|
|||
else
|
||||
m_Ref = TO_UTF8( GetRef() << m_NumRef );
|
||||
|
||||
m_RootCmp->SetRef( &m_SheetPath, FROM_UTF8( m_Ref.c_str() ) );
|
||||
m_RootCmp->SetRef( m_SheetPath.Last(), FROM_UTF8( m_Ref.c_str() ) );
|
||||
m_RootCmp->SetUnit( m_Unit );
|
||||
m_RootCmp->SetUnitSelection( &m_SheetPath, m_Unit );
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <sch_base_frame.h>
|
||||
#include <class_library.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <dialog_helpers.h>
|
||||
#include <dialog_edit_component_in_schematic_fbp.h>
|
||||
|
||||
|
@ -458,7 +459,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
|
|||
// Reference has a specific initialization, depending on the current active sheet
|
||||
// because for a given component, in a complex hierarchy, there are more than one
|
||||
// reference.
|
||||
m_cmp->SetRef( &m_parent->GetCurrentSheet(), m_FieldsBuf[REFERENCE].GetText() );
|
||||
m_cmp->SetRef( m_parent->GetCurrentSheet().Last(), m_FieldsBuf[REFERENCE].GetText() );
|
||||
|
||||
m_parent->OnModify();
|
||||
m_parent->GetScreen()->TestDanglingEnds();
|
||||
|
|
|
@ -455,8 +455,8 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
|||
m_tstUniqueGlobalLabels = m_cbTestUniqueGlbLabels->GetValue();
|
||||
|
||||
// Build the whole sheet list in hierarchy (sheet, not screen)
|
||||
SCH_SHEET_LIST sheets;
|
||||
sheets.AnnotatePowerSymbols( Prj().SchLibs() );
|
||||
int refDes = 1;
|
||||
g_RootSheet->AnnotatePowerSymbols( Prj().SchLibs(), &refDes );
|
||||
|
||||
if( m_parent->CheckAnnotate( aMessagesList, false ) )
|
||||
{
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2015 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
|
||||
|
@ -38,6 +38,7 @@
|
|||
#include <general.h>
|
||||
#include <class_library.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_sheet_path.h>
|
||||
|
||||
#include <dialog_edit_one_field.h>
|
||||
|
||||
|
@ -101,7 +102,7 @@ void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField )
|
|||
// Test if the reference string is valid:
|
||||
if( SCH_COMPONENT::IsReferenceStringValid( newtext ) )
|
||||
{
|
||||
component->SetRef( m_CurrentSheet, newtext );
|
||||
component->SetRef( m_CurrentSheet->Last(), newtext );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -67,9 +67,9 @@ int TestDuplicateSheetNames( bool aCreateMarker );
|
|||
|
||||
bool SCH_EDIT_FRAME::prepareForNetlist()
|
||||
{
|
||||
SCH_SHEET_LIST sheets;
|
||||
int refDes = 1;
|
||||
|
||||
sheets.AnnotatePowerSymbols( Prj().SchLibs() );
|
||||
g_RootSheet->AnnotatePowerSymbols( Prj().SchLibs(), &refDes );
|
||||
|
||||
// Performs some controls:
|
||||
if( CheckAnnotate( NULL, 0 ) )
|
||||
|
|
|
@ -184,7 +184,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit,
|
|||
|
||||
// update the reference -- just the prefix for now.
|
||||
msg += wxT( "?" );
|
||||
SetRef( sheet, msg );
|
||||
SetRef( sheet->Last(), msg );
|
||||
|
||||
// Use the schematic component name instead of the library value field
|
||||
// name.
|
||||
|
@ -471,7 +471,7 @@ const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet )
|
|||
// all have the same component references, but perhaps this is best.
|
||||
if( !GetField( REFERENCE )->GetText().IsEmpty() )
|
||||
{
|
||||
SetRef( sheet, GetField( REFERENCE )->GetText() );
|
||||
SetRef( sheet->Last(), GetField( REFERENCE )->GetText() );
|
||||
return GetField( REFERENCE )->GetText();
|
||||
}
|
||||
|
||||
|
@ -504,9 +504,9 @@ bool SCH_COMPONENT::IsReferenceStringValid( const wxString& aReferenceString )
|
|||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
|
||||
void SCH_COMPONENT::SetRef( const SCH_SHEET* aSheet, const wxString& ref )
|
||||
{
|
||||
wxString path = GetPath( sheet->Last() );
|
||||
wxString path = GetPath( aSheet );
|
||||
|
||||
bool notInArray = true;
|
||||
|
||||
|
|
|
@ -418,7 +418,7 @@ public:
|
|||
/**
|
||||
* Set the reference, for the given sheet path.
|
||||
*/
|
||||
void SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref );
|
||||
void SetRef( const SCH_SHEET* aSheet, const wxString& ref );
|
||||
|
||||
/**
|
||||
* Function AddHierarchicalReference
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include <class_library.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_field.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <kicad_string.h>
|
||||
|
||||
|
||||
|
@ -447,7 +448,7 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData )
|
|||
isReplaced = EDA_ITEM::Replace( aSearchData, text );
|
||||
|
||||
if( isReplaced )
|
||||
component->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
|
||||
component->SetRef( ((SCH_SHEET_PATH*) aAuxData)->Last(), text );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <kicad_string.h>
|
||||
#include <msgpanel.h>
|
||||
|
||||
#include <class_library.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <sch_component.h>
|
||||
|
@ -1294,6 +1295,43 @@ void SCH_SHEET::ClearModifyStatus()
|
|||
}
|
||||
|
||||
|
||||
void SCH_SHEET::AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference )
|
||||
{
|
||||
int ref = 1;
|
||||
|
||||
if( aReference )
|
||||
ref = *aReference;
|
||||
|
||||
for( EDA_ITEM* item = m_screen->GetDrawItems(); item; item = item->Next() )
|
||||
{
|
||||
if( item->Type() != SCH_COMPONENT_T )
|
||||
continue;
|
||||
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
||||
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
|
||||
|
||||
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 = wxT( "#" ) + refstr;
|
||||
|
||||
refstr << wxT( "0" ) << ref;
|
||||
component->SetRef( this, refstr );
|
||||
ref++;
|
||||
}
|
||||
|
||||
if( aReference )
|
||||
*aReference = ref;
|
||||
}
|
||||
|
||||
|
||||
SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
|
||||
{
|
||||
wxLogDebug( wxT( "Sheet assignment operator." ) );
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <sch_text.h>
|
||||
|
||||
|
||||
class PART_LIBS;
|
||||
class LINE_READER;
|
||||
class SCH_SCREEN;
|
||||
class SCH_SHEET;
|
||||
|
@ -656,6 +657,17 @@ public:
|
|||
*/
|
||||
bool IsAutoSaveRequired();
|
||||
|
||||
/**
|
||||
* 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 in the sheet that is annotated.
|
||||
*/
|
||||
void AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference );
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const; // override
|
||||
#endif
|
||||
|
|
|
@ -245,43 +245,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 = aLibs->FindLibPart( component->GetPartName() );
|
||||
|
||||
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 = wxT( "#" ) + refstr;
|
||||
|
||||
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 )
|
||||
{
|
||||
// Search to sheet path number:
|
||||
|
@ -684,15 +647,6 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet )
|
|||
}
|
||||
|
||||
|
||||
void SCH_SHEET_LIST::AnnotatePowerSymbols( PART_LIBS* aLibs )
|
||||
{
|
||||
int ref = 1;
|
||||
|
||||
for( SCH_SHEET_PATH* path = GetFirst(); path; path = GetNext() )
|
||||
path->AnnotatePowerSymbols( aLibs, &ref );
|
||||
}
|
||||
|
||||
|
||||
void SCH_SHEET_LIST::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
|
||||
bool aIncludePowerSymbols )
|
||||
{
|
||||
|
|
|
@ -226,17 +226,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.
|
||||
|
@ -436,13 +425,6 @@ public:
|
|||
*/
|
||||
SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true );
|
||||
|
||||
/**
|
||||
* Function AnnotatePowerSymbols
|
||||
* clear and annotates the entire hierarchy of the sheet path list.
|
||||
* @param aLib the library list to use
|
||||
*/
|
||||
void AnnotatePowerSymbols( PART_LIBS* aLib );
|
||||
|
||||
/**
|
||||
* Function GetComponents
|
||||
* adds a SCH_REFERENCE() object to \a aReferences for each component in the list
|
||||
|
@ -451,7 +433,8 @@ public:
|
|||
* @param aReferences List of references to populate.
|
||||
* @param aIncludePowerSymbols Set to false to only get normal components.
|
||||
*/
|
||||
void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols = true );
|
||||
void GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
|
||||
bool aIncludePowerSymbols = true );
|
||||
|
||||
/**
|
||||
* Function GetMultiUnitComponents
|
||||
|
|
Loading…
Reference in New Issue