Enforce SCH_SHEET_PATH processing in (yet) more places.
Also fixes a bug where ERC testing for text variables in sheet pins would start with the wrong sheet. Also fixes a bug where ERC testing of similar labels would use the wrong sheet. Also fixes a bug where ERC testing of bus-to-net conflicts would use the wrong sheet. Also fixes a bug where ERC didn't process variable references when checking hierarchical labels against sheet pins. Also fixes a bug where ERC multiple-drivers and netclass-conflicts tests didn't set a sheetpath.
This commit is contained in:
parent
05e954ad5d
commit
03953e80fc
|
@ -332,31 +332,39 @@ wxString CONNECTION_SUBGRAPH::driverName( SCH_ITEM* aItem ) const
|
|||
{
|
||||
case SCH_PIN_T:
|
||||
{
|
||||
bool forceNoConnect = m_no_connect != nullptr;
|
||||
SCH_PIN* pin = static_cast<SCH_PIN*>( aItem );
|
||||
bool forceNoConnect = m_no_connect != nullptr;
|
||||
|
||||
return pin->GetDefaultNetName( m_sheet, forceNoConnect );
|
||||
break;
|
||||
}
|
||||
|
||||
case SCH_LABEL_T:
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
case SCH_HIER_LABEL_T:
|
||||
{
|
||||
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
|
||||
|
||||
// NB: any changes here will need corresponding changes in SCH_LABEL_BASE::cacheShownText()
|
||||
return EscapeString( static_cast<SCH_TEXT*>( aItem )->GetShownText( &m_sheet, false ),
|
||||
CTX_NETNAME );
|
||||
return EscapeString( label->GetShownText( &m_sheet, false ), CTX_NETNAME );
|
||||
}
|
||||
|
||||
case SCH_SHEET_PIN_T:
|
||||
// Sheet pins need to use their parent sheet as their starting sheet or they will
|
||||
// resolve variables on the current sheet first
|
||||
return EscapeString( static_cast<SCH_TEXT*>( aItem )->GetShownText( nullptr, false ),
|
||||
CTX_NETNAME );
|
||||
{
|
||||
// Sheet pins need to use their parent sheet as their starting sheet or they will resolve
|
||||
// variables on the current sheet first
|
||||
SCH_SHEET_PIN* sheetPin = static_cast<SCH_SHEET_PIN*>( aItem );
|
||||
SCH_SHEET_PATH path = m_sheet;
|
||||
|
||||
if( path.Last() != sheetPin->GetParent() )
|
||||
path.push_back( sheetPin->GetParent() );
|
||||
|
||||
return EscapeString( sheetPin->GetShownText( &path, false ), CTX_NETNAME );
|
||||
}
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( wxS( "Unhandled item type in GetNameForDriver" ) );
|
||||
break;
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2688,7 +2696,8 @@ std::vector<const CONNECTION_SUBGRAPH*> CONNECTION_GRAPH::GetBusesNeedingMigrati
|
|||
if( !subgraph->m_driver )
|
||||
continue;
|
||||
|
||||
SCH_CONNECTION* connection = subgraph->m_driver->Connection( &subgraph->m_sheet );
|
||||
SCH_SHEET_PATH* sheet = &subgraph->m_sheet;
|
||||
SCH_CONNECTION* connection = subgraph->m_driver->Connection( sheet );
|
||||
|
||||
if( !connection->IsBus() )
|
||||
continue;
|
||||
|
@ -2698,11 +2707,11 @@ std::vector<const CONNECTION_SUBGRAPH*> CONNECTION_GRAPH::GetBusesNeedingMigrati
|
|||
if( labels.size() > 1 )
|
||||
{
|
||||
bool different = false;
|
||||
wxString first = static_cast<SCH_TEXT*>( labels.at( 0 ) )->GetShownText( false );
|
||||
wxString first = static_cast<SCH_TEXT*>( labels.at( 0 ) )->GetShownText( sheet, false );
|
||||
|
||||
for( unsigned i = 1; i < labels.size(); ++i )
|
||||
{
|
||||
if( static_cast<SCH_TEXT*>( labels.at( i ) )->GetShownText( false ) != first )
|
||||
if( static_cast<SCH_TEXT*>( labels.at( i ) )->GetShownText( sheet, false ) != first )
|
||||
{
|
||||
different = true;
|
||||
break;
|
||||
|
@ -2945,6 +2954,8 @@ bool CONNECTION_GRAPH::ercCheckMultipleDrivers( const CONNECTION_SUBGRAPH* aSubg
|
|||
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DRIVER_CONFLICT );
|
||||
ercItem->SetItems( aSubgraph->m_driver, driver );
|
||||
ercItem->SetSheetSpecificPath( aSubgraph->GetSheet() );
|
||||
ercItem->SetItemsSheetPaths( aSubgraph->GetSheet(), aSubgraph->m_sheet );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, driver->GetPosition() );
|
||||
|
@ -2961,8 +2972,9 @@ bool CONNECTION_GRAPH::ercCheckMultipleDrivers( const CONNECTION_SUBGRAPH* aSubg
|
|||
|
||||
bool CONNECTION_GRAPH::ercCheckNetclassConflicts( const std::vector<CONNECTION_SUBGRAPH*>& subgraphs )
|
||||
{
|
||||
wxString firstNetclass;
|
||||
SCH_ITEM* firstNetclassDriver = nullptr;
|
||||
wxString firstNetclass;
|
||||
SCH_ITEM* firstNetclassDriver = nullptr;
|
||||
const SCH_SHEET_PATH* firstNetclassDriverSheet = nullptr;
|
||||
|
||||
for( const CONNECTION_SUBGRAPH* subgraph : subgraphs )
|
||||
{
|
||||
|
@ -2979,11 +2991,14 @@ bool CONNECTION_GRAPH::ercCheckNetclassConflicts( const std::vector<CONNECTION_S
|
|||
{
|
||||
firstNetclass = netclass;
|
||||
firstNetclassDriver = item;
|
||||
firstNetclassDriverSheet = &subgraph->GetSheet();
|
||||
continue;
|
||||
}
|
||||
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_NETCLASS_CONFLICT );
|
||||
ercItem->SetItems( firstNetclassDriver, item );
|
||||
ercItem->SetSheetSpecificPath( subgraph->GetSheet() );
|
||||
ercItem->SetItemsSheetPaths( *firstNetclassDriverSheet, subgraph->GetSheet() );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, item->GetPosition() );
|
||||
subgraph->m_sheet.LastScreen()->Append( marker );
|
||||
|
@ -3016,6 +3031,7 @@ bool CONNECTION_GRAPH::ercCheckBusToNetConflicts( const CONNECTION_SUBGRAPH* aSu
|
|||
bus_item = ( !bus_item ) ? item : bus_item;
|
||||
else
|
||||
net_item = ( !net_item ) ? item : net_item;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3025,12 +3041,14 @@ bool CONNECTION_GRAPH::ercCheckBusToNetConflicts( const CONNECTION_SUBGRAPH* aSu
|
|||
case SCH_HIER_LABEL_T:
|
||||
{
|
||||
SCH_TEXT* text = static_cast<SCH_TEXT*>( item );
|
||||
conn.ConfigureFromLabel( EscapeString( text->GetShownText( false ), CTX_NETNAME ) );
|
||||
conn.ConfigureFromLabel( EscapeString( text->GetShownText( &sheet, false ),
|
||||
CTX_NETNAME ) );
|
||||
|
||||
if( conn.IsBus() )
|
||||
bus_item = ( !bus_item ) ? item : bus_item;
|
||||
else
|
||||
net_item = ( !net_item ) ? item : net_item;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3614,15 +3632,15 @@ bool CONNECTION_GRAPH::ercCheckLabels( const CONNECTION_SUBGRAPH* aSubgraph )
|
|||
|
||||
if( allPins == 1 && !has_nc )
|
||||
{
|
||||
reportError( text,
|
||||
type == SCH_GLOBAL_LABEL_T ? ERCE_GLOBLABEL : ERCE_LABEL_NOT_CONNECTED );
|
||||
reportError( text, type == SCH_GLOBAL_LABEL_T ? ERCE_GLOBLABEL
|
||||
: ERCE_LABEL_NOT_CONNECTED );
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if( allPins == 0 )
|
||||
{
|
||||
reportError( text,
|
||||
type == SCH_GLOBAL_LABEL_T ? ERCE_GLOBLABEL : ERCE_LABEL_NOT_CONNECTED );
|
||||
reportError( text, type == SCH_GLOBAL_LABEL_T ? ERCE_GLOBLABEL
|
||||
: ERCE_LABEL_NOT_CONNECTED );
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
@ -3640,12 +3658,12 @@ int CONNECTION_GRAPH::ercCheckHierSheets()
|
|||
|
||||
for( const SCH_SHEET_PATH& sheet : m_sheetList )
|
||||
{
|
||||
for( SCH_ITEM* item : sheet.LastScreen()->Items() )
|
||||
for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SHEET_T ) )
|
||||
{
|
||||
if( item->Type() != SCH_SHEET_T )
|
||||
continue;
|
||||
|
||||
SCH_SHEET* parentSheet = static_cast<SCH_SHEET*>( item );
|
||||
SCH_SHEET_PATH parentSheetPath = sheet;
|
||||
|
||||
parentSheetPath.push_back( parentSheet );
|
||||
|
||||
std::map<wxString, SCH_SHEET_PIN*> pins;
|
||||
std::map<wxString, SCH_HIERLABEL*> labels;
|
||||
|
@ -3653,7 +3671,7 @@ int CONNECTION_GRAPH::ercCheckHierSheets()
|
|||
for( SCH_SHEET_PIN* pin : parentSheet->GetPins() )
|
||||
{
|
||||
if( settings.IsTestEnabled( ERCE_HIERACHICAL_LABEL ) )
|
||||
pins[pin->GetText()] = pin;
|
||||
pins[ pin->GetShownText( &parentSheetPath, false ) ] = pin;
|
||||
|
||||
if( pin->IsDangling() && settings.IsTestEnabled( ERCE_PIN_NOT_CONNECTED ) )
|
||||
{
|
||||
|
@ -3676,11 +3694,12 @@ int CONNECTION_GRAPH::ercCheckHierSheets()
|
|||
if( subItem->Type() == SCH_HIER_LABEL_T )
|
||||
{
|
||||
SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( subItem );
|
||||
wxString labelText = label->GetShownText( &parentSheetPath, false );
|
||||
|
||||
if( !pins.count( label->GetText() ) )
|
||||
labels[label->GetText()] = label;
|
||||
if( !pins.count( labelText ) )
|
||||
labels[ labelText ] = label;
|
||||
else
|
||||
matchedPins.insert( label->GetText() );
|
||||
matchedPins.insert( labelText );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3711,9 +3730,6 @@ int CONNECTION_GRAPH::ercCheckHierSheets()
|
|||
"sheet pin in the parent sheet" ),
|
||||
UnescapeString( unmatched.first ) );
|
||||
|
||||
SCH_SHEET_PATH parentSheetPath = sheet;
|
||||
parentSheetPath.push_back( parentSheet );
|
||||
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_HIERACHICAL_LABEL );
|
||||
ercItem->SetItems( unmatched.second );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
|
|
|
@ -421,7 +421,8 @@ wxString DIALOG_PLOT_SCHEMATIC::getOutputPath()
|
|||
std::function<bool( wxString* )> textResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
return m_parent->Schematic().ResolveTextVar( token, 0 );
|
||||
SCHEMATIC& schematic = m_parent->Schematic();
|
||||
return schematic.ResolveTextVar( &schematic.CurrentSheet(), token, 0 );
|
||||
};
|
||||
|
||||
wxString path = m_outputDirectoryName->GetValue();
|
||||
|
|
|
@ -1225,11 +1225,14 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnExport( wxCommandEvent& aEvent )
|
|||
// Create output directory if it does not exist (also transform it in absolute form).
|
||||
// Bail if it fails.
|
||||
|
||||
std::function<bool( wxString* )> textResolver = [&]( wxString* token ) -> bool
|
||||
{
|
||||
// Handles m_board->GetTitleBlock() *and* m_board->GetProject()
|
||||
return m_parent->Schematic().ResolveTextVar( token, 0 );
|
||||
};
|
||||
std::function<bool( wxString* )> textResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
SCHEMATIC& schematic = m_parent->Schematic();
|
||||
|
||||
// Handles m_board->GetTitleBlock() *and* m_board->GetProject()
|
||||
return schematic.ResolveTextVar( &schematic.CurrentSheet(), token, 0 );
|
||||
};
|
||||
|
||||
wxString path = m_outputFileName->GetValue();
|
||||
|
||||
|
|
|
@ -196,12 +196,8 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
|||
wsItems.BuildDrawItemsList( aDrawingSheet->GetPageInfo(), aDrawingSheet->GetTitleBlock() );
|
||||
}
|
||||
|
||||
SCH_SHEET_PATH savedCurrentSheet = m_schematic->CurrentSheet();
|
||||
SCH_SHEET_LIST sheets = m_schematic->GetSheets();
|
||||
|
||||
for( SCH_SHEET_PATH& sheet : sheets )
|
||||
for( SCH_SHEET_PATH& sheet : m_schematic->GetSheets() )
|
||||
{
|
||||
m_schematic->SetCurrentSheet( sheet );
|
||||
SCH_SCREEN* screen = sheet.LastScreen();
|
||||
|
||||
for( SCH_ITEM* item : screen->Items().OfType( SCH_LOCATE_ANY_T ) )
|
||||
|
@ -212,10 +208,9 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
|||
|
||||
for( SCH_FIELD& field : symbol->GetFields() )
|
||||
{
|
||||
if( unresolved( field.GetShownText( true ) ) )
|
||||
if( unresolved( field.GetShownText( &sheet, true ) ) )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem =
|
||||
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( &field );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, field.GetPosition() );
|
||||
|
@ -229,10 +224,9 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
|||
|
||||
for( SCH_FIELD& field : subSheet->GetFields() )
|
||||
{
|
||||
if( unresolved( field.GetShownText( true ) ) )
|
||||
if( unresolved( field.GetShownText( &sheet, true ) ) )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem =
|
||||
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( &field );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, field.GetPosition() );
|
||||
|
@ -240,12 +234,14 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
|||
}
|
||||
}
|
||||
|
||||
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
|
||||
SCH_SHEET_PATH subSheetPath = sheet;
|
||||
subSheetPath.push_back( subSheet );
|
||||
|
||||
for( SCH_SHEET_PIN* pin : subSheet->GetPins() )
|
||||
{
|
||||
if( pin->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
|
||||
if( pin->GetShownText( &subSheetPath, true ).Matches( wxS( "*${*}*" ) ) )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem =
|
||||
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( pin );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, pin->GetPosition() );
|
||||
|
@ -255,10 +251,9 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
|||
}
|
||||
else if( SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( item ) )
|
||||
{
|
||||
if( text->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
|
||||
if( text->GetShownText( &sheet, true ).Matches( wxS( "*${*}*" ) ) )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem =
|
||||
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( text );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() );
|
||||
|
@ -267,10 +262,9 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
|||
}
|
||||
else if( SCH_TEXTBOX* textBox = dynamic_cast<SCH_TEXTBOX*>( item ) )
|
||||
{
|
||||
if( textBox->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
|
||||
if( textBox->GetShownText( &sheet, true ).Matches( wxS( "*${*}*" ) ) )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem =
|
||||
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
ercItem->SetItems( textBox );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, textBox->GetPosition() );
|
||||
|
@ -283,7 +277,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
|||
{
|
||||
if( DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item ) )
|
||||
{
|
||||
if( text->GetShownText( true ).Matches( wxS( "*${*}*" ) ) )
|
||||
if( text->GetShownText( &sheet, true ).Matches( wxS( "*${*}*" ) ) )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> erc = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
|
||||
erc->SetErrorMessage( _( "Unresolved text variable in drawing sheet" ) );
|
||||
|
@ -294,8 +288,6 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_schematic->SetCurrentSheet( savedCurrentSheet );
|
||||
}
|
||||
|
||||
|
||||
|
@ -881,6 +873,8 @@ int ERC_TESTER::TestSimilarLabels()
|
|||
{
|
||||
for( CONNECTION_SUBGRAPH* subgraph : net.second )
|
||||
{
|
||||
const SCH_SHEET_PATH& sheet = subgraph->GetSheet();
|
||||
|
||||
for( SCH_ITEM* item : subgraph->GetItems() )
|
||||
{
|
||||
switch( item->Type() )
|
||||
|
@ -891,23 +885,26 @@ int ERC_TESTER::TestSimilarLabels()
|
|||
{
|
||||
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item );
|
||||
|
||||
wxString normalized = label->GetShownText( false ).Lower();
|
||||
wxString normalized = label->GetShownText( &sheet, false ).Lower();
|
||||
|
||||
if( !labelMap.count( normalized ) )
|
||||
{
|
||||
labelMap[normalized] = std::make_pair( label, subgraph->GetSheet() );
|
||||
labelMap[normalized] = std::make_pair( label, sheet );
|
||||
break;
|
||||
}
|
||||
else if( labelMap.at( normalized ).first->GetShownText( false )
|
||||
!= label->GetShownText( false ) )
|
||||
|
||||
auto& [ otherLabel, otherSheet ] = labelMap.at( normalized );
|
||||
|
||||
if( otherLabel->GetShownText( &otherSheet, false )
|
||||
!= label->GetShownText( &sheet, false ) )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS );
|
||||
ercItem->SetItems( label, labelMap.at( normalized ).first );
|
||||
ercItem->SetSheetSpecificPath( subgraph->GetSheet() );
|
||||
ercItem->SetItemsSheetPaths( subgraph->GetSheet(),
|
||||
labelMap.at( normalized ).second );
|
||||
ercItem->SetSheetSpecificPath( sheet );
|
||||
ercItem->SetItemsSheetPaths( sheet, labelMap.at( normalized ).second );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, label->GetPosition() );
|
||||
subgraph->GetSheet().LastScreen()->Append( marker );
|
||||
sheet.LastScreen()->Append( marker );
|
||||
errors += 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -304,8 +304,12 @@ void ERC_TREE_MODEL::GetValue( wxVariant& aVariant, wxDataViewItem const& aItem,
|
|||
|
||||
if( aSheet != curSheet )
|
||||
{
|
||||
schEditFrame->SetCurrentSheet( aSheet );
|
||||
aSheet.UpdateAllScreenReferences();
|
||||
desc = aCurrItem->GetItemDescription( m_editFrame );
|
||||
{
|
||||
desc = aCurrItem->GetItemDescription( m_editFrame );
|
||||
}
|
||||
schEditFrame->SetCurrentSheet( curSheet );
|
||||
curSheet.UpdateAllScreenReferences();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -862,16 +862,11 @@ bool SCH_LABEL_BASE::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* toke
|
|||
if( sheet->ResolveTextVar( &path, token, aDepth + 1 ) )
|
||||
return true;
|
||||
}
|
||||
else if( aPath && aPath->Last() )
|
||||
else
|
||||
{
|
||||
if( aPath->Last()->ResolveTextVar( aPath, token, aDepth + 1 ) )
|
||||
return true;
|
||||
}
|
||||
else if( SCH_SHEET* sheet = schematic->CurrentSheet().Last() )
|
||||
{
|
||||
if( sheet->ResolveTextVar( aPath, token, aDepth + 1 ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1437,7 +1432,8 @@ const BOX2I SCH_LABEL::GetBodyBoundingBox() const
|
|||
|
||||
wxString SCH_LABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
|
||||
{
|
||||
return wxString::Format( _( "Label '%s'" ), KIUI::EllipsizeMenuText( GetText() ) );
|
||||
return wxString::Format( _( "Label '%s'" ),
|
||||
KIUI::EllipsizeMenuText( GetShownText( false ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1706,7 +1702,7 @@ wxString SCH_DIRECTIVE_LABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider
|
|||
{
|
||||
return wxString::Format( _( "Directive Label [%s %s]" ),
|
||||
UnescapeString( m_fields[0].GetName() ),
|
||||
KIUI::EllipsizeMenuText( m_fields[0].GetText() ) );
|
||||
KIUI::EllipsizeMenuText( m_fields[0].GetShownText( false ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1914,7 +1910,8 @@ void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings
|
|||
|
||||
wxString SCH_GLOBALLABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
|
||||
{
|
||||
return wxString::Format( _( "Global Label '%s'" ), KIUI::EllipsizeMenuText( GetText() ) );
|
||||
return wxString::Format( _( "Global Label '%s'" ),
|
||||
KIUI::EllipsizeMenuText( GetShownText( false ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -2048,7 +2045,7 @@ VECTOR2I SCH_HIERLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings
|
|||
wxString SCH_HIERLABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
|
||||
{
|
||||
return wxString::Format( _( "Hierarchical Label '%s'" ),
|
||||
KIUI::EllipsizeMenuText( GetText() ) );
|
||||
KIUI::EllipsizeMenuText( GetShownText( false ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -254,7 +254,12 @@ public:
|
|||
|
||||
wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
|
||||
{
|
||||
return GetShownText( nullptr, aAllowExtraText, aDepth );
|
||||
SCHEMATIC* schematic = Schematic();
|
||||
|
||||
if( schematic )
|
||||
return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
|
||||
else
|
||||
return GetText();
|
||||
}
|
||||
|
||||
bool HasCachedDriverName() const override;
|
||||
|
|
|
@ -253,7 +253,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
|
|||
{
|
||||
if( token->IsSameAs( m_fields[i].GetCanonicalName().Upper() ) )
|
||||
{
|
||||
*token = m_fields[i].GetShownText( nullptr, false, aDepth + 1 );
|
||||
*token = m_fields[i].GetShownText( aPath, false, aDepth + 1 );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
|
|||
{
|
||||
if( token->IsSameAs( m_fields[i].GetName() ) )
|
||||
{
|
||||
*token = m_fields[i].GetShownText( nullptr, false, aDepth + 1 );
|
||||
*token = m_fields[i].GetShownText( aPath, false, aDepth + 1 );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -300,12 +300,12 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
|
|||
SCH_SHEET_PATH path = *aPath;
|
||||
path.pop_back();
|
||||
|
||||
if( path.Last()->ResolveTextVar( aPath, token, aDepth + 1 ) )
|
||||
if( path.Last()->ResolveTextVar( &path, token, aDepth + 1 ) )
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( schematic->ResolveTextVar( token, aDepth + 1 ) )
|
||||
if( schematic->ResolveTextVar( aPath, token, aDepth + 1 ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -947,10 +947,10 @@ SCH_FIELD* SCH_SYMBOL::GetFieldById( int aFieldId )
|
|||
|
||||
SCH_FIELD* SCH_SYMBOL::GetFieldByName( const wxString& aFieldName )
|
||||
{
|
||||
for( size_t ii = 0; ii < m_fields.size(); ++ii )
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( m_fields[ii].GetName() == aFieldName )
|
||||
return &m_fields[ii];
|
||||
if( field.GetName() == aFieldName )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -959,35 +959,23 @@ SCH_FIELD* SCH_SYMBOL::GetFieldByName( const wxString& aFieldName )
|
|||
|
||||
const SCH_FIELD* SCH_SYMBOL::GetFieldByName( const wxString& aFieldName ) const
|
||||
{
|
||||
for( size_t ii = 0; ii < m_fields.size(); ++ii )
|
||||
for( const SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( m_fields[ii].GetName() == aFieldName )
|
||||
return &m_fields[ii];
|
||||
if( field.GetName() == aFieldName )
|
||||
return &field;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
wxString SCH_SYMBOL::GetFieldText( const wxString& aFieldName ) const
|
||||
{
|
||||
for( const SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( aFieldName == field.GetName() || aFieldName == field.GetCanonicalName() )
|
||||
return field.GetText();
|
||||
}
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly )
|
||||
{
|
||||
for( SCH_FIELD& field : m_fields )
|
||||
{
|
||||
if( aVisibleOnly )
|
||||
{
|
||||
if( !field.IsVisible() || field.GetShownText( nullptr, true ).IsEmpty() )
|
||||
if( !field.IsVisible() || field.GetText().IsEmpty() )
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -998,10 +986,8 @@ void SCH_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly
|
|||
|
||||
SCH_FIELD* SCH_SYMBOL::AddField( const SCH_FIELD& aField )
|
||||
{
|
||||
int newNdx = m_fields.size();
|
||||
|
||||
m_fields.push_back( aField );
|
||||
return &m_fields[newNdx];
|
||||
return &m_fields.back();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -401,13 +401,6 @@ public:
|
|||
|
||||
const SCH_FIELD* GetFieldByName( const wxString& aFieldName ) const;
|
||||
|
||||
/**
|
||||
* Search for a field named \a aFieldName and returns text associated with this field.
|
||||
*
|
||||
* @param aFieldName is the name of the field
|
||||
*/
|
||||
wxString GetFieldText( const wxString& aFieldName ) const;
|
||||
|
||||
/**
|
||||
* Populate a std::vector with SCH_FIELDs.
|
||||
*
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <sch_item.h>
|
||||
#include <sch_field.h>
|
||||
#include <sch_connection.h> // for CONNECTION_TYPE
|
||||
#include <schematic.h>
|
||||
|
||||
|
||||
class HTML_MESSAGE_BOX;
|
||||
|
@ -59,7 +60,12 @@ public:
|
|||
|
||||
wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
|
||||
{
|
||||
return GetShownText( nullptr, aAllowExtraText, aDepth );
|
||||
SCHEMATIC* schematic = Schematic();
|
||||
|
||||
if( schematic )
|
||||
return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
|
||||
else
|
||||
return GetText();
|
||||
}
|
||||
|
||||
int GetSchTextSize() const { return GetTextWidth(); }
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <eda_text.h>
|
||||
#include <sch_shape.h>
|
||||
#include <schematic.h>
|
||||
|
||||
|
||||
class HTML_MESSAGE_BOX;
|
||||
|
@ -63,7 +64,12 @@ public:
|
|||
|
||||
wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
|
||||
{
|
||||
return GetShownText( nullptr, aAllowExtraText, aDepth );
|
||||
SCHEMATIC* schematic = Schematic();
|
||||
|
||||
if( schematic )
|
||||
return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
|
||||
else
|
||||
return GetText();
|
||||
}
|
||||
|
||||
bool IsHypertext() const override
|
||||
|
|
|
@ -153,45 +153,45 @@ void SCHEMATIC::GetContextualTextVars( wxArrayString* aVars ) const
|
|||
}
|
||||
|
||||
|
||||
bool SCHEMATIC::ResolveTextVar( wxString* token, int aDepth ) const
|
||||
bool SCHEMATIC::ResolveTextVar( const SCH_SHEET_PATH* aSheetPath, wxString* token,
|
||||
int aDepth ) const
|
||||
{
|
||||
if( !CurrentSheet().empty() )
|
||||
{
|
||||
if( token->IsSameAs( wxT( "#" ) ) )
|
||||
{
|
||||
*token = CurrentSheet().GetPageNumber();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "##" ) ) )
|
||||
{
|
||||
*token = wxString::Format( "%i", Root().CountSheets() );
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "SHEETPATH" ) ) )
|
||||
{
|
||||
*token = CurrentSheet().PathHumanReadable();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "SHEETNAME" ) ) )
|
||||
{
|
||||
*token = CurrentSheet().Last()->GetName();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "FILENAME" ) ) )
|
||||
{
|
||||
wxFileName fn( GetFileName() );
|
||||
*token = fn.GetFullName();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "PROJECTNAME" ) ) )
|
||||
{
|
||||
*token = Prj().GetProjectName();
|
||||
return true;
|
||||
}
|
||||
wxCHECK( aSheetPath, false );
|
||||
|
||||
if( CurrentSheet().LastScreen()->GetTitleBlock().TextVarResolver( token, m_project ) )
|
||||
return true;
|
||||
if( token->IsSameAs( wxT( "#" ) ) )
|
||||
{
|
||||
*token = aSheetPath->GetPageNumber();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "##" ) ) )
|
||||
{
|
||||
*token = wxString::Format( "%i", Root().CountSheets() );
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "SHEETPATH" ) ) )
|
||||
{
|
||||
*token = aSheetPath->PathHumanReadable();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "SHEETNAME" ) ) )
|
||||
{
|
||||
*token = aSheetPath->Last()->GetName();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "FILENAME" ) ) )
|
||||
{
|
||||
wxFileName fn( GetFileName() );
|
||||
*token = fn.GetFullName();
|
||||
return true;
|
||||
}
|
||||
else if( token->IsSameAs( wxT( "PROJECTNAME" ) ) )
|
||||
{
|
||||
*token = Prj().GetProjectName();
|
||||
return true;
|
||||
}
|
||||
|
||||
if( aSheetPath->LastScreen()->GetTitleBlock().TextVarResolver( token, m_project ) )
|
||||
return true;
|
||||
|
||||
if( Prj().TextVarResolver( token ) )
|
||||
return true;
|
||||
|
|
|
@ -128,7 +128,7 @@ public:
|
|||
|
||||
void GetContextualTextVars( wxArrayString* aVars ) const;
|
||||
|
||||
bool ResolveTextVar( wxString* token, int aDepth ) const;
|
||||
bool ResolveTextVar( const SCH_SHEET_PATH* aSheetPath, wxString* token, int aDepth ) const;
|
||||
|
||||
/// Helper to retrieve the filename from the root sheet screen
|
||||
wxString GetFileName() const override;
|
||||
|
|
Loading…
Reference in New Issue