diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 34f59047e5..d0bae72a91 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -50,7 +50,7 @@ void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly ) } // Update the references for the sheet that is currently being displayed. - m_CurrentSheet->Last()->UpdateAllScreenReferences(); + m_CurrentSheet->UpdateAllScreenReferences(); GetCanvas()->Refresh(); OnModify(); } @@ -176,7 +176,7 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic, OnModify(); // Update on screen references, that can be modified by previous calculations: - m_CurrentSheet->Last()->UpdateAllScreenReferences(); + m_CurrentSheet->UpdateAllScreenReferences(); SetSheetNumberAndCount(); m_canvas->Refresh( true ); diff --git a/eeschema/class_netlist_object.cpp b/eeschema/class_netlist_object.cpp index 1f53224fc9..5d7ca6b41d 100644 --- a/eeschema/class_netlist_object.cpp +++ b/eeschema/class_netlist_object.cpp @@ -357,7 +357,7 @@ wxString NETLIST_OBJECT::GetShortNetName() const if( link ) // Should be always true { netName = wxT("Net-("); - netName << link->GetRef( m_netNameCandidate->m_SheetPath.Last() ); + netName << link->GetRef( &m_netNameCandidate->m_SheetPath ); netName << wxT("-Pad") << LIB_PIN::PinStringNum( m_netNameCandidate->m_PinNum ) << wxT(")"); diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index f927d88cdd..93ce5ab35e 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -7,8 +7,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2011 jean-pierre Charras - * Copyright (C) 1992-2015 Wayne Stambaugh - * Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2011 Wayne Stambaugh + * Copyright (C) 1992-2011 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 @@ -701,7 +701,7 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent m_RootCmp = aComponent; m_Entry = aLibComponent; - m_Unit = aComponent->GetUnitSelection( aSheetPath.Last() ); + m_Unit = aComponent->GetUnitSelection( &aSheetPath ); m_SheetPath = aSheetPath; m_IsNew = false; m_Flag = 0; @@ -709,10 +709,10 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_PART* aLibComponent m_CmpPos = aComponent->GetPosition(); m_SheetNum = 0; - if( aComponent->GetRef( aSheetPath.Last() ).IsEmpty() ) + if( aComponent->GetRef( &aSheetPath ).IsEmpty() ) aComponent->SetRef( aSheetPath.Last(), wxT( "DefRef?" ) ); - SetRef( aComponent->GetRef( aSheetPath.Last() ) ); + SetRef( aComponent->GetRef( &aSheetPath ) ); m_NumRef = -1; diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index aa5d57ae03..792f213999 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -108,7 +108,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC Pin->GetMsgPanelInfo( items ); if( LibItem ) - items.push_back( MSG_PANEL_ITEM( LibItem->GetRef( m_CurrentSheet->Last() ), + items.push_back( MSG_PANEL_ITEM( LibItem->GetRef( m_CurrentSheet ), LibItem->GetField( VALUE )->GetShownText(), DARKCYAN ) ); SetMsgPanel( items ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 25bd214d43..6aaf17a358 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -727,7 +727,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent } #endif - m_FieldsBuf[REFERENCE].SetText( m_cmp->GetRef( m_parent->GetCurrentSheet().Last() ) ); + m_FieldsBuf[REFERENCE].SetText( m_cmp->GetRef( &m_parent->GetCurrentSheet() ) ); for( unsigned i = 0; iLastScreen()->SetZoom( m_parent->GetScreen()->GetZoom() ); m_parent->SetCurrentSheet( *sheet ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); } m_lastMarkerFound = marker; diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index c21b5bb152..09257bda8c 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -327,7 +327,7 @@ bool SCH_PRINTOUT::OnPrintPage( int page ) if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) { m_parent->SetCurrentSheet( list ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); screen = m_parent->GetCurrentSheet().LastScreen(); } @@ -341,7 +341,7 @@ bool SCH_PRINTOUT::OnPrintPage( int page ) DrawPage( screen ); m_parent->SetCurrentSheet( oldsheetpath ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); return true; diff --git a/eeschema/dialogs/dialog_rescue_each.cpp b/eeschema/dialogs/dialog_rescue_each.cpp index fcc7f489fa..ac804ba2ea 100644 --- a/eeschema/dialogs/dialog_rescue_each.cpp +++ b/eeschema/dialogs/dialog_rescue_each.cpp @@ -34,8 +34,6 @@ #include #include #include -#include - class DIALOG_RESCUE_EACH: public DIALOG_RESCUE_EACH_BASE { @@ -158,7 +156,7 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList() SCH_FIELD* valueField = each_component->GetField( 1 ); data.clear(); - data.push_back( each_component->GetRef( m_Parent->GetCurrentSheet().Last() ) ); + data.push_back( each_component->GetRef( & m_Parent->GetCurrentSheet() ) ); data.push_back( valueField ? valueField->GetText() : wxT( "" ) ); m_ListOfInstances->AppendItem( data ); diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index d1e3207eed..f3ed69e78a 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -289,7 +289,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, cmp_ref = wxT( "?" ); if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link ) - cmp_ref = aNetItemRef->GetComponentParent()->GetRef( aNetItemRef->m_SheetPath.Last() ); + cmp_ref = aNetItemRef->GetComponentParent()->GetRef( &aNetItemRef->m_SheetPath ); if( aNetItemTst == NULL ) { @@ -310,7 +310,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, { if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link ) cmp_ref = aNetItemRef->GetComponentParent()->GetRef( - aNetItemRef->m_SheetPath.Last() ); + &aNetItemRef->m_SheetPath ); msg.Printf( _( "Pin %s (%s) of component %s is not driven (Net %d)." ), GetChars( string_pinnum ), @@ -352,7 +352,7 @@ void Diagnose( NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemTst, alt_cmp = wxT( "?" ); if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link ) - alt_cmp = aNetItemTst->GetComponentParent()->GetRef( aNetItemTst->m_SheetPath.Last() ); + alt_cmp = aNetItemTst->GetComponentParent()->GetRef( &aNetItemTst->m_SheetPath ); msg.Printf( _( "Pin %s (%s) of component %s is connected to " ), GetChars( string_pinnum ), @@ -425,9 +425,9 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList, continue; if( ( (SCH_COMPONENT*) aList->GetItem( aNetItemRef )-> - m_Link )->GetRef( aList->GetItem( aNetItemRef )->m_SheetPath.Last() ) != + m_Link )->GetRef( &aList->GetItem( aNetItemRef )-> m_SheetPath ) != ( (SCH_COMPONENT*) aList->GetItem( duplicate )->m_Link ) - ->GetRef( aList->GetItem( duplicate )->m_SheetPath.Last() ) ) + ->GetRef( &aList->GetItem( duplicate )->m_SheetPath ) ) continue; // Same component and same pin. Do dot create error for this pin diff --git a/eeschema/find.cpp b/eeschema/find.cpp index f239ad5727..d3a29e7c81 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -85,7 +85,7 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) { sheetFoundIn->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *sheetFoundIn; - m_CurrentSheet->Last()->UpdateAllScreenReferences(); + m_CurrentSheet->UpdateAllScreenReferences(); } SetCrossHairPosition( lastMarker->GetPosition() ); @@ -139,7 +139,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference, SCH_COMPONENT* pSch = (SCH_COMPONENT*) item; - if( aReference.CmpNoCase( pSch->GetRef( sheet->Last() ) ) == 0 ) + if( aReference.CmpNoCase( pSch->GetRef( sheet ) ) == 0 ) { Component = pSch; sheetWithComponentFound = sheet; @@ -193,7 +193,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference, { sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *sheet; - m_CurrentSheet->Last()->UpdateAllScreenReferences(); + m_CurrentSheet->UpdateAllScreenReferences(); centerAndRedraw = true; } @@ -489,7 +489,7 @@ void SCH_EDIT_FRAME::updateFindReplaceView( wxFindDialogEvent& aEvent ) { sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *sheet; - m_CurrentSheet->Last()->UpdateAllScreenReferences(); + m_CurrentSheet->UpdateAllScreenReferences(); SetScreen( sheet->LastScreen() ); } diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index adbf2332c7..578274b173 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -285,7 +285,7 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet() GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ); // update the References - m_CurrentSheet->Last()->UpdateAllScreenReferences(); + m_CurrentSheet->UpdateAllScreenReferences(); SetSheetNumberAndCount(); m_canvas->SetCanStartBlock( -1 ); diff --git a/eeschema/netlist_exporters/netlist_exporter.cpp b/eeschema/netlist_exporters/netlist_exporter.cpp index 4a7ebf4a32..62e39ccca8 100644 --- a/eeschema/netlist_exporters/netlist_exporter.cpp +++ b/eeschema/netlist_exporters/netlist_exporter.cpp @@ -115,8 +115,7 @@ SCH_COMPONENT* NETLIST_EXPORTER::findNextComponent( EDA_ITEM* aItem, SCH_SHEET_P // Power symbols and other components which have the reference starting // with "#" are not included in netlist (pseudo or virtual components) - ref = comp->GetRef( aSheetPath->Last() ); - + ref = comp->GetRef( aSheetPath ); if( ref[0] == wxChar( '#' ) ) continue; @@ -174,7 +173,7 @@ SCH_COMPONENT* NETLIST_EXPORTER::findNextComponentAndCreatePinList( EDA_ITEM* // Power symbols and other components which have the reference starting // with "#" are not included in netlist (pseudo or virtual components) - ref = comp->GetRef( aSheetPath->Last() ); + ref = comp->GetRef( aSheetPath ); if( ref[0] == wxChar( '#' ) ) continue; @@ -207,7 +206,7 @@ SCH_COMPONENT* NETLIST_EXPORTER::findNextComponentAndCreatePinList( EDA_ITEM* { LIB_PINS pins; // constructed once here - part->GetPins( pins, comp->GetUnitSelection( aSheetPath->Last() ), comp->GetConvert() ); + part->GetPins( pins, comp->GetUnitSelection( aSheetPath ), comp->GetConvert() ); for( size_t i = 0; i < pins.size(); i++ ) { @@ -323,10 +322,10 @@ void NETLIST_EXPORTER::eraseDuplicatePins() void NETLIST_EXPORTER::findAllInstancesOfComponent( SCH_COMPONENT* aComponent, - LIB_PART* aEntry, - SCH_SHEET_PATH* aSheetPath ) + LIB_PART* aEntry, + SCH_SHEET_PATH* aSheetPath ) { - wxString ref = aComponent->GetRef( aSheetPath->Last() ); + wxString ref = aComponent->GetRef( aSheetPath ); wxString ref2; SCH_SHEET_LIST sheetList; @@ -340,11 +339,11 @@ void NETLIST_EXPORTER::findAllInstancesOfComponent( SCH_COMPONENT* aComponent, SCH_COMPONENT* comp2 = (SCH_COMPONENT*) item; - ref2 = comp2->GetRef( sheet->Last() ); + ref2 = comp2->GetRef( sheet ); if( ref2.CmpNoCase( ref ) != 0 ) continue; - int unit2 = comp2->GetUnitSelection( sheet->Last() ); // slow + int unit2 = comp2->GetUnitSelection( sheet ); // slow for( LIB_PIN* pin = aEntry->GetNextPin(); pin; pin = aEntry->GetNextPin( pin ) ) { diff --git a/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp b/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp index 9c94c7d394..2b5b7fbf45 100644 --- a/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp @@ -93,7 +93,7 @@ bool NETLIST_EXPORTER_CADSTAR::WriteNetlist( const wxString& aOutFileName, unsig footprint = wxT( "$noname" ); */ - msg = component->GetRef( sheet->Last() ); + msg = component->GetRef( sheet ); ret |= fprintf( f, "%s ", TO_UTF8( StartCmpDesc ) ); ret |= fprintf( f, "%s", TO_UTF8( msg ) ); @@ -159,8 +159,7 @@ bool NETLIST_EXPORTER_CADSTAR::writeListOfNets( FILE* f ) continue; Cmp = nitem->GetComponentParent(); - wxString refstr = Cmp->GetRef( nitem->m_SheetPath.Last() ); - + wxString refstr = Cmp->GetRef( &nitem->m_SheetPath ); if( refstr[0] == '#' ) continue; // Power supply symbols. diff --git a/eeschema/netlist_exporters/netlist_exporter_generic.cpp b/eeschema/netlist_exporters/netlist_exporter_generic.cpp index df55edcef6..921e0fc1e4 100644 --- a/eeschema/netlist_exporters/netlist_exporter_generic.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_generic.cpp @@ -131,7 +131,7 @@ XNODE* NETLIST_EXPORTER_GENERIC::makeComponents() // an element. xcomps->AddChild( xcomp = node( sComponent ) ); - xcomp->AddAttribute( sRef, comp->GetRef( path->Last() ) ); + xcomp->AddAttribute( sRef, comp->GetRef( path ) ); xcomp->AddChild( node( sValue, comp->GetField( VALUE )->GetText() ) ); @@ -467,8 +467,7 @@ XNODE* NETLIST_EXPORTER_GENERIC::makeListOfNets() comp = nitem->GetComponentParent(); // Get the reference for the net name and the main parent component - ref = comp->GetRef( nitem->m_SheetPath.Last() ); - + ref = comp->GetRef( &nitem->m_SheetPath ); if( ref[0] == wxChar( '#' ) ) continue; @@ -530,8 +529,7 @@ bool NETLIST_EXPORTER_GENERIC::writeListOfNets( FILE* f, NETLIST_OBJECT_LIST& aO comp = nitem->GetComponentParent(); // Get the reference for the net name and the main parent component - ref = comp->GetRef( nitem->m_SheetPath.Last() ); - + ref = comp->GetRef( &nitem->m_SheetPath ); if( ref[0] == wxChar( '#' ) ) continue; // Pseudo component (Like Power symbol) diff --git a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp index b5f481b3ba..b0c8f6a286 100644 --- a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp @@ -99,7 +99,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, uns else footprint = wxT( "$noname" ); - field = comp->GetRef( path->Last() ); + field = comp->GetRef( path ); ret |= fprintf( f, " ( %s %s", TO_UTF8( comp->GetPath( path->Last() ) ), diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index 90746556b0..7158bd4d5e 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -235,7 +235,7 @@ bool NETLIST_EXPORTER_PSPICE::WriteNetlist( const wxString& aOutFileName, unsign } //Get Standard Reference Designator: - wxString RefName = comp->GetRef( sheet->Last() ); + wxString RefName = comp->GetRef( sheet ); //Conditionally add Prefix only for devices that begin with U or IC: if( aUsePrefix ) diff --git a/eeschema/plot_schematic_DXF.cpp b/eeschema/plot_schematic_DXF.cpp index 887aa36886..a571c73baa 100644 --- a/eeschema/plot_schematic_DXF.cpp +++ b/eeschema/plot_schematic_DXF.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -68,7 +67,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ) if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) { schframe->SetCurrentSheet( list ); - schframe->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + schframe->GetCurrentSheet().UpdateAllScreenReferences(); schframe->SetSheetNumberAndCount(); screen = schframe->GetCurrentSheet().LastScreen(); } @@ -106,7 +105,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ) msg.Printf( wxT( "DXF Plotter exception: %s"), GetChars( e.errorText ) ); reporter.Report( msg, REPORTER::RPT_ERROR ); schframe->SetCurrentSheet( oldsheetpath ); - schframe->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + schframe->GetCurrentSheet().UpdateAllScreenReferences(); schframe->SetSheetNumberAndCount(); return; } @@ -117,7 +116,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ) } schframe->SetCurrentSheet( oldsheetpath ); - schframe->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + schframe->GetCurrentSheet().UpdateAllScreenReferences(); schframe->SetSheetNumberAndCount(); } @@ -126,7 +125,7 @@ bool DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen, wxPoint aPlotOffset, double aScale, - bool aPlotFrameRef ) + bool aPlotFrameRef ) { DXF_PLOTTER* plotter = new DXF_PLOTTER(); diff --git a/eeschema/plot_schematic_HPGL.cpp b/eeschema/plot_schematic_HPGL.cpp index a19cd16341..c4479404f9 100644 --- a/eeschema/plot_schematic_HPGL.cpp +++ b/eeschema/plot_schematic_HPGL.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -141,7 +140,7 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef ) if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) { m_parent->SetCurrentSheet( list ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); screen = m_parent->GetCurrentSheet().LastScreen(); @@ -209,7 +208,7 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef ) } m_parent->SetCurrentSheet( oldsheetpath ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); } diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index a72c7d3355..900e1fb625 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -78,7 +77,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) { m_parent->SetCurrentSheet( list ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); screen = m_parent->GetCurrentSheet().LastScreen(); } @@ -155,7 +154,7 @@ void DIALOG_PLOT_SCHEMATIC::restoreEnvironment( PDF_PLOTTER* aPlotter, // Restore the previous sheet m_parent->SetCurrentSheet( aOldsheetpath ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); } diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index fc1dac9d5e..0c42e53b91 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -68,7 +67,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef ) if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) { m_parent->SetCurrentSheet( list ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); screen = m_parent->GetCurrentSheet().LastScreen(); } @@ -142,7 +141,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef ) } m_parent->SetCurrentSheet( oldsheetpath ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); } diff --git a/eeschema/plot_schematic_SVG.cpp b/eeschema/plot_schematic_SVG.cpp index 6213d34e09..0cc81ed854 100644 --- a/eeschema/plot_schematic_SVG.cpp +++ b/eeschema/plot_schematic_SVG.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -68,7 +67,7 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) ) { m_parent->SetCurrentSheet( list ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); screen = m_parent->GetCurrentSheet().LastScreen(); } @@ -110,14 +109,14 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) reporter.Report( msg, REPORTER::RPT_ERROR ); m_parent->SetCurrentSheet( oldsheetpath ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); return; } } m_parent->SetCurrentSheet( oldsheetpath ); - m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences(); + m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); } else // Print current sheet diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index b49daa9922..9077d89249 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -444,9 +444,9 @@ wxString SCH_COMPONENT::GetPath( const SCH_SHEET* aSheet ) const } -const wxString SCH_COMPONENT::GetRef( const SCH_SHEET* aSheet ) +const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet ) { - wxString path = GetPath( aSheet ); + wxString path = GetPath( sheet->Last() ); wxString h_path, h_ref; wxStringTokenizer tokenizer; wxString separators( wxT( " " ) ); @@ -473,7 +473,7 @@ const wxString SCH_COMPONENT::GetRef( const SCH_SHEET* aSheet ) // all have the same component references, but perhaps this is best. if( !GetField( REFERENCE )->GetText().IsEmpty() ) { - SetRef( aSheet, GetField( REFERENCE )->GetText() ); + SetRef( sheet->Last(), GetField( REFERENCE )->GetText() ); return GetField( REFERENCE )->GetText(); } @@ -481,6 +481,12 @@ const wxString SCH_COMPONENT::GetRef( const SCH_SHEET* aSheet ) } +/* Function IsReferenceStringValid (static function) + * Tests for an acceptable reference string + * An acceptable reference string must support unannotation + * i.e starts by letter + * returns true if OK + */ bool SCH_COMPONENT::IsReferenceStringValid( const wxString& aReferenceString ) { wxString text = aReferenceString; @@ -578,9 +584,9 @@ void SCH_COMPONENT::SetTimeStamp( time_t aNewTimeStamp ) } -int SCH_COMPONENT::GetUnitSelection( SCH_SHEET* aSheet ) +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( " " ) ); @@ -1530,7 +1536,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) if( m_currentSheetPath ) aList.push_back( MSG_PANEL_ITEM( _( "Reference" ), - GetRef( m_currentSheetPath->Last() ), + GetRef( m_currentSheetPath ), DARKCYAN ) ); wxString msg = part->IsPower() ? _( "Power symbol" ) : _( "Value" ); @@ -1880,7 +1886,7 @@ void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems, { wxASSERT( pin->Type() == LIB_PIN_T ); - if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath->Last() ) ) ) + if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath ) ) ) continue; if( pin->GetConvert() && ( pin->GetConvert() != GetConvert() ) ) diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 4c780402ba..faa9f46535 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -413,7 +413,7 @@ public: * Function GetRef * returns the reference, for the given sheet path. */ - const wxString GetRef( const SCH_SHEET* sheet ); + const wxString GetRef( const SCH_SHEET_PATH* sheet ); /** * Set the reference, for the given sheet path. @@ -433,7 +433,7 @@ public: int aMulti ); // returns the unit selection, for the given sheet path. - int GetUnitSelection( SCH_SHEET* aSheet ); + int GetUnitSelection( SCH_SHEET_PATH* aSheet ); // Set the unit selection, for the given sheet path. void SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection ); diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 63f5bbd6e6..550d91de9c 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -402,7 +402,7 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint wxCHECK_MSG( component != NULL, false, wxT( "No component associated with field" ) + text ); - text = component->GetRef( ((SCH_SHEET_PATH*) aAuxData)->Last() ); + text = component->GetRef( (SCH_SHEET_PATH*) aAuxData ); if( component->GetUnitCount() > 1 ) text << LIB_PART::SubReference( component->GetUnit() ); @@ -440,7 +440,7 @@ bool SCH_FIELD::Replace( wxFindReplaceData& aSearchData, void* aAuxData ) wxCHECK_MSG( component != NULL, false, wxT( "No component associated with field" ) + text ); - text = component->GetRef( ((SCH_SHEET_PATH*) aAuxData)->Last() ); + text = component->GetRef( (SCH_SHEET_PATH*) aAuxData ); // if( component->GetUnitCount() > 1 ) // text << LIB_PART::SubReference( component->GetUnit() ); diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 1a24d4a24e..95f9d94010 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1116,7 +1116,7 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri component = (SCH_COMPONENT*) item; - if( aReference.CmpNoCase( component->GetRef( aSheetPath->Last() ) ) == 0 ) + if( aReference.CmpNoCase( component->GetRef( aSheetPath ) ) == 0 ) { // Found: Init Footprint Field diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index b593882b82..e60adf26fe 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -1332,24 +1332,6 @@ void SCH_SHEET::AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference ) } -void SCH_SHEET::UpdateAllScreenReferences() -{ - EDA_ITEM* t = m_screen->GetDrawItems(); - - 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(); - } -} - - SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem ) { wxLogDebug( wxT( "Sheet assignment operator." ) ); diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 2787f12f95..30114adb31 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -668,17 +668,6 @@ public: */ void AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference ); - /** - * Function UpdateAllScreenReferences - * updates the reference and the m_Multi parameter (part selection) for all - * components on a screen depending on the actual sheet. - * Mandatory in complex hierarchies because sheets use the same screen - * (basic schematic) - * but with different references and part selections according to the - * displayed sheet - */ - void UpdateAllScreenReferences(); - #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const; // override #endif diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index a731ca4b88..e829924152 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -227,6 +227,24 @@ wxString SCH_SHEET_PATH::PathHumanReadable() const } +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(); + } +} + + void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols ) { // Search to sheet path number: @@ -248,7 +266,7 @@ void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aRefer // Skip pseudo components, which have a reference starting with #. This mainly // affects power symbols. - if( !aIncludePowerSymbols && component->GetRef( Last() )[0] == wxT( '#' ) ) + if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) ) continue; LIB_PART* part = aLibs->FindLibPart( component->GetPartName() ); @@ -283,7 +301,7 @@ void SCH_SHEET_PATH::GetMultiUnitComponents( PART_LIBS* aLibs, SCH_MULTI_UNIT_RE // Skip pseudo components, which have a reference starting with #. This mainly // affects power symbols. - if( !aIncludePowerSymbols && component->GetRef( Last() )[0] == wxT( '#' ) ) + if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) ) continue; LIB_PART* part = aLibs->FindLibPart( component->GetPartName() ); diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index e535b307aa..0c542086b3 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -215,6 +215,17 @@ public: */ bool BuildSheetPathInfoFromSheetPathValue( const wxString& aPath, bool aFound = false ); + /** + * Function UpdateAllScreenReferences + * updates the reference and the m_Multi parameter (part selection) for all + * components on a screen depending on the actual sheet path. + * Mandatory in complex hierarchies because sheets use the same screen + * (basic schematic) + * but with different references and part selections according to the + * displayed sheet + */ + void UpdateAllScreenReferences(); + /** * Function GetComponents * adds a SCH_REFERENCE() object to \a aReferences for each component in the sheet.