Revert "Eeschema: fix broken page numbers when renaming a sheet file name."

This reverts commit a468a79948.
This commit is contained in:
Wayne Stambaugh 2021-12-06 07:47:18 -05:00
parent 5ae844ba93
commit a03e6e4926
19 changed files with 193 additions and 85 deletions

View File

@ -165,7 +165,7 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataToWindow()
instance.push_back( m_sheet );
wxString nextPageNumber = m_sheet->GetPageNumber();
wxString nextPageNumber = m_sheet->GetPageNumber( instance );
m_pageNumberTextCtrl->ChangeValue( nextPageNumber );
@ -373,7 +373,10 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow()
instance.push_back( m_sheet );
m_sheet->SetPageNumber( m_pageNumberTextCtrl->GetValue() );
if( m_sheet->IsNew() )
m_sheet->AddInstance( instance.Path() );
m_sheet->SetPageNumber( instance, m_pageNumberTextCtrl->GetValue() );
m_frame->TestDanglingEnds();

View File

@ -179,13 +179,10 @@ void HIERARCHY_NAVIG_DLG::buildHierarchyTree( SCH_SHEET_PATH* aList, wxTreeItemI
for( SCH_ITEM* aItem : sheetChildren )
{
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
wxCHECK2( sheet, continue );
aList->push_back( sheet );
wxString sheetName = formatPageString( sheet->GetFields()[SHEETNAME].GetShownText(),
sheet->GetPageNumber() );
sheet->GetPageNumber( *aList ) );
m_nbsheets++;
wxTreeItemId menu;
menu = m_Tree->AppendItem( *aPreviousmenu, sheetName, 0, 1 );
@ -269,7 +266,7 @@ wxString HIERARCHY_NAVIG_DLG::getRootString()
SCH_SHEET_PATH rootPath;
rootPath.push_back( rootSheet );
return formatPageString ( _( "Root" ), rootSheet->GetPageNumber() );
return formatPageString ( _( "Root" ), rootSheet->GetPageNumber( rootPath ) );
}

View File

@ -542,7 +542,7 @@ void SCH_EDIT_FRAME::SetSheetNumberAndCount()
GetCurrentSheet().SetVirtualPageNumber( sheet_number );
GetScreen()->SetVirtualPageNumber( sheet_number );
GetScreen()->SetPageNumber( Schematic().CurrentSheet().Last()->GetPageNumber() );
GetScreen()->SetPageNumber( GetCurrentSheet().GetPageNumber() );
}
@ -583,7 +583,8 @@ void SCH_EDIT_FRAME::CreateScreens()
SCH_SHEET_PATH rootSheetPath;
rootSheetPath.push_back( &m_schematic->Root() );
m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
m_schematic->Root().SetPageNumber( wxT( "1" ) );
m_schematic->Root().AddInstance( rootSheetPath.Path() );
m_schematic->Root().SetPageNumber( rootSheetPath, wxT( "1" ) );
if( GetScreen() == nullptr )
{
@ -1395,7 +1396,7 @@ void SCH_EDIT_FRAME::RecomputeIntersheetRefs()
for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
{
if( sheet.LastScreen() == screen )
pageNumbers.push_back( sheet.Last()->GetPageNumber() );
pageNumbers.push_back( sheet.GetPageNumber() );
}
for( SCH_ITEM* item : screen->Items() )

View File

@ -627,10 +627,9 @@ void SCH_FIELD::DoHypertextMenu( EDA_DRAW_FRAME* aFrame )
std::vector<wxString> pageListCopy;
pageListCopy.insert( pageListCopy.end(), it->second.begin(), it->second.end() );
if( !Schematic()->Settings().m_IntersheetRefsListOwnPage )
{
wxString currentPage = Schematic()->CurrentSheet().Last()->GetPageNumber();
wxString currentPage = Schematic()->CurrentSheet().GetPageNumber();
alg::delete_matching( pageListCopy, currentPage );
if( pageListCopy.empty() )
@ -646,9 +645,9 @@ void SCH_FIELD::DoHypertextMenu( EDA_DRAW_FRAME* aFrame )
for( const SCH_SHEET_PATH& sheet : Schematic()->GetSheets() )
{
if( sheet.size() == 1 )
sheetNames[ sheet.Last()->GetPageNumber() ] = _( "<root sheet>" );
sheetNames[ sheet.GetPageNumber() ] = _( "<root sheet>" );
else
sheetNames[ sheet.Last()->GetPageNumber() ] = sheet.Last()->GetName();
sheetNames[ sheet.GetPageNumber() ] = sheet.Last()->GetName();
}
for( int i = 0; i < (int) pageListCopy.size(); ++i )

View File

@ -180,7 +180,8 @@ SCH_SHEET* SCH_ALTIUM_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchem
SCH_SHEET_PATH sheetpath;
sheetpath.push_back( m_rootSheet );
m_rootSheet->SetPageNumber( "#" ); // We'll update later if we find a
m_rootSheet->AddInstance( sheetpath.Path() );
m_rootSheet->SetPageNumber( sheetpath, "#" ); // We'll update later if we find a
// pageNumber record for it
}
@ -1519,7 +1520,9 @@ void SCH_ALTIUM_PLUGIN::ParseSheetSymbol( int aIndex,
m_rootSheet->LocatePathOfScreen( m_currentSheet->GetScreen(), &sheetpath );
sheetpath.push_back( sheet );
sheet->SetPageNumber( "#" ); // We'll update later if we find a pageNumber record for it.
sheet->AddInstance( sheetpath.Path() );
sheet->SetPageNumber( sheetpath, "#" ); // We'll update later if we find a pageNumber
// record for it
m_sheets.insert( { aIndex, sheet } );
}
@ -2340,7 +2343,7 @@ void SCH_ALTIUM_PLUGIN::ParseParameter( const std::map<wxString, wxString>& aPro
SCH_SHEET_PATH sheetpath;
m_rootSheet->LocatePathOfScreen( m_currentSheet->GetScreen(), &sheetpath );
sheetpath.Last()->SetPageNumber( elem.text );
m_rootSheet->SetPageNumber( sheetpath, elem.text );
}
else if( paramName == "TITLE" )
{

View File

@ -265,7 +265,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheets()
const std::vector<LAYER_ID>& orphanSheets = findOrphanSheets();
SCH_SHEET_PATH rootPath;
rootPath.push_back( m_rootSheet );
m_rootSheet->SetPageNumber( wxT( "1" ) );
m_rootSheet->AddInstance( rootPath.Path() );
m_rootSheet->SetPageNumber( rootPath, wxT( "1" ) );
if( orphanSheets.size() > 1 )
{
@ -2148,9 +2149,10 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(
sheet->GetScreen()->SetFileName( fn.GetFullPath() );
aParentSheet.Last()->GetScreen()->Append( sheet );
instance.push_back( sheet );
sheet->AddInstance( instance.Path() );
wxString pageNumStr = wxString::Format( "%d", getSheetNumber( aCadstarSheetID ) );
sheet->SetPageNumber( pageNumStr );
sheet->SetPageNumber( instance, pageNumStr );
sheet->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );

View File

@ -138,7 +138,7 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) :
m_borderWidth = aSheet.m_borderWidth;
m_borderColor = aSheet.m_borderColor;
m_backgroundColor = aSheet.m_backgroundColor;
m_pageNumber = aSheet.m_pageNumber;
m_instances = aSheet.m_instances;
if( m_screen )
m_screen->IncRefCount();
@ -256,7 +256,7 @@ bool SCH_SHEET::ResolveTextVar( wxString* token, int aDepth ) const
{
if( sheet.Last() == this ) // Current sheet path found
{
*token = wxString::Format( "%s", sheet.Last()->GetPageNumber() );
*token = wxString::Format( "%s", sheet.GetPageNumber() );
return true;
}
}
@ -308,7 +308,7 @@ void SCH_SHEET::SwapData( SCH_ITEM* aItem )
std::swap( m_borderWidth, sheet->m_borderWidth );
std::swap( m_borderColor, sheet->m_borderColor );
std::swap( m_backgroundColor, sheet->m_backgroundColor );
std::swap( m_pageNumber, sheet->m_pageNumber );
std::swap( m_instances, sheet->m_instances );
}
@ -1096,7 +1096,8 @@ SCH_SHEET& SCH_SHEET::operator=( const SCH_ITEM& aItem )
m_pins.back()->SetParent( this );
}
m_pageNumber = m_pageNumber;
for( const SCH_SHEET_INSTANCE& instance : sheet->m_instances )
m_instances.emplace_back( instance );
}
return *this;
@ -1120,15 +1121,60 @@ bool SCH_SHEET::operator <( const SCH_ITEM& aItem ) const
}
wxString SCH_SHEET::GetPageNumber() const
bool SCH_SHEET::AddInstance( const KIID_PATH& aSheetPath )
{
return m_pageNumber;
// a empty sheet path is illegal:
wxCHECK( aSheetPath.size() > 0, false );
wxString path;
for( const SCH_SHEET_INSTANCE& instance : m_instances )
{
// if aSheetPath is found, nothing to do:
if( instance.m_Path == aSheetPath )
return false;
}
SCH_SHEET_INSTANCE instance;
instance.m_Path = aSheetPath;
// This entry does not exist: add it with an empty page number.
m_instances.emplace_back( instance );
return true;
}
void SCH_SHEET::SetPageNumber( const wxString& aPageNumber )
wxString SCH_SHEET::GetPageNumber( const SCH_SHEET_PATH& aInstance ) const
{
m_pageNumber = aPageNumber;
wxString pageNumber;
KIID_PATH path = aInstance.Path();
for( const SCH_SHEET_INSTANCE& instance : m_instances )
{
if( instance.m_Path == path )
{
pageNumber = instance.m_PageNumber;
break;
}
}
return pageNumber;
}
void SCH_SHEET::SetPageNumber( const SCH_SHEET_PATH& aInstance, const wxString& aPageNumber )
{
KIID_PATH path = aInstance.Path();
for( SCH_SHEET_INSTANCE& instance : m_instances )
{
if( instance.m_Path == path )
{
instance.m_PageNumber = aPageNumber;
break;
}
}
}

View File

@ -390,18 +390,36 @@ public:
EDA_ITEM* Clone() const override;
/**
* Return the sheet page number.
*
* @return the page number for the sheet.
* @return the list of #SCH_SHEET_INSTANCE objects for this sheet.
*/
wxString GetPageNumber() const;
const std::vector<SCH_SHEET_INSTANCE> GetInstances() const;
/**
* Set the page number for the sheet.
* Add a new instance \a aSheetPath to the instance list.
*
* @param[in] aPageNumber is the new page number for the sheet.
* If \a aSheetPath does not already exist, it is added to the list. If already exists
* in the list, do nothing. Sheet instances allow for the sharing in complex hierarchies
* which allows for per instance data such as page number for sheets to stored.
*
* @param[in] aInstance is the #KIID_PATH of the sheet instance to the instance list.
* @return false if the instance already exists, true if the instance was added.
*/
void SetPageNumber( const wxString& aPageNumber );
bool AddInstance( const KIID_PATH& aInstance );
/**
* Return the sheet page number for \a aInstance.
*
* @return the page number for the requested sheet instance.
*/
wxString GetPageNumber( const SCH_SHEET_PATH& aInstance ) const;
/**
* Set the page number for the sheet instance \a aInstance.
*
* @param[in] aInstance is the hierarchical path of the sheet.
* @param[in] aReference is the new page number for the sheet.
*/
void SetPageNumber( const SCH_SHEET_PATH& aInstance, const wxString& aPageNumber );
/**
* Compares page numbers of schematic sheets.
@ -443,7 +461,7 @@ private:
KIGFX::COLOR4D m_borderColor;
KIGFX::COLOR4D m_backgroundColor;
wxString m_pageNumber;
std::vector<SCH_SHEET_INSTANCE> m_instances;
};

View File

@ -159,8 +159,8 @@ int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const
int SCH_SHEET_PATH::ComparePageNumAndName( const SCH_SHEET_PATH& aSheetPathToTest ) const
{
wxString pageA = Last()->GetPageNumber();
wxString pageB = aSheetPathToTest.Last()->GetPageNumber();
wxString pageA = GetPageNumber();
wxString pageB = aSheetPathToTest.GetPageNumber();
int pageNumComp = SCH_SHEET::ComparePageNum( pageA, pageB );
@ -454,6 +454,26 @@ bool SCH_SHEET_PATH::TestForRecursion( const wxString& aSrcFileName, const wxStr
}
wxString SCH_SHEET_PATH::GetPageNumber() const
{
SCH_SHEET* sheet = Last();
wxCHECK( sheet, wxEmptyString );
return sheet->GetPageNumber( *this );
}
void SCH_SHEET_PATH::SetPageNumber( const wxString& aPageNumber )
{
SCH_SHEET* sheet = Last();
wxCHECK( sheet, /* void */ );
sheet->SetPageNumber( *this, aPageNumber );
}
void SCH_SHEET_PATH::MakeFilePathRelativeToParentSheet()
{
wxCHECK( m_sheets.size() > 1, /* void */ );
@ -560,7 +580,7 @@ void SCH_SHEET_LIST::SortByPageNumbers( bool aUpdateVirtualPageNums )
std::sort( begin(), end(),
[]( SCH_SHEET_PATH a, SCH_SHEET_PATH b ) -> bool
{
return a.ComparePageNumAndName( b ) < 0;
return a.ComparePageNumAndName(b) < 0;
} );
if( aUpdateVirtualPageNums )
@ -591,7 +611,7 @@ bool SCH_SHEET_LIST::PageNumberExists( const wxString& aPageNumber ) const
{
for( const SCH_SHEET_PATH& sheet : *this )
{
if( sheet.Last()->GetPageNumber() == aPageNumber )
if( sheet.GetPageNumber() == aPageNumber )
return true;
}
@ -943,7 +963,8 @@ void SCH_SHEET_LIST::UpdateSheetInstances( const std::vector<SCH_SHEET_INSTANCE>
wxCHECK2( sheet, continue );
sheet->SetPageNumber( it->m_PageNumber );
sheet->AddInstance( instance.Path() );
sheet->SetPageNumber( instance, it->m_PageNumber );
}
}
@ -971,7 +992,7 @@ std::vector<SCH_SHEET_INSTANCE> SCH_SHEET_LIST::GetSheetInstances() const
wxCHECK2( sheet, continue );
instance.m_Path = path.PathWithoutRootUuid();
instance.m_PageNumber = sheet->GetPageNumber();
instance.m_PageNumber = sheet->GetPageNumber( path );
retval.push_back( instance );
}
@ -988,7 +1009,7 @@ bool SCH_SHEET_LIST::AllSheetPageNumbersEmpty() const
wxCHECK2( sheet, continue );
if( !sheet->GetPageNumber().IsEmpty() )
if( !sheet->GetPageNumber( instance ).IsEmpty() )
return false;
}
@ -1010,8 +1031,9 @@ void SCH_SHEET_LIST::SetInitialPageNumbers()
wxCHECK2( sheet, continue );
sheet->AddInstance( instance.Path() );
tmp.Printf( "%d", pageNumber );
sheet->SetPageNumber( tmp );
sheet->SetPageNumber( instance, tmp );
pageNumber += 1;
}
}

View File

@ -183,6 +183,15 @@ public:
int GetVirtualPageNumber() const { return m_virtualPageNumber; }
/**
* Set the sheet instance user definable page number.
*
* @note User definable page numbers can be any string devoid of white space characters.
*/
void SetPageNumber( const wxString& aPageNumber );
wxString GetPageNumber() const;
const SCH_SHEET* GetSheet( unsigned aIndex ) const
{
SCH_SHEET* retv = nullptr;

View File

@ -1271,7 +1271,7 @@ bool SCH_GLOBALLABEL::ResolveTextVar( wxString* token, int aDepth ) const
if( !settings.m_IntersheetRefsListOwnPage )
{
wxString currentPage = Schematic()->CurrentSheet().Last()->GetPageNumber();
wxString currentPage = Schematic()->CurrentSheet().GetPageNumber();
alg::delete_matching( pageListCopy, currentPage );
}

View File

@ -126,7 +126,7 @@ bool SCHEMATIC::ResolveTextVar( wxString* token, int aDepth ) const
{
if( token->IsSameAs( wxT( "#" ) ) )
{
*token = CurrentSheet().Last()->GetPageNumber();
*token = CurrentSheet().GetPageNumber();
return true;
}
else if( token->IsSameAs( wxT( "##" ) ) )

View File

@ -1369,7 +1369,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
{
SCH_SHEET_PATH sheetPath = instance;
sheetPath.push_back( sheet );
sheetPath.Last()->SetPageNumber( wxString::Format( "%d", pageNum++ ) );
sheet->AddInstance( sheetPath.Path() );
sheet->SetPageNumber( sheetPath, wxString::Format( "%d", pageNum++ ) );
}
if( m_frame->EditSheetProperties( static_cast<SCH_SHEET*>( sheet ),

View File

@ -1752,7 +1752,7 @@ int SCH_EDIT_TOOL::EditPageNumber( const TOOL_EVENT& aEvent )
wxString msg;
wxString sheetPath = instance.PathHumanReadable( false );
wxString pageNumber = instance.Last()->GetPageNumber();
wxString pageNumber = instance.GetPageNumber();
msg.Printf( _( "Enter page number for sheet path%s" ),
( sheetPath.Length() > 20 ) ? "\n" + sheetPath : " " + sheetPath );
@ -1761,12 +1761,12 @@ int SCH_EDIT_TOOL::EditPageNumber( const TOOL_EVENT& aEvent )
dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space.
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue() == instance.Last()->GetPageNumber() )
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetValue() == instance.GetPageNumber() )
return 0;
m_frame->SaveCopyInUndoList( screen, sheet, UNDO_REDO::CHANGED, false );
instance.Last()->SetPageNumber( dlg.GetValue() );
instance.SetPageNumber( dlg.GetValue() );
if( instance == m_frame->GetCurrentSheet() )
{

View File

@ -481,7 +481,7 @@ int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
{
if( afterSheet )
{
if( afterSheet->Last()->GetPageNumber() == sheet->Last()->GetPageNumber() )
if( afterSheet->GetPageNumber() == sheet->GetPageNumber() )
afterSheet = nullptr;
continue;
@ -1541,6 +1541,8 @@ SCH_SHEET_PATH SCH_EDITOR_CONTROL::updatePastedSheet( const SCH_SHEET_PATH& aPas
SCH_SHEET_PATH sheetPath = aPastePath;
sheetPath.push_back( aSheet );
aSheet->AddInstance( sheetPath.Path() );
wxString pageNum;
if( m_clipboardSheetInstances.count( aClipPath ) > 0 )
@ -1548,7 +1550,7 @@ SCH_SHEET_PATH SCH_EDITOR_CONTROL::updatePastedSheet( const SCH_SHEET_PATH& aPas
else
pageNum = wxString::Format( "%d", static_cast<int>( aPastedSheetsSoFar->size() ) );
sheetPath.Last()->SetPageNumber( pageNum );
aSheet->SetPageNumber( sheetPath, pageNum );
aPastedSheetsSoFar->push_back( sheetPath );
if( aSheet->GetScreen() == nullptr )
@ -1921,7 +1923,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
while( hierarchy.PageNumberExists( pageNum ) )
pageNum = wxString::Format( "%d", ++page );
pastedSheet.Last()->SetPageNumber( pageNum );
pastedSheet.SetPageNumber( pageNum );
hierarchy.push_back( pastedSheet );
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 CERN
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020 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
@ -46,7 +46,7 @@ int SCH_NAVIGATE_TOOL::HypertextCommand( const TOOL_EVENT& aEvent )
{
for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() )
{
if( sheet.Last()->GetPageNumber() == *aPage )
if( sheet.GetPageNumber() == *aPage )
{
m_frame->GetToolManager()->RunAction( ACTIONS::cancelInteractive, true );
m_frame->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
@ -69,7 +69,7 @@ int SCH_NAVIGATE_TOOL::HypertextCommand( const TOOL_EVENT& aEvent )
}
else
{
m_hypertextStack.push( m_frame->GetCurrentSheet().Last()->GetPageNumber() );
m_hypertextStack.push( m_frame->GetCurrentSheet().GetPageNumber() );
goToPage( page );
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020 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 as published by the
@ -126,9 +126,9 @@ BOOST_AUTO_TEST_CASE( TestSheetListPageProperties )
sheets.SetInitialPageNumbers();
// The root sheet should now be page 1.
BOOST_CHECK_EQUAL( sheets.at( 0 ).Last()->GetPageNumber(), "1" );
BOOST_CHECK_EQUAL( sheets.at( 1 ).Last()->GetPageNumber(), "2" );
BOOST_CHECK_EQUAL( sheets.at( 2 ).Last()->GetPageNumber(), "3" );
BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "1" );
BOOST_CHECK_EQUAL( sheets.at( 1 ).GetPageNumber(), "2" );
BOOST_CHECK_EQUAL( sheets.at( 2 ).GetPageNumber(), "3" );
}
@ -142,8 +142,8 @@ BOOST_AUTO_TEST_CASE( TestEditPageNumbersInSharedDesign )
SCH_SHEET_LIST sheets = m_schematic.GetSheets();
BOOST_CHECK_EQUAL( sheets.size(), 2 );
BOOST_CHECK_EQUAL( sheets.at( 0 ).Last()->GetPageNumber(), "i" );
BOOST_CHECK_EQUAL( sheets.at( 1 ).Last()->GetPageNumber(), "ii" );
BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "i" );
BOOST_CHECK_EQUAL( sheets.at( 1 ).GetPageNumber(), "ii" );
}
BOOST_TEST_CONTEXT( "Read Root Sheet, prior to modification" )
@ -154,11 +154,11 @@ BOOST_AUTO_TEST_CASE( TestEditPageNumbersInSharedDesign )
SCH_SHEET_LIST sheets = m_schematic.GetSheets();
BOOST_CHECK_EQUAL( sheets.size(), 5 );
BOOST_CHECK_EQUAL( sheets.at( 0 ).Last()->GetPageNumber(), "1" );
BOOST_CHECK_EQUAL( sheets.at( 1 ).Last()->GetPageNumber(), "2" );
// BOOST_CHECK_EQUAL( sheets.at( 2 ).Last()->GetPageNumber(), "3" );
// BOOST_CHECK_EQUAL( sheets.at( 3 ).Last()->GetPageNumber(), "4" );
BOOST_CHECK_EQUAL( sheets.at( 4 ).Last()->GetPageNumber(), "5" );
BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "1" );
BOOST_CHECK_EQUAL( sheets.at( 1 ).GetPageNumber(), "2" );
BOOST_CHECK_EQUAL( sheets.at( 2 ).GetPageNumber(), "3" );
BOOST_CHECK_EQUAL( sheets.at( 3 ).GetPageNumber(), "4" );
BOOST_CHECK_EQUAL( sheets.at( 4 ).GetPageNumber(), "5" );
}
BOOST_TEST_CONTEXT( "Modify page numbers in root sheet" )
@ -166,11 +166,11 @@ BOOST_AUTO_TEST_CASE( TestEditPageNumbersInSharedDesign )
SCH_SHEET_LIST sheets = m_schematic.GetSheets();
// Amend Page numbers
sheets.at( 0 ).Last()->SetPageNumber( "A" );
sheets.at( 1 ).Last()->SetPageNumber( "B" );
sheets.at( 2 ).Last()->SetPageNumber( "C" );
sheets.at( 3 ).Last()->SetPageNumber( "D" );
sheets.at( 4 ).Last()->SetPageNumber( "E" );
sheets.at( 0 ).SetPageNumber( "A" );
sheets.at( 1 ).SetPageNumber( "B" );
sheets.at( 2 ).SetPageNumber( "C" );
sheets.at( 3 ).SetPageNumber( "D" );
sheets.at( 4 ).SetPageNumber( "E" );
// Save and reload
wxString tempName = "complex_hierarchy_shared/complex_hierarchy_modified";
@ -181,11 +181,11 @@ BOOST_AUTO_TEST_CASE( TestEditPageNumbersInSharedDesign )
sheets = m_schematic.GetSheets();
BOOST_CHECK_EQUAL( sheets.size(), 5 );
BOOST_CHECK_EQUAL( sheets.at( 0 ).Last()->GetPageNumber(), "A" );
BOOST_CHECK_EQUAL( sheets.at( 1 ).Last()->GetPageNumber(), "B" );
BOOST_CHECK_EQUAL( sheets.at( 2 ).Last()->GetPageNumber(), "C" );
// BOOST_CHECK_EQUAL( sheets.at( 3 ).Last()->GetPageNumber(), "D" );
BOOST_CHECK_EQUAL( sheets.at( 4 ).Last()->GetPageNumber(), "E" );
BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "A" );
BOOST_CHECK_EQUAL( sheets.at( 1 ).GetPageNumber(), "B" );
BOOST_CHECK_EQUAL( sheets.at( 2 ).GetPageNumber(), "C" );
BOOST_CHECK_EQUAL( sheets.at( 3 ).GetPageNumber(), "D" );
BOOST_CHECK_EQUAL( sheets.at( 4 ).GetPageNumber(), "E" );
// Cleanup
wxRemoveFile( tempFn.GetFullPath() );
@ -200,8 +200,8 @@ BOOST_AUTO_TEST_CASE( TestEditPageNumbersInSharedDesign )
SCH_SHEET_LIST sheets = m_schematic.GetSheets();
BOOST_CHECK_EQUAL( sheets.size(), 2 );
BOOST_CHECK_EQUAL( sheets.at( 0 ).Last()->GetPageNumber(), "i" );
BOOST_CHECK_EQUAL( sheets.at( 1 ).Last()->GetPageNumber(), "ii" );
BOOST_CHECK_EQUAL( sheets.at( 0 ).GetPageNumber(), "i" );
BOOST_CHECK_EQUAL( sheets.at( 1 ).GetPageNumber(), "ii" );
}
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.TXT for contributors.
* Copyright (C) 2019-2020 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
@ -85,6 +85,9 @@ BOOST_AUTO_TEST_CASE( Empty )
BOOST_CHECK_THROW( m_empty_path.at( 0 ), std::out_of_range );
// Sheet paths with no SCH_SCHEET object are illegal.
CHECK_WX_ASSERT( m_empty_path.GetPageNumber() );
// These accessors return nullptr when empty (i.e. they don't crash)
BOOST_CHECK_EQUAL( m_empty_path.Last(), nullptr );
BOOST_CHECK_EQUAL( m_empty_path.LastScreen(), nullptr );
@ -132,12 +135,14 @@ BOOST_AUTO_TEST_CASE( Compare )
*/
BOOST_AUTO_TEST_CASE( SheetPathPageProperties )
{
BOOST_CHECK_EQUAL( m_linear.Last()->GetPageNumber(), wxEmptyString );
BOOST_CHECK_EQUAL( m_linear.GetPageNumber(), wxEmptyString );
m_linear.Last()->SetPageNumber( "1" );
BOOST_CHECK_EQUAL( m_linear.Last()->GetPageNumber(), "1" );
m_linear.Last()->SetPageNumber( "i" );
BOOST_CHECK_EQUAL( m_linear.Last()->GetPageNumber(), "i" );
// Add new instance to sheet object.
BOOST_CHECK( m_linear.Last()->AddInstance( m_linear.Path() ) );
m_linear.SetPageNumber( "1" );
BOOST_CHECK_EQUAL( m_linear.GetPageNumber(), "1" );
m_linear.SetPageNumber( "i" );
BOOST_CHECK_EQUAL( m_linear.GetPageNumber(), "i" );
}