Browse Source

Eeschema: move update all screen references from SCH_SHEET_PATH to SCH_SHEET.

* Uncouple SCH_COMPONENT::GetRef() from  SCH_SHEET_PATH and use SCH_SHEET
  instead.
* Uncouple SCH_COMPONENT::GetUnitSelection() from  SCH_SHEET_PATH and use
  SCH_SHEET instead.
* Fix all calls to GetRef() and GetUnitSelection() to pass a pointer to the
  appropriate SCH_SHEET object instead of an SCH_SHEET_PATH object.
pull/10/head
Wayne Stambaugh 10 years ago
parent
commit
e8e0a75b8c
  1. 4
      eeschema/annotate.cpp
  2. 2
      eeschema/class_netlist_object.cpp
  3. 10
      eeschema/component_references_lister.cpp
  4. 2
      eeschema/controle.cpp
  5. 2
      eeschema/dialogs/dialog_edit_component_in_schematic.cpp
  6. 2
      eeschema/dialogs/dialog_erc.cpp
  7. 4
      eeschema/dialogs/dialog_print_using_printer.cpp
  8. 4
      eeschema/dialogs/dialog_rescue_each.cpp
  9. 10
      eeschema/erc.cpp
  10. 8
      eeschema/find.cpp
  11. 2
      eeschema/hierarch.cpp
  12. 17
      eeschema/netlist_exporters/netlist_exporter.cpp
  13. 5
      eeschema/netlist_exporters/netlist_exporter_cadstar.cpp
  14. 8
      eeschema/netlist_exporters/netlist_exporter_generic.cpp
  15. 2
      eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp
  16. 2
      eeschema/netlist_exporters/netlist_exporter_pspice.cpp
  17. 9
      eeschema/plot_schematic_DXF.cpp
  18. 5
      eeschema/plot_schematic_HPGL.cpp
  19. 5
      eeschema/plot_schematic_PDF.cpp
  20. 5
      eeschema/plot_schematic_PS.cpp
  21. 7
      eeschema/plot_schematic_SVG.cpp
  22. 20
      eeschema/sch_component.cpp
  23. 4
      eeschema/sch_component.h
  24. 4
      eeschema/sch_field.cpp
  25. 2
      eeschema/sch_screen.cpp
  26. 18
      eeschema/sch_sheet.cpp
  27. 11
      eeschema/sch_sheet.h
  28. 22
      eeschema/sch_sheet_path.cpp
  29. 11
      eeschema/sch_sheet_path.h

4
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->UpdateAllScreenReferences();
m_CurrentSheet->Last()->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->UpdateAllScreenReferences();
m_CurrentSheet->Last()->UpdateAllScreenReferences();
SetSheetNumberAndCount();
m_canvas->Refresh( true );

2
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 );
netName << link->GetRef( m_netNameCandidate->m_SheetPath.Last() );
netName << wxT("-Pad")
<< LIB_PIN::PinStringNum( m_netNameCandidate->m_PinNum )
<< wxT(")");

10
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 <jean-pierre.charras@gipsa-lab.inpg.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-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-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
@ -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 );
m_Unit = aComponent->GetUnitSelection( aSheetPath.Last() );
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 ).IsEmpty() )
if( aComponent->GetRef( aSheetPath.Last() ).IsEmpty() )
aComponent->SetRef( aSheetPath.Last(), wxT( "DefRef?" ) );
SetRef( aComponent->GetRef( &aSheetPath ) );
SetRef( aComponent->GetRef( aSheetPath.Last() ) );
m_NumRef = -1;

2
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 ),
items.push_back( MSG_PANEL_ITEM( LibItem->GetRef( m_CurrentSheet->Last() ),
LibItem->GetField( VALUE )->GetShownText(), DARKCYAN ) );
SetMsgPanel( items );

2
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() ) );
m_FieldsBuf[REFERENCE].SetText( m_cmp->GetRef( m_parent->GetCurrentSheet().Last() ) );
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
{

2
eeschema/dialogs/dialog_erc.cpp

@ -235,7 +235,7 @@ void DIALOG_ERC::OnLeftClickMarkersList( wxHtmlLinkEvent& event )
{
sheet->LastScreen()->SetZoom( m_parent->GetScreen()->GetZoom() );
m_parent->SetCurrentSheet( *sheet );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
}
m_lastMarkerFound = marker;

4
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().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->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().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
return true;

4
eeschema/dialogs/dialog_rescue_each.cpp

@ -34,6 +34,8 @@
#include <boost/foreach.hpp>
#include <project_rescue.h>
#include <eeschema_config.h>
#include <sch_sheet_path.h>
class DIALOG_RESCUE_EACH: public DIALOG_RESCUE_EACH_BASE
{
@ -156,7 +158,7 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList()
SCH_FIELD* valueField = each_component->GetField( 1 );
data.clear();
data.push_back( each_component->GetRef( & m_Parent->GetCurrentSheet() ) );
data.push_back( each_component->GetRef( m_Parent->GetCurrentSheet().Last() ) );
data.push_back( valueField ? valueField->GetText() : wxT( "" ) );
m_ListOfInstances->AppendItem( data );

10
eeschema/erc.cpp

@ -290,7 +290,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 );
cmp_ref = aNetItemRef->GetComponentParent()->GetRef( aNetItemRef->m_SheetPath.Last() );
if( aNetItemTst == NULL )
{
@ -311,7 +311,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 );
aNetItemRef->m_SheetPath.Last() );
msg.Printf( _( "Pin %s (%s) of component %s is not driven (Net %d)." ),
GetChars( string_pinnum ),
@ -353,7 +353,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 );
alt_cmp = aNetItemTst->GetComponentParent()->GetRef( aNetItemTst->m_SheetPath.Last() );
msg.Printf( _( "Pin %s (%s) of component %s is connected to " ),
GetChars( string_pinnum ),
@ -426,9 +426,9 @@ void TestOthersItems( NETLIST_OBJECT_LIST* aList,
continue;
if( ( (SCH_COMPONENT*) aList->GetItem( aNetItemRef )->
m_Link )->GetRef( &aList->GetItem( aNetItemRef )-> m_SheetPath ) !=
m_Link )->GetRef( aList->GetItem( aNetItemRef )->m_SheetPath.Last() ) !=
( (SCH_COMPONENT*) aList->GetItem( duplicate )->m_Link )
->GetRef( &aList->GetItem( duplicate )->m_SheetPath ) )
->GetRef( aList->GetItem( duplicate )->m_SheetPath.Last() ) )
continue;
// Same component and same pin. Do dot create error for this pin

8
eeschema/find.cpp

@ -85,7 +85,7 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
{
sheetFoundIn->LastScreen()->SetZoom( GetScreen()->GetZoom() );
*m_CurrentSheet = *sheetFoundIn;
m_CurrentSheet->UpdateAllScreenReferences();
m_CurrentSheet->Last()->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 ) ) == 0 )
if( aReference.CmpNoCase( pSch->GetRef( sheet->Last() ) ) == 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->UpdateAllScreenReferences();
m_CurrentSheet->Last()->UpdateAllScreenReferences();
centerAndRedraw = true;
}
@ -489,7 +489,7 @@ void SCH_EDIT_FRAME::updateFindReplaceView( wxFindDialogEvent& aEvent )
{
sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() );
*m_CurrentSheet = *sheet;
m_CurrentSheet->UpdateAllScreenReferences();
m_CurrentSheet->Last()->UpdateAllScreenReferences();
SetScreen( sheet->LastScreen() );
}

2
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->UpdateAllScreenReferences();
m_CurrentSheet->Last()->UpdateAllScreenReferences();
SetSheetNumberAndCount();
m_canvas->SetCanStartBlock( -1 );

17
eeschema/netlist_exporters/netlist_exporter.cpp

@ -115,7 +115,8 @@ 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 );
ref = comp->GetRef( aSheetPath->Last() );
if( ref[0] == wxChar( '#' ) )
continue;
@ -173,7 +174,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 );
ref = comp->GetRef( aSheetPath->Last() );
if( ref[0] == wxChar( '#' ) )
continue;
@ -206,7 +207,7 @@ SCH_COMPONENT* NETLIST_EXPORTER::findNextComponentAndCreatePinList( EDA_ITEM*
{
LIB_PINS pins; // constructed once here
part->GetPins( pins, comp->GetUnitSelection( aSheetPath ), comp->GetConvert() );
part->GetPins( pins, comp->GetUnitSelection( aSheetPath->Last() ), comp->GetConvert() );
for( size_t i = 0; i < pins.size(); i++ )
{
@ -322,10 +323,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 );
wxString ref = aComponent->GetRef( aSheetPath->Last() );
wxString ref2;
SCH_SHEET_LIST sheetList;
@ -339,11 +340,11 @@ void NETLIST_EXPORTER::findAllInstancesOfComponent( SCH_COMPONENT* aComponent,
SCH_COMPONENT* comp2 = (SCH_COMPONENT*) item;
ref2 = comp2->GetRef( sheet );
ref2 = comp2->GetRef( sheet->Last() );
if( ref2.CmpNoCase( ref ) != 0 )
continue;
int unit2 = comp2->GetUnitSelection( sheet ); // slow
int unit2 = comp2->GetUnitSelection( sheet->Last() ); // slow
for( LIB_PIN* pin = aEntry->GetNextPin(); pin; pin = aEntry->GetNextPin( pin ) )
{

5
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 );
msg = component->GetRef( sheet->Last() );
ret |= fprintf( f, "%s ", TO_UTF8( StartCmpDesc ) );
ret |= fprintf( f, "%s", TO_UTF8( msg ) );
@ -159,7 +159,8 @@ bool NETLIST_EXPORTER_CADSTAR::writeListOfNets( FILE* f )
continue;
Cmp = nitem->GetComponentParent();
wxString refstr = Cmp->GetRef( &nitem->m_SheetPath );
wxString refstr = Cmp->GetRef( nitem->m_SheetPath.Last() );
if( refstr[0] == '#' )
continue; // Power supply symbols.

8
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 ) );
xcomp->AddAttribute( sRef, comp->GetRef( path->Last() ) );
xcomp->AddChild( node( sValue, comp->GetField( VALUE )->GetText() ) );
@ -467,7 +467,8 @@ 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 );
ref = comp->GetRef( nitem->m_SheetPath.Last() );
if( ref[0] == wxChar( '#' ) )
continue;
@ -529,7 +530,8 @@ 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 );
ref = comp->GetRef( nitem->m_SheetPath.Last() );
if( ref[0] == wxChar( '#' ) )
continue; // Pseudo component (Like Power symbol)

2
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 );
field = comp->GetRef( path->Last() );
ret |= fprintf( f, " ( %s %s",
TO_UTF8( comp->GetPath( path->Last() ) ),

2
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 );
wxString RefName = comp->GetRef( sheet->Last() );
//Conditionally add Prefix only for devices that begin with U or IC:
if( aUsePrefix )

9
eeschema/plot_schematic_DXF.cpp

@ -30,6 +30,7 @@
#include <class_sch_screen.h>
#include <schframe.h>
#include <sch_sheet_path.h>
#include <sch_sheet.h>
#include <project.h>
#include <dialog_plot_schematic.h>
@ -67,7 +68,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef )
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{
schframe->SetCurrentSheet( list );
schframe->GetCurrentSheet().UpdateAllScreenReferences();
schframe->GetCurrentSheet().Last()->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount();
screen = schframe->GetCurrentSheet().LastScreen();
}
@ -105,7 +106,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().UpdateAllScreenReferences();
schframe->GetCurrentSheet().Last()->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount();
return;
}
@ -116,7 +117,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef )
}
schframe->SetCurrentSheet( oldsheetpath );
schframe->GetCurrentSheet().UpdateAllScreenReferences();
schframe->GetCurrentSheet().Last()->UpdateAllScreenReferences();
schframe->SetSheetNumberAndCount();
}
@ -125,7 +126,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();

5
eeschema/plot_schematic_HPGL.cpp

@ -30,6 +30,7 @@
#include <class_sch_screen.h>
#include <schframe.h>
#include <base_units.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <project.h>
@ -140,7 +141,7 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef )
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{
m_parent->SetCurrentSheet( list );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
screen = m_parent->GetCurrentSheet().LastScreen();
@ -208,7 +209,7 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef )
}
m_parent->SetCurrentSheet( oldsheetpath );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
}

5
eeschema/plot_schematic_PDF.cpp

@ -28,6 +28,7 @@
#include <fctsys.h>
#include <plot_common.h>
#include <class_sch_screen.h>
#include <sch_sheet.h>
#include <schframe.h>
#include <base_units.h>
#include <sch_sheet_path.h>
@ -77,7 +78,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef )
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{
m_parent->SetCurrentSheet( list );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
screen = m_parent->GetCurrentSheet().LastScreen();
}
@ -154,7 +155,7 @@ void DIALOG_PLOT_SCHEMATIC::restoreEnvironment( PDF_PLOTTER* aPlotter,
// Restore the previous sheet
m_parent->SetCurrentSheet( aOldsheetpath );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
}

5
eeschema/plot_schematic_PS.cpp

@ -29,6 +29,7 @@
#include <class_sch_screen.h>
#include <schframe.h>
#include <base_units.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <project.h>
#include <reporter.h>
@ -67,7 +68,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef )
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{
m_parent->SetCurrentSheet( list );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
screen = m_parent->GetCurrentSheet().LastScreen();
}
@ -141,7 +142,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef )
}
m_parent->SetCurrentSheet( oldsheetpath );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
}

7
eeschema/plot_schematic_SVG.cpp

@ -34,6 +34,7 @@
#include <schframe.h>
#include <base_units.h>
#include <libeditframe.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <project.h>
#include <reporter.h>
@ -67,7 +68,7 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef )
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
{
m_parent->SetCurrentSheet( list );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
screen = m_parent->GetCurrentSheet().LastScreen();
}
@ -109,14 +110,14 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef )
reporter.Report( msg, REPORTER::RPT_ERROR );
m_parent->SetCurrentSheet( oldsheetpath );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
return;
}
}
m_parent->SetCurrentSheet( oldsheetpath );
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->GetCurrentSheet().Last()->UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount();
}
else // Print current sheet

20
eeschema/sch_component.cpp

@ -442,9 +442,9 @@ wxString SCH_COMPONENT::GetPath( const SCH_SHEET* aSheet ) const
}
const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet )
const wxString SCH_COMPONENT::GetRef( const SCH_SHEET* aSheet )
{
wxString path = GetPath( sheet->Last() );
wxString path = GetPath( aSheet );
wxString h_path, h_ref;
wxStringTokenizer tokenizer;
wxString separators( wxT( " " ) );
@ -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->Last(), GetField( REFERENCE )->GetText() );
SetRef( aSheet, GetField( REFERENCE )->GetText() );
return GetField( REFERENCE )->GetText();
}
@ -479,12 +479,6 @@ const wxString SCH_COMPONENT::GetRef( const SCH_SHEET_PATH* sheet )
}
/* 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;
@ -582,9 +576,9 @@ void SCH_COMPONENT::SetTimeStamp( time_t aNewTimeStamp )
}
int SCH_COMPONENT::GetUnitSelection( SCH_SHEET_PATH* aSheet )
int SCH_COMPONENT::GetUnitSelection( SCH_SHEET* aSheet )
{
wxString path = GetPath( aSheet->Last() );
wxString path = GetPath( aSheet );
wxString h_path, h_multi;
wxStringTokenizer tokenizer;
wxString separators( wxT( " " ) );
@ -1534,7 +1528,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList )
if( m_currentSheetPath )
aList.push_back( MSG_PANEL_ITEM( _( "Reference" ),
GetRef( m_currentSheetPath ),
GetRef( m_currentSheetPath->Last() ),
DARKCYAN ) );
wxString msg = part->IsPower() ? _( "Power symbol" ) : _( "Value" );
@ -1884,7 +1878,7 @@ void SCH_COMPONENT::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
{
wxASSERT( pin->Type() == LIB_PIN_T );
if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath ) ) )
if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath->Last() ) ) )
continue;
if( pin->GetConvert() && ( pin->GetConvert() != GetConvert() ) )

4
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_PATH* sheet );
const wxString GetRef( const SCH_SHEET* 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_PATH* aSheet );
int GetUnitSelection( SCH_SHEET* aSheet );
// Set the unit selection, for the given sheet path.
void SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection );

4
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 );
text = component->GetRef( ((SCH_SHEET_PATH*) aAuxData)->Last() );
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 );
text = component->GetRef( ((SCH_SHEET_PATH*) aAuxData)->Last() );
// if( component->GetUnitCount() > 1 )
// text << LIB_PART::SubReference( component->GetUnit() );

2
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 ) ) == 0 )
if( aReference.CmpNoCase( component->GetRef( aSheetPath->Last() ) ) == 0 )
{
// Found: Init Footprint Field

18
eeschema/sch_sheet.cpp

@ -1332,6 +1332,24 @@ 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." ) );

11
eeschema/sch_sheet.h

@ -668,6 +668,17 @@ 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

22
eeschema/sch_sheet_path.cpp

@ -227,24 +227,6 @@ 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:
@ -266,7 +248,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( this )[0] == wxT( '#' ) )
if( !aIncludePowerSymbols && component->GetRef( Last() )[0] == wxT( '#' ) )
continue;
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );
@ -301,7 +283,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( this )[0] == wxT( '#' ) )
if( !aIncludePowerSymbols && component->GetRef( Last() )[0] == wxT( '#' ) )
continue;
LIB_PART* part = aLibs->FindLibPart( component->GetPartName() );

11
eeschema/sch_sheet_path.h

@ -215,17 +215,6 @@ 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.

Loading…
Cancel
Save