Eeschema: uncouple clearing annotation from SCH_SHEET_PATH.
* Add code to SCH_SHEET object to clear annotation. * Change SCH_COMPONENT::GetPath() to derive path from SCH_SHEET object instead of SCH_SHEET_PATH object. * Remove clear annotation code from SCH_SCREENS object.
This commit is contained in:
parent
c5e9bda936
commit
c6d591b534
|
@ -6,7 +6,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
|
||||
* 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
|
||||
|
@ -35,19 +35,18 @@
|
|||
|
||||
#include <sch_reference_list.h>
|
||||
#include <class_library.h>
|
||||
#include <sch_sheet.h>
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly )
|
||||
{
|
||||
if( aCurrentSheetOnly )
|
||||
{
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
wxCHECK_RET( screen != NULL, wxT( "Attempt to clear annotation of a NULL screen." ) );
|
||||
screen->ClearAnnotation( m_CurrentSheet );
|
||||
m_CurrentSheet->Last()->ClearAnnotation();
|
||||
}
|
||||
else
|
||||
{
|
||||
SCH_SCREENS ScreenList;
|
||||
ScreenList.ClearAnnotation();
|
||||
m_CurrentSheet->Last()->GetRootSheet()->ClearAnnotation( true );
|
||||
}
|
||||
|
||||
// Update the references for the sheet that is currently being displayed.
|
||||
|
|
|
@ -425,11 +425,11 @@ public:
|
|||
|
||||
/**
|
||||
* Function ClearAnnotation
|
||||
* clears the annotation for the components in \a aSheetPath on the screen.
|
||||
* @param aSheetPath The sheet path of the component annotation to clear. If NULL then
|
||||
* the entire hierarchy is cleared.
|
||||
* clears the annotation for the components in \a aSheet on the screen.
|
||||
* @param aSheet The sheet of the component annotation to clear. If NULL then
|
||||
* the entire hierarchy is cleared for this screen.
|
||||
*/
|
||||
void ClearAnnotation( SCH_SHEET_PATH* aSheetPath );
|
||||
void ClearAnnotation( SCH_SHEET* aSheet );
|
||||
|
||||
/**
|
||||
* Function GetHierarchicalItems
|
||||
|
@ -549,12 +549,6 @@ public:
|
|||
SCH_SCREEN* GetNext();
|
||||
SCH_SCREEN* GetScreen( unsigned int aIndex ) const;
|
||||
|
||||
/**
|
||||
* Function ClearAnnotation
|
||||
* clears the annotation for all components in the hierarchy.
|
||||
*/
|
||||
void ClearAnnotation();
|
||||
|
||||
/**
|
||||
* Function SchematicCleanUp
|
||||
* merges and breaks wire segments in the entire schematic hierarchy.
|
||||
|
|
|
@ -102,7 +102,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, uns
|
|||
field = comp->GetRef( path );
|
||||
|
||||
ret |= fprintf( f, " ( %s %s",
|
||||
TO_UTF8( comp->GetPath( path ) ),
|
||||
TO_UTF8( comp->GetPath( path->Last() ) ),
|
||||
TO_UTF8( footprint ) );
|
||||
|
||||
ret |= fprintf( f, " %s", TO_UTF8( field ) );
|
||||
|
|
|
@ -429,21 +429,21 @@ void SCH_COMPONENT::AddHierarchicalReference( const wxString& aPath,
|
|||
}
|
||||
|
||||
|
||||
wxString SCH_COMPONENT::GetPath( const SCH_SHEET_PATH* sheet ) const
|
||||
wxString SCH_COMPONENT::GetPath( const SCH_SHEET* aSheet ) const
|
||||
{
|
||||
wxCHECK_MSG( sheet != NULL, wxEmptyString,
|
||||
wxCHECK_MSG( aSheet != NULL, wxEmptyString,
|
||||
wxT( "Cannot get component path with invalid sheet object." ) );
|
||||
|
||||
wxString str;
|
||||
|
||||
str.Printf( wxT( "%8.8lX" ), (long unsigned) m_TimeStamp );
|
||||
return sheet->Path() + str;
|
||||
return aSheet->GetPath() + str;
|
||||
}
|
||||
|
||||
|
||||
const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet )
|
||||
{
|
||||
wxString path = GetPath( sheet );
|
||||
wxString path = GetPath( sheet->Last() );
|
||||
wxString h_path, h_ref;
|
||||
wxStringTokenizer tokenizer;
|
||||
wxString separators( wxT( " " ) );
|
||||
|
@ -505,7 +505,7 @@ bool SCH_COMPONENT::IsReferenceStringValid( const wxString& aReferenceString )
|
|||
|
||||
void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
|
||||
{
|
||||
wxString path = GetPath( sheet );
|
||||
wxString path = GetPath( sheet->Last() );
|
||||
|
||||
bool notInArray = true;
|
||||
|
||||
|
@ -583,7 +583,7 @@ void SCH_COMPONENT::SetTimeStamp( time_t aNewTimeStamp )
|
|||
|
||||
int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet )
|
||||
{
|
||||
wxString path = GetPath( aSheet );
|
||||
wxString path = GetPath( aSheet->Last() );
|
||||
wxString h_path, h_multi;
|
||||
wxStringTokenizer tokenizer;
|
||||
wxString separators( wxT( " " ) );
|
||||
|
@ -611,7 +611,7 @@ int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet )
|
|||
|
||||
void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection )
|
||||
{
|
||||
wxString path = GetPath( aSheet );
|
||||
wxString path = GetPath( aSheet->Last() );
|
||||
|
||||
bool notInArray = true;
|
||||
|
||||
|
@ -727,7 +727,7 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem )
|
|||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
|
||||
void SCH_COMPONENT::ClearAnnotation( SCH_SHEET* aSheet )
|
||||
{
|
||||
bool keepMulti = false;
|
||||
wxArrayString reference_fields;
|
||||
|
@ -750,7 +750,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
|
|||
}
|
||||
else
|
||||
{ // This is a malformed reference: reinit this reference
|
||||
m_prefix = defRef = wxT("U"); // Set to default ref prefix
|
||||
m_prefix = defRef = wxT( "U" ); // Set to default ref prefix
|
||||
}
|
||||
|
||||
defRef.Append( wxT( "?" ) );
|
||||
|
@ -759,22 +759,22 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
|
|||
|
||||
// For components with units locked,
|
||||
// we cannot remove all annotations: part selection must be kept
|
||||
// For all components: if aSheetPath is not NULL,
|
||||
// For all components: if aSheet is not NULL,
|
||||
// remove annotation only for the given path
|
||||
if( keepMulti || aSheetPath )
|
||||
if( keepMulti || aSheet )
|
||||
{
|
||||
wxString NewHref;
|
||||
wxString path;
|
||||
|
||||
if( aSheetPath )
|
||||
path = GetPath( aSheetPath );
|
||||
if( aSheet )
|
||||
path = GetPath( aSheet );
|
||||
|
||||
for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
|
||||
{
|
||||
// Break hierarchical reference in path, ref and multi selection:
|
||||
reference_fields = wxStringTokenize( m_PathsAndReferences[ii], separators );
|
||||
|
||||
if( aSheetPath == NULL || reference_fields[0].Cmp( path ) == 0 )
|
||||
if( aSheet == NULL || reference_fields[0].Cmp( path ) == 0 )
|
||||
{
|
||||
if( keepMulti ) // Get and keep part selection
|
||||
multi = reference_fields[2];
|
||||
|
|
|
@ -240,10 +240,10 @@ public:
|
|||
/**
|
||||
* Function ClearAnnotation
|
||||
* clears exiting component annotation ( i.i IC23 changed to IC? and part reset to 1)
|
||||
* @param aSheetPath: SCH_SHEET_PATH value: if NULL remove all annotations,
|
||||
* else remove annotation relative to this sheetpath
|
||||
* @param aSheet: SCH_SHEET value: if NULL remove all annotations,
|
||||
* else remove annotation relative to \a aSheet.
|
||||
*/
|
||||
void ClearAnnotation( SCH_SHEET_PATH* aSheetPath );
|
||||
void ClearAnnotation( SCH_SHEET* aSheet );
|
||||
|
||||
/**
|
||||
* Function SetTimeStamp
|
||||
|
@ -329,8 +329,8 @@ public:
|
|||
|
||||
void SwapData( SCH_ITEM* aItem );
|
||||
|
||||
// returns a unique ID, in the form of a path.
|
||||
wxString GetPath( const SCH_SHEET_PATH* sheet ) const;
|
||||
// returns a unique ID, in the form of a path determined by \a aSheet.
|
||||
wxString GetPath( const SCH_SHEET* sheet ) const;
|
||||
|
||||
/**
|
||||
* Function IsReferenceStringValid (static)
|
||||
|
|
|
@ -755,7 +755,7 @@ int SCH_SCREEN::CountConnectedItems( const wxPoint& aPos, bool aTestJunctions )
|
|||
}
|
||||
|
||||
|
||||
void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
|
||||
void SCH_SCREEN::ClearAnnotation( SCH_SHEET* aSheet )
|
||||
{
|
||||
for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() )
|
||||
{
|
||||
|
@ -763,7 +763,7 @@ void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
|
|||
{
|
||||
SCH_COMPONENT* component = (SCH_COMPONENT*) item;
|
||||
|
||||
component->ClearAnnotation( aSheetPath );
|
||||
component->ClearAnnotation( aSheet );
|
||||
|
||||
// Clear the modified component flag set by component->ClearAnnotation
|
||||
// because we do not use it here and we should not leave this flag set,
|
||||
|
@ -1431,13 +1431,6 @@ void SCH_SCREENS::BuildScreenList( EDA_ITEM* aItem )
|
|||
}
|
||||
|
||||
|
||||
void SCH_SCREENS::ClearAnnotation()
|
||||
{
|
||||
for( size_t i = 0; i < m_screens.size(); i++ )
|
||||
m_screens[i]->ClearAnnotation( NULL );
|
||||
}
|
||||
|
||||
|
||||
void SCH_SCREENS::SchematicCleanUp()
|
||||
{
|
||||
for( size_t i = 0; i < m_screens.size(); i++ )
|
||||
|
|
|
@ -1214,6 +1214,25 @@ wxString SCH_SHEET::GetHumanReadablePath() const
|
|||
}
|
||||
|
||||
|
||||
void SCH_SHEET::ClearAnnotation( bool aIncludeSubSheets )
|
||||
{
|
||||
m_screen->ClearAnnotation( this );
|
||||
|
||||
if( aIncludeSubSheets )
|
||||
{
|
||||
SCH_ITEM* item = m_screen->GetDrawItems();
|
||||
|
||||
while( item )
|
||||
{
|
||||
if( item->Type() == SCH_SHEET_T )
|
||||
static_cast<SCH_SHEET*>( item )->ClearAnnotation( aIncludeSubSheets );
|
||||
|
||||
item = item->Next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem )
|
||||
{
|
||||
wxLogDebug( wxT( "Sheet assignment operator." ) );
|
||||
|
|
|
@ -633,6 +633,8 @@ public:
|
|||
*/
|
||||
wxString GetHumanReadablePath() const;
|
||||
|
||||
void ClearAnnotation( bool aIncludeSubSheets = false );
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const; // override
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue